Skip to content

Fix non-streaming parsing for backends that split tool_calls across choices#1336

Closed
agwblack wants to merge 1 commit intokarthink:masterfrom
agwblack:fix/multi-choice-tool-calls
Closed

Fix non-streaming parsing for backends that split tool_calls across choices#1336
agwblack wants to merge 1 commit intokarthink:masterfrom
agwblack:fix/multi-choice-tool-calls

Conversation

@agwblack
Copy link
Copy Markdown

@agwblack agwblack commented Apr 8, 2026

Some OpenAI-compatible backends (e.g. GitHub Copilot) return non-streaming responses where text content and tool_calls are spread across separate choices entries rather than combined in a single choices[0].message.

gptel--parse-response for gptel-openai only examines choices[0], so it finds the text content but misses the tool_calls entirely. :tool-use is never set in info, and the response is treated as a plain text completion -- the tools never run.

This is particularly damaging for sub-agent (task) tool calls: the agent's introductory text is returned as the final result, and the caller sees an empty/useless response.

Fix: Collect tool_calls from all choices and merge them into a single injected prompt message. For standard backends where everything is in choices[0], behavior is unchanged.

…hoices

Some OpenAI-compatible backends (e.g. GitHub Copilot) return
non-streaming responses where text content and tool_calls are spread
across separate choices entries rather than combined in a single
choices[0].message.

gptel--parse-response for gptel-openai only examines choices[0], so it
finds the text content but misses the tool_calls entirely.  :tool-use
is never set in info, and the response is treated as a plain text
completion -- the tools never run.

This is particularly damaging for sub-agent (task) tool calls: the
agent's introductory text is returned as the final result, and the
caller sees an empty/useless response.

Fix: Collect tool_calls from all choices and merge them into a single
injected prompt message.  For standard backends where everything is in
choices[0], behavior is unchanged.
@karthink
Copy link
Copy Markdown
Owner

karthink commented Apr 8, 2026

Thanks for the PR. This looks like a duplicate of #1284, so please focus there instead. I will be closing this PR unless you think this isn't a duplicate.

@agwblack
Copy link
Copy Markdown
Author

agwblack commented Apr 8, 2026

Thanks, sorry I missed that one. We can close this

@agwblack agwblack closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants