Add cadence_thresholds passthrough to clients#29
Merged
aayush3011 merged 4 commits intoJul 8, 2026
Merged
Conversation
Consumers can now set per-turn processing cadence (fact extraction, dedup, thread/user summary frequency) in-process via a cadence_thresholds mapping on CosmosMemoryClient and AsyncCosmosMemoryClient, instead of only through os.environ. The auto-trigger already accepted a thresholds override; the clients now forward it. None preserves the env-only behavior and missing keys fall back to env/defaults, so this is backward compatible.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an instance-scoped way to configure the cadence/threshold behavior of the Cosmos memory auto-trigger by introducing a cadence_thresholds constructor argument on both the sync and async Cosmos memory clients, avoiding process-global os.environ mutation for library consumers.
Changes:
- Added
cadence_thresholds: Mapping[str, int] | NonetoCosmosMemoryClientandAsyncCosmosMemoryClientconstructors and stored it on the instance. - Forwarded the stored thresholds override into
maybe_trigger_steps(..., thresholds=self._cadence_thresholds)from_maybe_auto_trigger. - Added unit tests to validate forwarding behavior (including default
None) and updated the changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
azure/cosmos/agent_memory/cosmos_memory_client.py |
Adds cadence_thresholds parameter and forwards it into the sync auto-trigger call. |
azure/cosmos/agent_memory/aio/cosmos_memory_client.py |
Adds cadence_thresholds parameter and forwards it into the async auto-trigger call. |
tests/unit/test_cosmos_memory_client.py |
Adds sync client unit tests verifying thresholds passthrough behavior. |
tests/unit/aio/test_auto_trigger.py |
Adds async client unit tests verifying thresholds passthrough behavior. |
CHANGELOG.md |
Documents the new in-process cadence configuration capability under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aayush3011
approved these changes
Jul 8, 2026
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.
Summary
Adds a
cadence_thresholdsconstructor argument toCosmosMemoryClientandAsyncCosmosMemoryClientso consumers can set per-turn processing cadence(fact extraction, dedup, thread/user summary frequency) in-process, instead
of only through environment variables.
Motivation
Today the only way to configure cadence is via environment variables, because the
auto-trigger reads thresholds from
os.environ. That's fine for operators, butit's a problem for library consumers.
The Agent Framework Cosmos memory provider
wraps this client, and to expose cadence configuration it currently has to mutate
os.environat runtime. Reviewers (rightly) pushed back on that: it's aprocess-global side effect, not scoped to the client instance, and surprising in a
library. This change gives consumers a clean, instance-scoped way to pass the
values directly.
Change
The auto-trigger already accepted an optional
thresholdsoverride (a mapping keyedby the same names as the env vars); the clients simply weren't forwarding one. This
PR:
cadence_thresholds: Mapping[str, int] | None = Noneto both clients.maybe_trigger_steps(..., thresholds=self._cadence_thresholds)in_maybe_auto_trigger.