Skip to content

Add reasoning parameter handling to completion extras transformation #13695

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oabdellatif
Copy link

Title

Add reasoning parameter handling to completion extras transformation

Relevant issues

N/A

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

Enhanced /chat/completionslitellm.responses() transformation:

  • Added _handle_reasoning_parameters() method to LiteLLMResponsesTransformationHandler
  • Automatic parameter promotion from extra_body.reasoning_effort to top-level
  • Default reasoning_effort="medium" for reasoning-capable models when not provided
  • Auto-routing for reasoning models to Responses API in main.py

Key benefits:

  • Reasoning summaries enabled by default (no manual reasoning_effort required)
  • Seamless integration with tools like Aider
  • Backward compatible with explicit parameters
  • Clean separation of routing vs transformation logic
Screenshot 2025-08-17 190814 Screenshot 2025-08-17 190831

- Add _handle_reasoning_parameters() method to LiteLLMResponsesTransformationHandler:
  * Promotes reasoning_effort from extra_body to top-level parameter
  * Sets default reasoning_effort="medium" for reasoning-capable models
  * Uses supports_reasoning() to detect reasoning-capable models
- Enhance transform_request() to call reasoning parameter handler
- Add auto-routing logic in main.py for reasoning-capable models
- Add comprehensive test suite for reasoning routing and transformation
- Enable reasoning summaries by default for reasoning models
- Rename test_gpt5_reasoning_routing.py -> test_reasoning_routing.py
- Move from tests/ to tests/llm_translation/ for better organization
- Update class names to be more descriptive:
  * TestGPT5ReasoningRouting -> TestReasoningRouting
  * TestTransformationLayerReasoningHandling -> TestReasoningParameterTransformation
- Keep all test functionality intact, just better organized
Copy link

vercel bot commented Aug 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Aug 17, 2025 11:13pm

@krrishdholakia
Copy link
Contributor

hi @oabdellatif can you help me understand - what is the issue you are trying to solve here?

@oabdellatif
Copy link
Author

Hi @krrishdholakia, the main goal is to enable reasoning summaries by default for OpenAI models through tools like Aider. There’s no way to configure this currently:

  1. Setting “mode”: “responses” in .aider.model.metadata.json doesn’t route to the Responses API
  2. Prefixing the model with responses/ works, but the completion to responses bridge doesn’t check extra_body for reasoning_effort so summaries still aren’t shown

The rationale is that reasoning-capable models should show reasoning summaries by default, and the auto-routing is one way to accomplish that. I can create an issue for further discussion.

@oabdellatif
Copy link
Author

Created #13780 for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants