fix(responses): forward client headers on response management routes - #35735
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThe PR consistently forwards configured client headers through the Responses API management routes while preserving case-insensitive precedence for explicit
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/responses/main.py | Centralizes forwarded-header merging and applies the effective headers consistently to all Responses API management provider calls. |
| litellm/responses/utils.py | Broadens header inputs to mappings and normalizes merge results into dictionaries while retaining case-insensitive explicit-header precedence. |
| tests/test_litellm/responses/test_responses_api_request_body.py | Adds mocked coverage for forwarding and precedence across retrieval, deletion, cancellation, input-item listing, and compaction. |
| basedpyright-code-budget.json | Reduces unknown-member and unknown-variable type budgets to match the improved typing. |
| type-discipline-budget.json | Lowers the LIT001 budget by one to reflect the type-discipline improvement. |
Reviews (2): Last reviewed commit: "refactor(responses): keep merged forward..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mateo-berri
left a comment
There was a problem hiding this comment.
Your parametrized route matrix covers only get, delete, cancel, and list-input-items. Please also add compact
Also, add before=fail/after=succeed no mock real proxy live e2e proof
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Done in 364deca: compact is in the route matrix now, and the description has a live before/after run for cancel and compact against real OpenAI (before, both reach the provider with no |
…al_staging Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Merged staging and kept the merged headers in a Final local instead of rebinding the param. @greptileai |
TLDR
Problem this solves:
/v1/responsesmanagement routes drop forwarded client headersHow it solves it:
headerskwargextra_headersstill wins, case-insensitivelyRelevant issues
Follow-up to #34531, requested in review
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Live proxy with
general_settings.forward_client_headers_to_llm_api: trueandgpt-5.6-sol(real OpenAI calls);api_basepoints at a tiny transparent relay in front ofhttps://api.openai.comthat logs thex-my-*headers the provider actually receives, since the header is invisible in the response bodyBefore, at f60e99c (litellm_internal_staging, which already has #34531); only the create call carries the header
After, at e17947b
Cancel and compact need a background response, so they get their own run
Before, at f60e99c
After, at 364deca
Type
🐛 Bug Fix
Changes
#34531 mapped the proxy's forwarded
headerskwarg ontoextra_headersonly inresponses(), so every other responses route still dropped it. The merge is now a one-liner helper (_merge_forwarded_client_headers) applied inget_responses,delete_responses,cancel_responses,list_input_itemsandcompact_responsesas well, all reusingResponsesAPIRequestUtils.merge_client_forwarded_headers, so precedence rules stay identical everywhereTests parametrize over all five routes, patch the matching httpx verb and assert both that the forwarded header reaches the provider request and that an explicit
extra_headersvalue still wins over a differently cased client headerFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/a1233d20018d4279b3a1b69094ccd33b