Repository navigation
fix(reflect): accept done after a search that found nothing (#5702) - #5777
Merged
Merged
Conversation
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.
This was referenced Oct 20, 2026
Merged
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.
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 gatedoneon 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.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).