This repository was archived by the owner on May 13, 2026. It is now read-only.
Repository navigation
fix(claude): 修复工具调用兼容与解析回退 - #55
Merged
Merged
Conversation
- Claude 工具定义兼容 input_schema 与 function.parameters - tool_calls 解析增加 thinking 回退与大小写无关工具名匹配 - 补充 claude/util 相关回归测试
|
@BigUncle is attempting to deploy a commit to the cjack's projects Team on Vercel. A member of the Team first needs to authorize it. |
Closed
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 255feb2e65
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- only parse tool_calls from thinking when finalText is empty - apply the same guard in stream runtime finalizer - add regression tests for non-stream and stream paths
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CJackHwang
approved these changes
Feb 27, 2026
This branch was successfully deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Claude 工具定义兼容 input_schema 与 function.parameters
tool_calls 解析增加 thinking 回退与大小写无关工具名匹配
补充 claude/util 相关回归测试
fix(claude): improve tool-call compatibility and parsing fallback for Anthropic messages
PR 内容
背景
在
POST /anthropic/v1/messages场景下,存在“返回普通文本而非tool_use”的问题,主要表现为:tools[].function.parameters请求兼容性不足。{"tool_calls":...}输出在 thinking 通道时,工具调用可能漏检。Bash/bash)会导致策略过滤误拒绝。本次改动
支持从以下路径提取工具元信息(name/description/schema):
tools[].input_schema(Claude 原生)tools[].parameters(扁平)tools[].function.parameters(OpenAI 风格)在未从
finalText命中tool_calls时,回退解析finalThinking:internal/format/claude/render.gointernal/adapter/claude/stream_runtime_finalize.gotool_calls过滤改为大小写不敏感匹配,并回写为声明时 canonical 工具名,减少Bash/bash场景下的误拒绝。影响范围
internal/adapter/claude/handler_utils.gointernal/adapter/claude/stream_runtime_finalize.gointernal/format/claude/render.gointernal/util/toolcalls_parse.gointernal/adapter/claude/handler_util_test.gointernal/adapter/claude/handler_stream_test.gointernal/format/claude/render_test.go(新增)internal/util/toolcalls_test.go验证
已完成以下回归并通过:
tools[].input_schema:返回tool_use,stop_reason=tool_usetools[].function.parameters:返回tool_use,stop_reason=tool_useBash/bash大小写场景:返回tool_use,无原始{"tool_calls":...}文本泄漏测试命令:
GOCACHE=/tmp/go-build go test ./internal/util ./internal/adapter/claude ./internal/format/claude风险与兼容性