fix(provider): preserve OpenAI reasoning item for web_search_call multi-turn#159
Merged
Merged
Conversation
…ti-turn GPT-5.5 requires a `reasoning` item to precede `web_search_call` in conversation history. Three gaps caused the item to be lost: 1. stream.rs: `parse_output_item_done` did not handle `"reasoning"` type, so the reasoning ID was never captured as ThinkingSignature. 2. llm_record.rs: condition was too strict — thinking block was not saved when text was empty but server blocks existed. 3. input_builder.rs: ContentBlock::Thinking was silently ignored instead of being converted to the OpenAI `reasoning` input item.
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.
Summary
web_search_callitem was provided without its requiredreasoningitemreasoningoutput item from OpenAI Responses API stream, storing its ID viaThinkingSignatureContentBlock::Thinkingto OpenAIreasoninginput item on multi-turn replayChanges
crates/loopal-provider/src/openai/stream.rs— handle"reasoning"inparse_output_item_donecrates/loopal-provider/src/openai/input_builder.rs— emitreasoningitem fromContentBlock::Thinkingcrates/loopal-runtime/src/agent_loop/llm_record.rs— relax save condition for thinking blocks with server blocksopenai_reasoning_test.rs,openai_reasoning_e2e_test.rsTest plan
bazel test //crates/loopal-provider:loopal-provider_testpassesbazel test //crates/loopal-provider:loopal-provider-unit-testpassesbazel test //crates/loopal-runtime:loopal-runtime-unit-testpassesbazel build //... --config=clippyzero warnings