Repository navigation
Studio: let search_conversation find this turn's results on API providers - #16666
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
2 of 5 tasks
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 #16602
What was wrong
On API providers (OpenRouter, OpenAI-compatible custom servers and so on), Studio runs the tool loop itself and refits the context before every provider call. When a refit pushes out a tool result from the current turn, that result is archived, and
search_conversationis meant to get it back later in the same turn.The archive only returns chunks that are on the branch the tool is given. The external loop gave the tool the client's messages as they were when the turn started, so a result produced during this turn was never on that branch. It was archived and then filtered out of every search. The model saw "the conversation search came back empty" and answered that it had no earlier findings.
The local llama.cpp loop already passes a branch that grows as the loop goes (
_extend_live_branch), so GGUF models were not affected.The change
stream_with_studio_toolskeeps the same kind of growing branch: the request's messages plus every message the loop adds.search_conversationgets a snapshot of it on each call. Nothing else reads the old frozen copy.Tests
test_search_conversation_branch_holds_this_turns_tool_results(tests/test_external_tool_edge_cases.py): oneweb_searchcall, then asearch_conversationcall, checking that the branch handed to the tool holds theweb_searchresult. It fails on main and passes with the change.web_searchcalls, the context refits 10 times, and then it callssearch_conversationfor a finding from round 1. On main the chunk is in the archive, but the tool returns only older saved turns. With the change the finding comes back.test_studio_tool_loop.py,test_external_tool_edge_cases.py,test_external_conversation_archive.py,test_external_auto_compaction.py,test_conversation_recall_injection.py,test_conversation_recall_session.py,test_conversation_archive.py,test_external_tool_refusal_gates.py,test_external_mcp_delta_provenance.py,test_external_preserve_thinking.py,test_external_tool_call_id_replay.py,test_tool_loop_controller.py(637 passed).