Repository navigation
Conversation
Merging this PR will not alter performance1 warning
Comparing Footnotes |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryFixes the silent drop of
Confidence Score: 5/5The change is narrowly scoped to the Responses API input transformation path and does not affect any other code paths. The fix is well-contained: a single dispatch guard and a new static helper, both mirroring the patterns of the existing function-call transformer. The previously-flagged index offset bug is resolved. Tests are mock-only, cover the exact regression scenario and a non-regression guard for text-only messages, and introduce no network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/responses/litellm_completion_transformation/transformation.py | Adds mixed-content assistant message detection in the dispatch path, routing to a new helper that correctly splits function_call parts into tool_calls and text parts into content. The previously-flagged index issue is resolved. |
| tests/test_litellm/responses/litellm_completion_transformation/test_responses_mixed_content_function_call.py | New mock-only regression tests covering: mixed content lifts function_call to tool_calls, function_call_output pairs correctly, and text-only assistant messages are unaffected. |
Reviews (3): Last reviewed commit: "fix(responses): index tool_calls by tool..." | Re-trigger Greptile
|
@hclsys — could you add a screenshot or short video showing the responses API correctly lifting |
|
@krrish-berri-2 here's the before/after exercised directly against the conversion function: from litellm.responses.litellm_completion_transformation.transformation import LiteLLMCompletionResponsesConfig
input_items = [
{"role": "assistant", "content": [
{"type": "text", "text": "ok"},
{"type": "function_call", "id": "call_good", "name": "test", "arguments": "{}"},
]},
{"type": "function_call_output", "call_id": "call_good", "output": "result"},
{"role": "user", "content": [{"type": "input_text", "text": "continue"}]},
]
msgs = LiteLLMCompletionResponsesConfig._transform_response_input_param_to_chat_completion_message(input=input_items)
for m in msgs: print(m.get("role"), "tool_calls=", m.get("tool_calls"), "tool_call_id=", m.get("tool_call_id"))unpatched main: this PR: tool_call_id |
|
@greptileai pushed a fix for the tool_call index — re-review please |
|
p2 from greptile was addressed in 11c14af — |
|
@krrish-berri-2 same env limit as #29501 — can't spin up the proxy from here, but the regression tests exercise the exact mixed-content→tool_calls lift scenario: CI is fully green now. ready for another look. |
11c14af to
573b361
Compare
573b361 to
c7a4cb1
Compare
|
rebased onto internal_staging and squashed to one commit. reconciled with the |
22dd0ae to
67019f6
Compare
…ol_calls A Responses API assistant message whose content list mixes text/output_text parts with function_call parts was dropped on the floor when transformed to a Chat Completion message. Lift the function_call parts into tool_calls (indexed by tool-call position) while keeping the text content, so the round-trip preserves both. Adds a focused transform + regression tests.
67019f6 to
b220a78
Compare
|
rebased onto main. The responses transformation was refactored since my last push, so I redid the branch on the new code: same fix (function_call parts lifted out of an assistant |
Fixes #28978.
what
Responses input shape
assistant.content = [{text}, {function_call}]was dropping the function_call. The matchingfunction_call_outputthen orphaned and the conversation died onMissing corresponding tool call for tool response message.why
_transform_responses_api_input_item_to_chat_completion_messageonly dispatches by the top-leveltype. Mixed-content assistant items haverole=assistant(no top-leveltype=function_call), so they fell into the plain-content path and the nested function_call part was thrown away.fix
In the plain path, detect
role==assistant+contentis a list containing anytype=="function_call"part, and route to a new helper_transform_responses_api_mixed_assistant_content_to_chat_completion_messagethat splits the list:content(via the existing content transformer)tool_callsemits ONE assistant message carrying both. The text-only and top-level-function_call paths are untouched.
proof
sibling tests in
tests/test_litellm/responses/litellm_completion_transformation/(68 pre-existing) still pass.