Repository navigation
test(memory): reset the sticky tool tracker between memory gate tests - #4873
Open
chopratejas wants to merge 1 commit into
Open
chopratejas wants to merge 1 commit into
chopratejas wants to merge 1 commit into
Conversation
Memory tool definitions are sticky per session in a process-wide tracker. When a test that injected them ran earlier in the same process with an identical request, a later "not injected" case replayed the tools, and the proxy correctly ran the calls it had offered, failing the test. Reset the tracker around each test. Assay-Kind: tests Assay-Ask: The memory "not injected" tests failed on main when a test that injected memory tools for an identical request ran earlier in the same process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chopratejas
requested review from
DevanshiVyas and
JerrettDavis
as code owners
November 14, 2026 05:56
Contributor
PR governanceThis PR follows the template and is marked ready for human review. |
Comment on lines
+26
to
+33
| @pytest.fixture(autouse=True) | ||
| def _fresh_tool_tracker(): | ||
| # Memory tools are sticky per session in a process-wide tracker: a test | ||
| # that injected them would make a later identical request replay them, | ||
| # and the proxy then correctly runs the calls it offered. | ||
| _reset_session_tool_tracker_for_test() | ||
| yield | ||
| _reset_session_tool_tracker_for_test() |
Contributor
There was a problem hiding this comment.
🟡 Prohibited standalone test-isolation fix
Adding _fresh_tool_tracker makes this a test-only PR addressing a known main-branch failure. The contribution policy explicitly prohibits that submission category.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch was successfully 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.
Description
On main,
test_memory_call_the_proxy_did_not_inject_reaches_the_client[not_injected-anthropic]and[not_injected-anthropic_stream]fail whentests/test_memory_tool_user_scope.pyruns earlier in the same process (CI shardtest (3)).This is a test-isolation problem, not a regression in the proxy. Memory tool definitions are sticky per session (
SessionToolTracker, a process-wide tracker inheadroom/proxy/helpers.py). The user-scope test sends an identical Anthropic request with memory tools injected. When the laternot_injectedcase sends the same request, the session tracker replays those tool definitions, so the proxy really does offermemory_deleteupstream on that request. Running the call is then the intended behaviour. Each PR passed alone because nothing else in its own shard had injected tools for that request first.The fix resets the tracker before and after each test in
tests/test_memory_tools_only_when_injected.py. The same reset is already used intest_memory_tool_stream.pyandtest_corrupt_golden_bytes_recovery.py.Type of Change
Changes Made
tests/test_memory_tools_only_when_injected.py: an autouse fixture calls_reset_session_tool_tracker_for_test()around each test. No production code changes.Testing
pytest)ruff check .)mypy headroom) (tests-only change)Test Output
Same order as CI (
tests/test_memory_tool_user_scope.pythentests/test_memory_tools_only_when_injected.py), on origin/main fda75de:On this branch:
Injected controls first, then the not-injected cases, in one process: 4 failed on main,
11 passedon this branch.tests/test_memory_tool_user_scope.py tests/test_memory_tools_only_when_injected.py tests/test_memory/ tests/test_memory_handler_native_ops.py:780 passed, 2 skipped. ruff check and format are clean.Real Behavior Proof
create_appwith aMockTransportupstream,LITELLM_LOCAL_MODEL_COST_MAP=True.assert ['delete'] == []because the replayed session tools are injected; on this branch all pass.Runtime Rollout Safety
Review Readiness
Checklist
CHANGELOG.md— it is generated by release-please from my Conventional Commit PR title (a CI guard enforces this)Additional Notes
Sticky replay only matters within a single process that serves the same session under different memory settings, which a running proxy (with one fixed config) does not do.
🤖 Generated with Claude Code