Skip to content

fix: improve Claude message conversion#201

Merged
bbbugg merged 4 commits into
mainfrom
fix/claude
Jun 6, 2026
Merged

fix: improve Claude message conversion#201
bbbugg merged 4 commits into
mainfrom
fix/claude

Conversation

@bbbugg

@bbbugg bbbugg commented Jun 6, 2026

Copy link
Copy Markdown
Member

修改

@bbbugg bbbugg changed the title [codex] fix Claude to Gemini message conversion fix: 修复 Claude 消息转换 Jun 6, 2026
@bbbugg bbbugg changed the title fix: 修复 Claude 消息转换 fix: improve Claude message conversion Jun 6, 2026
@bbbugg bbbugg marked this pull request as ready for review June 6, 2026 16:55
@bbbugg bbbugg requested a review from Copilot June 6, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Claude→Gemini request conversion in FormatConverter.translateClaudeToGoogle() to better align with Gemini’s contents/systemInstruction expectations and to fix invalid payloads observed with Claude Code tool-calling conversations (Issue #200).

Changes:

  • Aggregate messages[].role === "system" content (in addition to top-level claudeBody.system) into Gemini systemInstruction, and skip those messages during contents conversion.
  • Normalize Claude tool_result.content so Gemini functionResponse.response is always an object (including when the source is a JSON array).
  • Avoid splitting tool_result + same-message text/image into separate user entries by buffering non-tool_result blocks into pendingToolParts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/FormatConverter.js
Comment thread src/core/FormatConverter.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/core/FormatConverter.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@bbbugg bbbugg merged commit 0e4db44 into main Jun 6, 2026
1 check passed
@bbbugg bbbugg added the 🐛 Bug Something isn't working label Jun 9, 2026
@bbbugg bbbugg deleted the fix/claude branch June 10, 2026 15:38
@github-actions

Copy link
Copy Markdown

🎉 此 PR 的修改已在版本 v1.3.2 中发布。
🎉 The changes in this PR have been released in version v1.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Claude /v1/messages 转换后出现连续 user 角色,导致 Gemini API 返回 400 INVALID_ARGUMENT

2 participants