fix(responses): generate Responses-compatible IDs in Chat Completions bridge - #27426
fix(responses): generate Responses-compatible IDs in Chat Completions bridge#27426Jwrede wants to merge 2 commits into
Conversation
[Infra] Promote Internal Staging to main
… bridge The Chat Completions -> Responses API bridge reused chatcmpl-* IDs for response and message output items. When bridged output from a non-OpenAI provider (e.g. Claude via LiteLLM) is later sent as input to an OpenAI Responses model, OpenAI rejects the request because message item IDs must start with msg_. Generate proper Responses-compatible IDs: - resp_<uuid> for the top-level ResponsesAPIResponse - msg_<uuid> for message output items - img_<uuid> for image generation output items Fixes BerriAI#27333
0b7293a to
6f9b893
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes a bug where the Chat Completions → Responses API bridge reused
Confidence Score: 5/5Safe to merge — the change is minimal, well-tested, and fixes a clear interoperability bug without touching auth, routing, or any critical request path. The three code-site changes are straightforward and consistent with what the streaming path already does. New regression tests are mock-only and directly target the failure scenario described in the issue. The existing test update is appropriate: the old exact-ID assertion (test_123_img_0) would always fail with random UUIDs, and replacing it with a prefix check is the correct way to validate the new contract. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/responses/litellm_completion_transformation/transformation.py | Replaces chatcmpl-* ID reuse with proper resp_/msg_/img_ UUID generation in the non-streaming Chat Completions → Responses bridge |
| tests/test_litellm/responses/litellm_completion_transformation/test_response_id_prefixes.py | New regression tests covering resp_/msg_ prefix enforcement and ID distinctness for bridged Responses output; pure unit tests using only mock data, no real network calls |
| tests/test_litellm/responses/litellm_completion_transformation/test_image_generation_output.py | Updates image ID assertions from exact chatcmpl-derived strings to img_* prefix checks, matching the new random-UUID generation behavior |
Reviews (1): Last reviewed commit: "fix(responses): generate Responses-compa..." | Re-trigger Greptile
|
🤖 litellm-agent: This PR was marked BLOCKED 7 days ago with no subsequent activity. Closing automatically. |
Relevant issues
Fixes #27333
Pre-Submission checklist
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
Changes
The Chat Completions -> Responses API bridge reuses
chatcmpl-*IDs from the underlying Chat Completion response as both the top-level response ID and the message output item ID. When bridged output from a non-OpenAI provider (e.g. Claude via LiteLLM) is later sent as input to an OpenAI Responses model, OpenAI rejects the request:This PR generates Responses-compatible IDs instead of reusing Chat Completions IDs:
resp_<uuid>for the top-levelResponsesAPIResponse.idmsg_<uuid>for message output items (GenericResponseOutputItem.id)img_<uuid>for image generation output items (OutputImageGenerationCall.id)This matches what the streaming path already does (in
streaming_iterator.py), which generatesresp_andmsg_prefixed IDs.Files changed
litellm/responses/litellm_completion_transformation/transformation.py-- generateresp_,msg_,img_prefixed UUIDs instead of reusingchat_completion_response.idtests/test_litellm/responses/litellm_completion_transformation/test_response_id_prefixes.py-- 4 regression tests verifying correct ID prefixes on bridged responsestests/test_litellm/responses/litellm_completion_transformation/test_image_generation_output.py-- update existing test to assertimg_prefix instead of the old{id}_img_{idx}format