fix: #1876 LiteLLM extra_body forwarding#2900
Merged
seratch merged 2 commits intoopenai:mainfrom Apr 16, 2026
Merged
Conversation
Member
|
@yu2001-s Thanks for sending this. I've confirmed this works way better than the current implementation. Once all the things on your side are ready, mark this PR as ready for review. |
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
ModelSettings.extra_bodyvia LiteLLM'sextra_bodykwarg instead of flattening its keys into top-levellitellm.acompletion()kwargsreasoning_effortpromotion to the top-level LiteLLM parameter while removing the duplicated key from the forwardedextra_bodycopyextra_body, nested metadata, and reasoning-effort precedence behaviorWhy
LiteLLM already supports
extra_bodyand merges it into the upstream OpenAI-compatible request body. FlatteningModelSettings.extra_bodyin the SDK changes the request shape and can break proxy-specific fields like nested metadata, session tags, and cached-content hints.Validation
uv run pytest -q tests/models/test_litellm_extra_body.pyuv run ruff check src/agents/extensions/models/litellm_model.py tests/models/test_litellm_extra_body.pyuv run mypy src/agents/extensions/models/litellm_model.py tests/models/test_litellm_extra_body.pymake formatmake lintmake typecheckcurrently fails on an unrelated mypy error intests/test_run_step_execution.py:1231(Module has no attribute "eager_task_factory") outside this diffFixes #1876