Skip to content

Fix multi choices in OpenAI response with different types of content(…#81

Merged
ericc-ch merged 3 commits intoericc-ch:masterfrom
hedecai:claude-code
Aug 10, 2025
Merged

Fix multi choices in OpenAI response with different types of content(…#81
ericc-ch merged 3 commits intoericc-ch:masterfrom
hedecai:claude-code

Conversation

@hedecai
Copy link
Copy Markdown
Contributor

@hedecai hedecai commented Aug 8, 2025

…some with text content, some with tool calls), the translation only picked up the text content from the first choice and missing the tool calls from the seconed choice. The code was written by Copilot.

…some with text content, some with tool calls), the translation only picked up the text content from the first choice and missing the tool calls from the seconed choice. The code was written by Copilot.
Copilot AI review requested due to automatic review settings August 8, 2025 02:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in OpenAI response translation where only the first choice's content was being processed, causing tool calls from subsequent choices to be missed. The fix ensures all choices are processed and their content is properly merged.

Key Changes

  • Modified the translation logic to iterate through all choices instead of only processing the first one
  • Added logic to merge text blocks and tool use blocks from all choices
  • Implemented stop reason prioritization logic to handle multiple choices appropriately

Comment thread src/routes/messages/non-stream-translation.ts Outdated
Comment thread src/routes/messages/non-stream-translation.ts Outdated
hedecai and others added 2 commits August 8, 2025 10:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MrPeacockNLB
Copy link
Copy Markdown

This fixes timeout issues for me when using claude-code with copilot-api. Thanks!

@ericc-ch
Copy link
Copy Markdown
Owner

Ah well haven't had the chance to properly review this. I'll merge this once I'm home

Thanks!

@ericc-ch ericc-ch merged commit b4c9a07 into ericc-ch:master Aug 10, 2025
hao1939 pushed a commit to hao1939/copilot-api that referenced this pull request Nov 22, 2025
Fix multi choices in OpenAI response with different types of content(…
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.

4 participants