Skip to content

fix: web_search diverse-query loop, stale process_id recovery, tool_describe cache (#1012 #1014 #1015)#1016

Closed
Lexus2016 wants to merge 1 commit into
mainfrom
evolution/reliability-fixes-2026-07-15
Closed

fix: web_search diverse-query loop, stale process_id recovery, tool_describe cache (#1012 #1014 #1015)#1016
Lexus2016 wants to merge 1 commit into
mainfrom
evolution/reliability-fixes-2026-07-15

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

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 = 6 in agent/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_id doesn't resolve to any registered process, the registry returns a bare not_found with 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_describe calls (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.py keyed 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. Added clear_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.3
  • acp_registry/agent.json: 0.18.2 → 0.18.3 (both version and distribution.uvx.package)
  • uv.lock regenerated

Test 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)

…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
@Lexus2016

Copy link
Copy Markdown
Owner Author

Closing to reopen from rebased branch (main advanced after #1017 merge). New PR will be created to clear BEHIND state. All CI was green.

@Lexus2016 Lexus2016 closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant