Skip to content

fix(proxy): preserve reasoning_content for tool calls#2367

Open
codeasier wants to merge 2 commits intofarion1231:mainfrom
codeasier:fix/reasoning-content-2365
Open

fix(proxy): preserve reasoning_content for tool calls#2367
codeasier wants to merge 2 commits intofarion1231:mainfrom
codeasier:fix/reasoning-content-2365

Conversation

@codeasier
Copy link
Copy Markdown

@codeasier codeasier commented Apr 26, 2026

Summary / 概述

Preserve assistant thinking blocks as OpenAI-compatible reasoning_content when converting Anthropic messages with tool_use into Chat Completions format. Moonshot AI rejects assistant tool call history when thinking is enabled but reasoning_content is missing, so this also injects a small fallback for tool call messages without thinking content.

Related Issue / 关联 Issue

Fixes #2365

Screenshots / 截图

Before / 修改前
image
After / 修改后
image
image

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查 (not run; Rust-only change)
  • pnpm format:check passes / 通过代码格式检查 (not run; cargo fmt --check passed)
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件 (no user-facing text changed)

Verification / 验证

  • cargo fmt --check
  • cargo clippy --lib -- -D warnings
  • cargo test --lib transform

Copy link
Copy Markdown
Owner

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c288377e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/proxy/providers/transform.rs Outdated
@codeasier
Copy link
Copy Markdown
Author

Addressed the review feedback in 160b587. The converter now only emits assistant messages when text/image content or tool_calls exist, so thinking-only blocks continue to be skipped instead of becoming empty assistant turns. Added test_anthropic_to_openai_skips_thinking_only_message. Verified with cargo fmt --check, cargo clippy --lib -- -D warnings, and cargo test --lib transform.

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.

🐛 Missing reasoning_content causes Moonshot AI 400 error on tool calls

2 participants