Skip to content

fix: tool_search streak counter fires injection at 3 and tool_describe at 5 (Closes #1373) - #1459

Merged
Lexus2016 merged 2 commits into
mainfrom
evolution/issue-1373-tool-search-streak
Jul 28, 2026
Merged

fix: tool_search streak counter fires injection at 3 and tool_describe at 5 (Closes #1373)#1459
Lexus2016 merged 2 commits into
mainfrom
evolution/issue-1373-tool-search-streak

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Automated evolution PR for issue #1373.

Root cause: callers pass session_id=agent.session_id or empty string, and the old streak counter treated any falsy value (incl. empty string) as do-not-track, so the streak never incremented and the fallback directive never fired.

Fix:

  • Map empty-string session_id to stable key default_session so production fires; None still opts out (preserves pure-function test contract).
  • Add per-session previous-queries tracking (rolling, capped at 8).
  • At streak >= 3 (search_streak_threshold): inject full tool list + previous queries + fallback directive.
  • At streak >= 5 (new search_streak_describe_threshold): additionally inject auto_describe with the top hit full schema.

Tests: 8 new tests in TestSearchStreakEmptySessionNowFires covering all four spec requirements.

…cribe at 5 (#1373)

Closes #1373

Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
@github-actions github-actions Bot added fix Bug or fix security labels Jul 28, 2026
@Lexus2016

Copy link
Copy Markdown
Owner Author

Reviewed and merging. This correctly implements the root cause my diagnostic PR (#1445) surfaced, and goes further by adding previous_queries so the model can see it is circling.

One risk worth recording rather than blocking on: all empty-session callers now share a single __default_session__ counter. Sub-agents built by delegate_task run in the same process, so if a parent and a child both reach the counter with an empty session id, their streaks add together and the directive fires earlier than either warrants.

Worst case is a nudge one or two searches early, which is mild — and the alternative (no counter at all) is what this PR is fixing. Worth watching in the next digest: if tool_search streak counts drop but the directive appears in sessions that only searched twice, this is why.

Note the diagnostic warning from #1445 is removed here, which is right — there is no longer a silent-off path to warn about. If a future change reintroduces one, the lesson is that a counter returning 0 forever looks identical to a counter that is working.

@Lexus2016
Lexus2016 merged commit d12a78d into main Jul 28, 2026
36 checks passed
@Lexus2016
Lexus2016 deleted the evolution/issue-1373-tool-search-streak branch July 28, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug or fix security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant