claude code tools error

This commit is contained in:
Sakurasan
2026-08-19 03:46:39 +08:00
parent 3e7efb3c88
commit 30ab9e842c
4 changed files with 709 additions and 77 deletions
@@ -305,8 +305,11 @@ func responsesToChatResp(body []byte) ([]byte, error) {
msg["tool_calls"] = toolCalls
}
finish := "stop"
if string(rawJSON(m, "status")) == `"incomplete"` {
finish = "length"
switch {
case string(rawJSON(m, "status")) == `"incomplete"`:
finish = "length" // 截断优先,客户端可据此区分
case len(toolCalls) > 0:
finish = "tool_calls" // 有工具调用时映射 tool_calls,否则中转后 stop_reason 成 end_turn
}
var prompt, completion int64
if u := rawJSON(m, "usage"); u != nil {