litellm/tests/test_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
..
litellm_completion_transformation fix(responses): keep namespace tools intact when a guardrail returns them unchanged 2026-09-02 11:32:04 -07:00
mcp Merge pull request #36978 from Scott-Wilson-ZocDoc/fix/mcp-guardrail-usage-monitor 2026-08-17 13:18:03 -07:00
test_custom_tool_call.py fix(responses): normalize tool call id shapes across the anthropic bridge and openai replay 2026-09-01 11:12:24 -07:00
test_metadata_codex_callback.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_no_duplicate_spend_logs.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_null_test_fix.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_responses_api_bridge_flag.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_responses_api_request_body.py fix(responses): let cache-control injection reach the system prompt from instructions (#38120) 2026-08-26 16:43:26 -07:00
test_responses_prompt_management.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_dotprompt_model_swap 2026-08-26 17:36:01 -07:00
test_responses_router_cooldown.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_responses_streaming_iterator.py fix(responses): stop scheduling sync success_handler concurrently with async_success_handler (#32239) 2026-07-07 09:13:50 -07:00
test_responses_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
test_responses_websocket_all_providers.py test: require a match= on broad pytest.raises, and drop duplicate parametrize cases (#37769) 2026-08-20 20:24:49 -07:00
test_rust_bridge_websocket.py Merge pull request #39334 from BerriAI/litellm_rust_opt_in_configuration 2026-09-02 16:26:36 -07:00
test_sse_output_recovery.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
test_streaming_iterator.py fix(responses): keep provider response headers in streaming logging callbacks (#38131) 2026-09-02 17:40:13 -07:00
test_streaming_iterator_error_events.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_text_format_conversion.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00