Repository navigation
fix(responses): join function_call_output text parts with a newline in the chat-completions bridge - #45338
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
fix(responses): join function_call_output text parts with a newline in the chat-completions bridge#45338devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…n the chat-completions bridge
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
/v1/responsesthrough the chat-completions bridge glued a tool result's text parts togetherParis: 22 degreesplusclear skiesreached the model asParis: 22 degreesclear skiesHow it solves it:
function_call_output'sinput_textparts with a newline, like fix(ollama): one stream id, 400 on non-text tool content, separated tool results, no empty message item #45177 did inside theollama/prompt builderUser Flow
Before: a developer whose agent app runs on the OpenAI Agents SDK against a model served through chat completions gets a two-part tool result read as one word
"model": "sonnet", aget_weathertool, and "What is the weather in Paris?"; the model answers with afunction_callfunction_call_outputwhoseoutputis[{"type": "input_text", "text": "Paris: 22 degrees"}, {"type": "input_text", "text": "clear skies"}]Paris: 22 degreesclear skies, so an agent told to repeat the result printsParis: 22 degreesclear skies;"model": "gemini"does the sameAfter: the same tool result reaches the model as two lines
"model": "sonnet", aget_weathertool, and "What is the weather in Paris?"; the model answers with afunction_callfunction_call_outputwhoseoutputis[{"type": "input_text", "text": "Paris: 22 degrees"}, {"type": "input_text", "text": "clear skies"}]Paris: 22 degreesandclear skieson separate lines, so the agent prints them on two lines;"model": "gemini"does the samePre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@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
Last updated: 574b96a. QA and /live-pr-risk ran on 4264079, the last commit with a product diff
Setup, shared by both legs: a proxy booted from a worktree at the named commit with
--num_workers 2 --detailed_debug,drop_params: true, and two deployments,sonnet=anthropic/claude-sonnet-5-5andgemini=gemini/gemini-3.8-flash. The before leg ran on port 26357, the after leg on port 41667, same config and the same.env. The client is the OpenAI Agents SDK 0.23.1 (openai 3.26.1) over the Responses API, pointed at the proxy. Itsget_weathertool returns[ToolOutputText("Paris: 22 degrees"), ToolOutputText("clear skies")], which the SDK sends as afunction_call_outputwhoseoutputis twoinput_textparts, and the agent's instructions are to repeat the tool output exactly, inside a code block, so what the agent prints is what the model readBefore (7c7b0ea)
Anthropic, a provider whose tool result takes a list
python agent_client.py http://127.0.0.1:26357/v1 $KEY sonnet"output": [{"type": "input_text", "text": "Paris: 22 degrees"}, {"type": "input_text", "text": "clear skies"}]on thefunction_call_outputGemini, a provider whose tool result is one string
python agent_client.py http://127.0.0.1:26357/v1 $KEY geminifunction_call_outputWhat each upstream received, from the proxy's
POST Request Sent from LiteLLMdebug line: Anthropic got{'type': 'tool_result', 'tool_use_id': 'toolu_01FLAxzSfN6PxyJxrhHdYy3v', 'content': 'Paris: 22 degreesclear skies'}and Gemini got'function_response': {'name': 'get_weather', 'response': {'content': 'Paris: 22 degreesclear skies'}, 'id': 'call_134314'}After (4264079)
Anthropic, a provider whose tool result takes a list
python agent_client.py http://127.0.0.1:41667/v1 $KEY sonnet"output": [{"type": "input_text", "text": "Paris: 22 degrees"}, {"type": "input_text", "text": "clear skies"}]on thefunction_call_outputGemini, a provider whose tool result is one string
python agent_client.py http://127.0.0.1:41667/v1 $KEY geminifunction_call_outputWhat each upstream received, from the same debug line: Anthropic got
{'type': 'tool_result', 'tool_use_id': 'toolu_01VAUtNW4R56xZhymCeUojKb', 'content': 'Paris: 22 degrees\nclear skies'}and Gemini got'function_response': {'name': 'get_weather', 'response': {'content': 'Paris: 22 degrees\nclear skies'}, 'id': 'call_250842'}Observations from the run:
__thought__<signature>suffix on the wire; unrelated, unchangedType
🐛 Bug Fix
Caveats (if any)
Low
input_textpart and a plain stringoutputare unchanged; only lists of two or more text parts change. A client that splits one string across severalinput_textparts now gets a newline at each seam. No known client does that (the Agents SDK sends one part perToolOutputText), and no rule can tell a seam from two results, so this stays as isFinal Attestation