feat: cross-provider reasoning trace roundtrip#1396
Merged
joshua-mo-143 merged 2 commits into0xPlaygrounds:mainfrom Feb 17, 2026
Merged
feat: cross-provider reasoning trace roundtrip#1396joshua-mo-143 merged 2 commits into0xPlaygrounds:mainfrom
joshua-mo-143 merged 2 commits into0xPlaygrounds:mainfrom
Conversation
1 task
75c9270 to
5a93c3f
Compare
4 tasks
Implement lossless reasoning trace preservation for all providers that require it, enabling multi-turn conversations with reasoning models (tool call loops, follow-up questions). Provider changes: - OpenAI Responses API: encrypted_content roundtrip, msg_ ID threading - Anthropic: redacted reasoning blocks, multi-block signature preservation - Gemini: thinking-part thought_signature roundtrip - xAI: structured reasoning conversion and streaming alignment - OpenRouter: reasoning_details response parsing and request emission Includes integration tests for all 5 providers (reasoning_roundtrip.rs). Implements 0xPlaygrounds#1147, 0xPlaygrounds#1146, 0xPlaygrounds#684
5a93c3f to
561e102
Compare
Contributor
|
Looks like just needs |
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.
Summary
Builds on #1395 to implement full reasoning trace preservation across all providers, ensuring reasoning content survives multi-turn conversations including tool call loops.
msg_IDs through streaming/non-streaming paths; reverts strip-reasoning workaround; emitsMessageIdfromOutputItemDone; includesreasoning_encrypted_contentautomatically when reasoning is configuredReasoning→Thinking/RedactedThinkingconversion with signature preservation; streamingRedactedThinkingsupport viaget_or_insert_withthought_signatureroundtrip preservation; emits fullReasoningblock (not just delta) when signature is present in streamingReasoning↔ Chat Completionsreasoning_contentconversion with encrypted/redacted mapping; fixes#[serde(rename)]→#[serde(rename_all)]reasoning_detailsby ID preserving ordering; mapsEncrypted/Redactedcontent types through Chat Completions formatReasoningDeltaevents now accumulate in a separate text buffer instead of being converted to unsignedReasoningblocks — fixes Anthropic 400 "signature required" errors in multi-turn tool call loopsCloses #1147, closes #1146
Integration Tests
Four test suites covering both streaming and non-streaming code paths with per-provider coverage:
Streaming Tests
reasoning_roundtrip.rs(streaming) — Text-only 2-turn streaming conversation:model.stream()→ collect reasoning blocks/deltas + textreasoning_tool_roundtrip.rs(streaming) — Reasoning + tool call viaagent.stream_chat().multi_turn():get_weathertool[Reasoning, ToolCall]in chat historyNon-Streaming Tests
reasoning_roundtrip.rs(non-streaming) — Text-only 2-turn non-streaming conversation:model.completion()→ verifyCompletionResponse.choicecontainsReasoningblocksreasoning_tool_roundtrip.rs(non-streaming) — Reasoning + tool call viaagent.chat():model.completion(), preserves reasoning viaresp.choice.clone()Results
Test plan
cargo fmtcleancargo clippy -p rig-core --tests— 0 warningscargo test -p rig-core --lib— 271 tests passreasoning_roundtripintegration tests pass (4/4 providers)reasoning_tool_roundtripintegration tests pass (4/4 providers)reasoning_roundtripintegration tests pass (4/4 providers)reasoning_tool_roundtripintegration tests pass (4/4 providers)