Repository navigation
[Python] Add a dedicated Cosmos memory provider User-Agent token - #9223
Merged
westey (westey-m) merged 2 commits intoOct 9, 2026
Merged
westey (westey-m) merged 2 commits into
westey (westey-m) merged 2 commits into
Conversation
Pass the Agent Framework user agent to provider-created Agent Memory Toolkit clients so Cosmos requests identify both integrations. Cover both credential paths and preserve caller-injected clients. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Theo van Kraay (TheovanKraay)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 8, 2026 19:58
Theo van Kraay (TheovanKraay)
temporarily deployed
to
github-app-auth
October 8, 2026 19:58 — with
GitHub Actions
Inactive
Theo van Kraay (TheovanKraay)
temporarily deployed
to
github-app-auth
October 8, 2026 19:58 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the toolkit API, covers both credential paths, and preserves caller-owned client behavior.
0 open findings
What changed in this PR
Adds Agent Framework identification to provider-created Cosmos memory clients while leaving caller-provided clients unchanged.
Changes:
- Passes
get_user_agent()through both credential paths. - Adds focused constructor tests for user-agent propagation and injected-client behavior.
| File | Description |
|---|---|
_context_provider.py |
Adds the Agent Framework user agent to provider-owned clients. |
test_context_provider.py |
Verifies both construction paths and injected-client behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Identify provider-created clients with agent-framework-azure-cosmos-memory and the provider package version, retaining framework and toolkit tokens. Assert the explicit identity in both credential paths and document injected-client behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Theo van Kraay (TheovanKraay)
temporarily deployed
to
github-app-auth
October 8, 2026 20:15 — with
GitHub Actions
Inactive
Theo van Kraay (TheovanKraay)
temporarily deployed
to
github-app-auth
October 8, 2026 20:16 — with
GitHub Actions
Inactive
westey (westey-m)
approved these changes
Oct 9, 2026
5 of 7 tasks
This branch was previously deployed
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 & Context
CosmosMemoryContextProvidercreates Agent Memory Toolkit clients without a provider-specific User-Agent. Cosmos requests therefore cannot distinguish this integration from direct toolkit usage.Add the explicit
agent-framework-azure-cosmos-memory/<provider-package-version>token to provider-created clients, alongsideagent-framework-python/<core-version>. The toolkit retains its ownazsdk-python-cosmos-agent-memory/<toolkit-version>token. Attribution can match the dedicated provider token rather than infer usage from generic Agent Framework traffic or customer-level overlap.Description & Review Guide
__version__, pass it with the framework User-Agent to both provider-owned client constructors, assert the exact token in both credential-path tests, and document the behavior.memory_clientinstances retain their existing User-Agent configuration. This does not retroactively identify older traffic or instrument injected clients.Package unit tests: 53 passed, 12 integration tests deselected. Ruff lint/format and package Pyright passed (0 errors, 0 warnings). A no-network check using the real toolkit and Cosmos SDK User-Agent policy confirmed that the provider header contains all three identifiers and the direct-toolkit header lacks the provider token. Live-service integration tests and the full monorepo suite were not run.
Related Issue
N/A - trivial change: adds a dedicated User-Agent token to two existing provider-owned client constructors, with focused tests and documentation. No public API changes.
AI Assistance
AI assistance details: implementation, tests, documentation, and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.