Fix non-streaming parsing for backends that split tool_calls across choices#1336
Closed
agwblack wants to merge 1 commit intokarthink:masterfrom
Closed
Fix non-streaming parsing for backends that split tool_calls across choices#1336agwblack wants to merge 1 commit intokarthink:masterfrom
agwblack wants to merge 1 commit intokarthink:masterfrom
Conversation
…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.
Owner
|
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. |
Author
|
Thanks, sorry I missed that one. We can close this |
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.
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.