litellm/litellm/responses
devin-ai-integration[bot] c19d49d919
fix(responses): keep provider response headers in streaming logging callbacks (#38131)
* fix(responses): keep provider response headers in streaming logging callbacks

The responses streaming iterator captures the provider's HTTP response headers into
its own _hidden_params, but never puts them on the completed response, and the
model_validate(model_dump()) copy made for logging drops pydantic private attributes.
Success callbacks and StandardLoggingPayload.hidden_params.additional_headers therefore
saw an empty dict for streaming /v1/responses, so Azure's apim-request-id was unreadable
from the callback payload.

Restore the headers on the nested response of the logging copy, preferring any the
provider transform already set (the fake_stream path) and falling back to the ones the
iterator captured from the stream. Skipped when the copy fell back to the original event,
so a serialization failure never leaves logging-only state on the caller's object.

* fix: satisfy LIT002 mutable-collection gate in header restore

---------

Co-authored-by: Yucheng Zhu <yucheng@berri.ai>
2026-09-02 17:40:13 -07:00
..
file_search refactor(repositories): type prisma table access with one generic protocol 2026-08-25 12:14:17 +00:00
litellm_completion_transformation Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_responses_guardrail_namespace_tools 2026-09-02 16:29:34 -07:00
mcp refactor(types): replace Any with precise types across 73 modules 2026-09-01 11:05:02 +00:00
main.py feat(spend): report prompt caching savings as total and gateway-attributed (#38134) 2026-08-28 00:19:06 -07:00
sse_output_recovery.py refactor(repositories): type prisma table access with one generic protocol 2026-08-25 12:14:17 +00:00
streaming_iterator.py fix(responses): keep provider response headers in streaming logging callbacks (#38131) 2026-09-02 17:40:13 -07:00
utils.py fix(prompts): apply prompt templates before routing on /v1/responses and honor ignore_prompt_manager_model 2026-08-26 14:12:28 -07:00