Unify reasoning request conversion across protocols - #46
Merged
Merged
Conversation
Reviewer's GuideThis PR introduces a shared reasoning normalization layer used by all request protocols and routing, preserving readable reasoning as separate assistant history while consistently mapping controls and account-specific defaults, including after failover. It adds documentation and comprehensive regression coverage for conversion, streaming, capability, validation, and routing edge cases. Sequence diagram for protocol reasoning conversion and account defaultssequenceDiagram
participant Client
participant Protocol as Protocol adapter
participant Reasoning as app.reasoning
participant Router
participant Account
participant Upstream
Client->>Protocol: Submit request
Protocol->>Reasoning: map_reasoning_controls(body, chat, protocol)
Reasoning-->>Protocol: Explicit reasoning_effort or implicit control
Protocol->>Router: Validate and route canonical request
Router->>Account: Select account and model
Account-->>Router: Account reasoning metadata
Router->>Reasoning: resolve_reasoning_effort(effort, mode, model)
Reasoning-->>Router: Account-compatible effort
Router->>Upstream: Send normalized reasoning_effort
Upstream-->>Client: Response or stream
Flow diagram for preserving readable reasoning historyflowchart TD
Input[Protocol history item]
Extract[extract_reasoning_text]
Reject{Opaque or encrypted reasoning?}
Preserve[Append to assistant reasoning_content]
Content[Keep answer text and tool calls separate]
Convert[Forward normalized assistant history]
Input --> Extract
Extract --> Reject
Reject -- Yes --> Error[Return HTTP 400 before routing]
Reject -- No --> Preserve
Input --> Content
Preserve --> Convert
Content --> Convert
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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. |
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.
Changes
app/reasoning.py, shared by Chat, Messages, Responses and routing/capability checks.thinking/output_config.effortand preserve Responses effort extensions supported by the selected model. Resolve implicit effort from the selected account again after failover, while retaining explicit controls and existing capability, binding and free-tier checks.reasoning_content, including thinking-only turns and tool continuations. Keep Responses reasoning, text and calls together even when realtime output starts with a tool call; never inject reasoning into ordinary answer text.Verification
vp buildsucceeds. Served WebUI assets match the rebuilt files;git diff --checkand version consistency pass. Focused Ruff checks have no new findings relative to the base.Fixes #43
Summary by Sourcery
Standardize reasoning conversion and validation across supported protocols while preserving compatible history and routing behavior.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: