Skip to content

Python: Reuse Redis context index connection for schema validation - #9063

Open
LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/redis-context-schema-client
Open

LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/redis-context-schema-client

Conversation

@ktz03

Copy link
Copy Markdown
Contributor

Motivation & Context

An existing Redis context index can use a connection supplied through redis_index, while schema validation opens another connection using the provider's redis_url. With an injected index, that URL can still be the default localhost endpoint. Initialization should inspect the schema on the same Redis connection used to check index existence.

Description & Review Guide

  • What are the major changes? Reuse the index's initialized Redis client when loading the existing server schema. Add four regressions covering injected and URL-created indexes with compatible and incompatible schemas, and update the existing test fixture to accept the client argument.
  • What is the impact of these changes? Existing-index initialization retains the active connection and its connection settings. Schema compatibility validation and refusal to create an incompatible index remain intact. The Redis unit suite passes 322 tests with 93.34% coverage; 48 integration tests were deselected. Ruff, source Pyright, all five test type checkers, and the package build pass. No live Redis server or model service was tested.
  • What do you want reviewers to focus on? Connection reuse after exists() initializes the client, and preservation of the incompatible-schema rejection path.

Related Issue

Fixes #9062

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 15:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused implementation addresses the reported connection mismatch and covers both construction paths and schema outcomes.

Review effort: Balanced
Findings: None

What changed in this PR

Reuses the active Redis index connection during schema validation, preventing accidental fallback to localhost or another server.

Changes:

  • Passes the initialized index client to schema lookup.
  • Adds four regression scenarios for injected/URL-created indexes and compatible/incompatible schemas.
  • Updates the shared test fixture for client-based lookup.
File Description
python/​packages/​redis/​agent_framework_redis/​_context_provider.py Reuses the active Redis client for schema validation.
python/​packages/​redis/​tests/​test_context_provider_edges.py Tests connection reuse and schema rejection behavior.
python/​packages/​redis/​tests/​test_providers.py Updates the mock schema loader signature.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

This branch was previously deployed

1 inactive deployment
github-app-auth — 48f4fe2e Deployed Oct 9, 2026 by ktz03 via team_check #6413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Redis context schema checks ignore the injected index connection

2 participants