Skip to content

Commit 0c41256

Browse files
chore: 删除测试文件 test_tool_result_fix.js
1 parent 17f7a39 commit 0c41256

3 files changed

Lines changed: 8 additions & 122 deletions

File tree

deno-proxy/src/anthropic_to_openai.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ function normalizeBlocks(content: string | ClaudeContentBlock[], triggerSignal?:
3535
return `${THINKING_START_TAG}${block.thinking}${THINKING_END_TAG}`;
3636
}
3737
if (block.type === "tool_result") {
38-
return `<tool_result id="${block.tool_use_id}">${block.content ?? ""}</tool_result>`;
38+
const contentStr = typeof block.content === "string"
39+
? block.content
40+
: JSON.stringify(block.content ?? "");
41+
return `<tool_result id="${block.tool_use_id}">${contentStr}</tool_result>`;
3942
}
4043
if (block.type === "tool_use") {
4144
// 只有从 tool_use 转换的 <invoke> 标签才会带触发信号

deno-proxy/src/token_counter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export function extractTextFromMessages(messages: ClaudeMessage[]): string {
4444
return `<invoke name="${block.name}">${JSON.stringify(block.input)}</invoke>`;
4545
}
4646
if (block.type === "tool_result") {
47-
return `<tool_result>${block.content}</tool_result>`;
47+
const contentStr = typeof block.content === "string"
48+
? block.content
49+
: JSON.stringify(block.content ?? "");
50+
return `<tool_result>${contentStr}</tool_result>`;
4851
}
4952
return "";
5053
})

test_tool_result_fix.js

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)