-
Notifications
You must be signed in to change notification settings - Fork 786
feat(openai): add per-request reasoning_effort override for GPT-5.1 #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add ability to dynamically control reasoning_effort parameter on a
per-request basis for OpenAI reasoning models (o1/o3/o4/gpt-5 series).
Changes:
- Add reasoning_effort field to RequestParams with Literal type hints
- Support 'none', 'low', 'medium', 'high' values in config and runtime
- Implement fallback logic: request param -> config -> default ('medium')
- Add comprehensive unit tests for reasoning_effort behavior
- Update example to demonstrate gpt-5.1 with reasoning_effort override
- Update JSON schema to include 'none' value
The reasoning_effort parameter is OpenAI-specific and only applies to
reasoning models. Non-reasoning models ignore this parameter.
Tests: Added 5 new test cases covering all reasoning_effort scenarios
WalkthroughThe changes introduce per-request specification of OpenAI reasoning effort, adding a new optional Changes
Sequence DiagramsequenceDiagram
participant User
participant augmented_llm as AugmentedLLM
participant augmented_llm_openai as OpenAIAugmentedLLM
participant OpenAI as OpenAI API
User->>augmented_llm: generate_str(request_params=RequestParams(reasoning_effort="none"))
augmented_llm->>augmented_llm_openai: Forward request_params
augmented_llm_openai->>augmented_llm_openai: Check if params.reasoning_effort provided
alt Request-level reasoning_effort exists
augmented_llm_openai->>augmented_llm_openai: Use params.reasoning_effort
else Fallback to default
augmented_llm_openai->>augmented_llm_openai: Use self._reasoning_effort ("medium")
end
augmented_llm_openai->>OpenAI: POST with reasoning_effort in payload
OpenAI-->>augmented_llm_openai: Response
augmented_llm_openai-->>augmented_llm: Result
augmented_llm-->>User: Generated output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-07-22T18:59:49.368ZApplied to files:
🧬 Code graph analysis (2)tests/workflows/llm/test_augmented_llm_openai.py (2)
examples/basic/functions/main.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (13)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
rholinshead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks @dragon1086 for the contribution and attention to detail to the contributing guidelines :)
Summary
Add per-request
reasoning_effortparameter override to support mixing reasoning and non-reasoning modes in multi-agent applications with GPT-5.1.Problem
With GPT-5.1's release, OpenAI added
reasoning_effort='none'for non-reasoning mode. However, mcp-agent only supported one globalreasoning_effortsetting per application.Real-world issue:
reasoning_effortsetting created conflictsreasoning_effort='none'for some agents andreasoning_effort='high'for othersSolution
Allow
reasoning_effortto be set per-request viaRequestParams, with fallback to config default.Usage:
Changes
reasoning_effortfield toRequestParamswithLiteral["none", "low", "medium", "high"]'none'value inOpenAISettingsconfig'medium')reasoning_effort='none'Testing
make format- passedmake lint- passedmake schema- updatedBackward Compatibility
✅ Fully backward compatible - existing applications work without changes.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.