sdk-adapter canUseTool returns no updatedInput — every tool call fires ZodError #881
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#881
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Every tool call in every agent dispatch produces a
tool_resultcontaining:The SDK falls back to allow-on-schema-fail, so the tool actually runs. But the agent reads the error in its own conversation context, misinterprets "permission request failed" as a real denial, and goes into recovery loops — observed instances include code-lead trying to invoke
update-config/fewer-permission-prompts/ harness skills to "fix" the permission system, then aborting with a confused dispatch summary.Confirmed across at least 5 distinct code-lead sessions (issues #571, #213, #209, #591, #671). Likely affects every agent on every dispatch since the permission callback was wired up.
Root cause
apps/server/src/infrastructure/agent/sdk-adapter.ts:570-574:The SDK's permission-callback schema requires
updatedInput: Record<string, unknown>on the allow branch — it is the (possibly-modified) input the SDK passes to the tool. We omit it entirely. The Zod union fails on the first member (allow with updatedInput) and reports the error.Acceptance criteria
apps/server/src/infrastructure/agent/sdk-adapter.ts:570-574returns{ behavior: "allow", updatedInput: input }on the allow branch.sdk-adapter.test.ts: stubcanUseTool, invoke a tool, assert no Zod error appears in anytool_resultevent."permission request failed"— must be empty.tool_useevent forSkill,update-config, orfewer-permission-prompts(those names should never appear in agent reasoning if the underlying permission noise is gone).Out of scope
extraKnownMarketplacesin agent settings.json mirrors the whole Anthropic marketplace into the agent env-dir, which leaksupdate-config/fewer-permission-promptsetc into theskill_listingsystem reminder; that is a different bug).References
apps/server/src/infrastructure/agent/sdk-adapter.ts:570-574.@anthropic-ai/claude-agent-sdk—canUseToolreturn shape (allow branch carriesupdatedInput).~/.config/claude-hooks/agent-env/code-lead/projects/-state-worktrees-boss-default-charles--claude-hooks--boss-2F671/9bacbc0f-12ad-428c-b06f-629ea0a6c211.jsonl(and 4 siblings).