fix: trim whitespace from tool names to prevent invalid tool calls

Some models (e.g. kimi-k2.5) return tool names with leading spaces
like ' delegate_task', causing tool matching to fail.

Add .trim() in transformToolName() and defensive trim in claude-code-hooks.

Fixes #1568
This commit is contained in:
YeonGyu-Kim
2026-02-07 13:12:47 +09:00
parent 1c0b41aa65
commit eb5cc873ea
3 changed files with 161 additions and 5 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ export function createClaudeCodeHooksHook(
input: { tool: string; sessionID: string; callID: string },
output: { args: Record<string, unknown> }
): Promise<void> => {
if (input.tool === "todowrite" && typeof output.args.todos === "string") {
if (input.tool.trim() === "todowrite" && typeof output.args.todos === "string") {
let parsed: unknown
try {
parsed = JSON.parse(output.args.todos)