fix: web_search diverse-query loop, stale process_id recovery, tool_describe cache (#1012 #1014 #1015)#1018
Merged
Conversation
…escribe cache (#1012 #1014 #1015) #1012 — web_search diverse-query spiral guard - Add _WEB_SEARCH_DIVERSE_QUERY_CAP=6 in loop_guard.py - When web_search is called 6+ times with different queries, nudge the model to STOP searching and synthesize from results gathered - Complements existing same-argument short-circuit (#467) - 4 new tests + 1 updated test in test_loop_guard.py #1014 — stale session_id recovery in process tool - Validate session_id against process_registry before dispatching - When ID not found, enrich error with available process IDs - Model can self-correct in one round-trip instead of looping - 3 new tests in test_process_schema_confusion.py #1015 — tool_describe schema caching - Add in-memory cache keyed by (name, toolset_signature) - Cache invalidates naturally when tool set changes - Error responses are not cached - clear_describe_cache() for explicit invalidation - 3 new tests in test_tool_search.py Version bump: 0.18.2 → 0.18.3
This was referenced Jul 15, 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
Consolidation-mode reliability fixes for three open issues, plus version bump 0.18.2 → 0.18.3.
#1012 — web_search diverse-query spiral guard
Problem: The loop guard catches repeated web_search with identical queries (#467 same-arg short-circuit), but a model that reformulates the query each time (different args, each call "succeeds") spirals indefinitely — never stopping to synthesize.
Fix: Added
_WEB_SEARCH_DIVERSE_QUERY_CAP = 6inagent/loop_guard.py. When web_search is called 6+ times with ≥2 distinct query hashes, the guard nudges the model to "STOP searching and synthesize an answer from the results you already have." This fires before the generic repeat threshold (8) and complements (not replaces) the existing same-arg guard.Tests: 4 new tests + 1 updated test in
test_loop_guard.py.#1014 — stale session_id recovery in process tool
Problem: When
session_iddoesn't resolve to any registered process, the registry returns a barenot_foundwith no recovery hint. The model retries the same stale ID, looping.Fix: Added session_id existence validation in
tools/process_registry.py_handle_process(). When the ID isn't found, the error is enriched with the actual available process IDs (up to 5), so the model can self-correct in one round-trip. When no processes exist at all, the error says so explicitly.Tests: 3 new tests in
test_process_schema_confusion.py.#1015 — tool_describe schema caching
Problem: Repeated
tool_describecalls (common when the model forgets a tool's schema between turns) trigger a full catalog scan each time, contributing to 23 observed failures.Fix: Added an in-memory cache in
tools/tool_search.pykeyed by(tool_name, toolset_signature). The signature is derived from the sorted set of currently available tool names, so the cache invalidates naturally when the tool set changes (different session, enabled/disabled toolsets). Error responses are not cached. Addedclear_describe_cache()for explicit invalidation. Cache is bounded at 64 entries with FIFO eviction.Tests: 3 new tests in
test_tool_search.py.Version bump
pyproject.toml: 0.18.2 → 0.18.3acp_registry/agent.json: 0.18.2 → 0.18.3 (bothversionanddistribution.uvx.package)uv.lockregeneratedTest Results
All 171 tests across 4 test files pass:
tests/agent/test_loop_guard.py— 79 ✓tests/tools/test_tool_search.py— 56 ✓tests/tools/test_process_schema_confusion.py— 33 ✓tests/scripts/test_release_acp_registry.py— 3 ✓Production code: 122 lines (within 200-line self-merge cap)