Python: Fix store=False not overriding client default#4569
Open
TaoChenOSU wants to merge 4 commits intomicrosoft:mainfrom
Open
Python: Fix store=False not overriding client default#4569TaoChenOSU wants to merge 4 commits intomicrosoft:mainfrom
TaoChenOSU wants to merge 4 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the Python agent runtime where store=False provided via agent/runtime options does not correctly take precedence over client defaults (e.g., STORES_BY_DEFAULT=True), impacting whether local history storage is injected.
Changes:
- Merge agent
default_optionswith runtimeoptionsin_prepare_run_contextso runtime options take precedence. - Simplify the
InMemoryHistoryProviderauto-injection condition usingstore+STORES_BY_DEFAULT. - Update/expand unit tests around
STORES_BY_DEFAULT/storebehaviors and refreshpython/uv.lockdependency pins.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_agents.py | Merges default + runtime options earlier and adjusts store/STORES_BY_DEFAULT logic for local history injection. |
| python/packages/core/tests/core/test_agents.py | Adds/adjusts tests for storage injection behavior and reformats some existing tests. |
| python/uv.lock | Updates locked dependency versions (filelock, fonttools, kiwisolver, posthog, prek, setuptools). |
Comments suppressed due to low confidence (1)
python/packages/core/tests/core/test_agents.py:1589
- The regression this PR targets (agent-level
default_options={"store": False}should override a client withSTORES_BY_DEFAULT=True) isn’t directly covered by the added tests. Current coverage only asserts runtimeoptions={"store": False}. Please add a test whereclient.STORES_BY_DEFAULT=True, the agent is constructed withdefault_options={"store": False},run()is called without passingoptions, and InMemoryHistoryProvider is injected.
async def test_stores_by_default_with_store_false_injects_inmemory(
client: SupportsChatGetResponse,
) -> None:
"""Client with STORES_BY_DEFAULT=True but store=False should still inject InMemoryHistoryProvider."""
from agent_framework._sessions import InMemoryHistoryProvider
client.STORES_BY_DEFAULT = True # type: ignore[attr-defined]
agent = Agent(client=client)
session = agent.create_session()
await agent.run("Hello", session=session, options={"store": False})
eavanvalkenburg
approved these changes
Mar 9, 2026
…fork into local-branch-python-4488
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
moonbox3
approved these changes
Mar 9, 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.
Motivation and Context
Closes #4488
Description
Fixes the bug where runtime
store=Falseoption doesn't take precedence over client default option.Contribution Checklist