Skip to content

fix(reflect): accept done after a search that found nothing (#5702) - #5777

Merged
nicoloboschi merged 1 commit into
mainfrom
triage/5702
Oct 19, 2026
Merged

nicoloboschi merged 1 commit into
mainfrom
triage/5702

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Fixes #5702.

Problem

Reflect refuses to accept an answer until it has "searched". It decided that by checking whether any memory ids had been collected — so a search that ran fine and found nothing looked like no search. On an empty scope (e.g. a strict tag nobody has), the model's "nothing is recorded" answer was sent back with "You must search for information first" until the iterations ran out: ~3 extra LLM calls and several seconds per call, for the same final answer.

Fix

Remember whether a retrieval tool (search_mental_models, read_mental_models, search_observations, recall) returned a result, even an empty one, and gate done on that. A tool that returned an error still doesn't count, and answering before any search is still refused. The "nothing found before recall ran → force recall" guard is unchanged.

Same idea as the patch the reporter (@sergesha) posted in the issue — thanks!

Tests

  • test_reflect_agent.py: done after an empty recall / observations / mental-model search is accepted (fail on main, pass here); an errored search still bounces done.
  • System story test_40_reflect.py::test_a_scope_with_nothing_in_it_is_answered_on_the_first_try: reflect over an empty tag scope is answered without a bounce (fails on main, passes here).

The "search first" guard checked whether any evidence ids had been
collected, so a search that ran and came back empty looked the same as no
search at all. On an empty scope the model's honest "nothing is recorded"
answer was bounced until the loop gave up, costing ~3 extra LLM calls.

Track whether a retrieval tool returned a result (even an empty one) and
gate done on that. A search that errored still does not count.

Tests: unit tests for empty recall/observations/mental models and for an
errored search; a system story reflecting over an empty tag scope.
@nicoloboschi
nicoloboschi merged commit e530a81 into main Oct 19, 2026
117 checks passed
@nicoloboschi
nicoloboschi deleted the triage/5702 branch October 19, 2026 13:22
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 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.

Reflect rejects done after successful empty retrieval, causing repeated completion attempts and forced closing

1 participant