Draft
Conversation
bambriz
commented
Apr 7, 2026
| DEFAULT_CONTEXT_PROMPT: ClassVar[str] = "Use the following context to answer the question:" | ||
| _DEFAULT_RESULT_LIMIT: ClassVar[int] = 5 | ||
| _DEFAULT_SCAN_LIMIT: ClassVar[int] = 25 | ||
| _DEFAULT_SEARCH_MODE: ClassVar[CosmosContextSearchMode] = CosmosContextSearchMode.FULL_TEXT |
bambriz
commented
Apr 7, 2026
| url_field_name: str | None = "url", | ||
| message_field_name: str | None = "message", | ||
| metadata_field_name: str | None = "metadata", | ||
| vector_field_name: str | None = None, |
Author
There was a problem hiding this comment.
should have default vector field name
bambriz
commented
Apr 7, 2026
| self._cosmos_client = CosmosClient( | ||
| url=settings["endpoint"], # type: ignore[arg-type] | ||
| credential=credential or settings["key"].get_secret_value(), # type: ignore[arg-type,union-attr] | ||
| user_agent_suffix=AGENT_FRAMEWORK_USER_AGENT, |
Author
There was a problem hiding this comment.
add something related to cosmos db python (to track what cosmos sdk is being used)
bambriz
commented
Apr 7, 2026
| scan_limit: int | None | ||
|
|
||
|
|
||
| class AzureCosmosContextProvider(BaseContextProvider): |
Author
There was a problem hiding this comment.
basecontextproivder is now contextproivder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR adds
AzureCosmosContextProviderto theagent-framework-azure-cosmospackage.The goal is to enable Azure Cosmos DB-backed retrieval for Agent Framework sessions, so an agent can pull relevant context before a run and write conversation data back after the run. This brings the Cosmos package beyond history persistence and adds a retrieval-oriented context provider pattern similar to other context provider integrations in the repo.
This change contributes to scenarios where:
It also keeps the API intentionally simple by avoiding extra query-builder-style configuration and instead following the same general pattern used by other context provider packages.
Description
This PR introduces
AzureCosmosContextProviderin the Azure Cosmos package.The provider adds two main behaviors:
before_run(...): retrieves relevant context from an existing Cosmos container and injects it into the sessionafter_run(...): writes eligible input and response messages back into the configured Cosmos container after every runKey design choices in this implementation:
userandassistantmessages from the current run into a single query string.top_kscan_limitpartition_keybefore_run(...), including:search_modeweightstop_kscan_limitpartition_keyThis allows normal agent usage to stay simple while still supporting advanced scenarios where one provider instance is reused across multiple runs with different retrieval settings.
The provider supports:
Writeback is always performed in
after_run(...), so the knowledge container can accumulate conversation data over time. Those writeback documents are tagged with an internal document type and excluded from retrieval queries.This PR also updates the Azure Cosmos package docs, samples, and tests to document and validate the new provider behavior.
Important usage guidance called out in the docs:
before_run(...)for a specific runContribution Checklist