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

@bbbuggbbbugg commented Jun 6, 2026

Copy link
Copy Markdown
Member

修改

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

CopilotAI 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 threadsrc/core/FormatConverter.js
Comment threadsrc/core/FormatConverter.js Outdated

CopilotAI 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 threadsrc/core/FormatConverter.js

CopilotAI 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 mainJun 6, 2026
1 check passed
@bbbuggbbbugg 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 BugSomething 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

@bbbugg