Skip to content

fix: #1876 LiteLLM extra_body forwarding#2900

Merged
seratch merged 2 commits intoopenai:mainfrom
yu2001-s:codex/litellm-extra-body
Apr 16, 2026
Merged

fix: #1876 LiteLLM extra_body forwarding#2900
seratch merged 2 commits intoopenai:mainfrom
yu2001-s:codex/litellm-extra-body

Conversation

@yu2001-s
Copy link
Copy Markdown
Contributor

Summary

  • pass ModelSettings.extra_body via LiteLLM's extra_body kwarg instead of flattening its keys into top-level litellm.acompletion() kwargs
  • keep reasoning_effort promotion to the top-level LiteLLM parameter while removing the duplicated key from the forwarded extra_body copy
  • add regression tests for nested extra_body, nested metadata, and reasoning-effort precedence behavior

Why

LiteLLM already supports extra_body and merges it into the upstream OpenAI-compatible request body. Flattening ModelSettings.extra_body in 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.py
  • uv run ruff check src/agents/extensions/models/litellm_model.py tests/models/test_litellm_extra_body.py
  • uv run mypy src/agents/extensions/models/litellm_model.py tests/models/test_litellm_extra_body.py
  • make format
  • make lint
  • make typecheck currently fails on an unrelated mypy error in tests/test_run_step_execution.py:1231 (Module has no attribute "eager_task_factory") outside this diff

Fixes #1876

@seratch seratch changed the title [codex] Fix LiteLLM extra_body forwarding fix: LiteLLM extra_body forwarding Apr 15, 2026
@seratch seratch added this to the 0.14.x milestone Apr 15, 2026
@seratch
Copy link
Copy Markdown
Member

seratch commented Apr 15, 2026

@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.

@yu2001-s yu2001-s marked this pull request as ready for review April 16, 2026 02:55
@github-actions github-actions bot added the bug Something isn't working label Apr 16, 2026
@seratch seratch changed the title fix: LiteLLM extra_body forwarding fix: #1876 LiteLLM extra_body forwarding Apr 16, 2026
@seratch seratch enabled auto-merge (squash) April 16, 2026 06:32
@seratch seratch merged commit 4f3c8a5 into openai:main Apr 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata/Sessions/Tags does not show up when using Open AI Agents SDK with LiteLLM

2 participants