diff --git a/.story_kit/work/1_upcoming/180_bug_web_ui_permissions_handling_unreliable.md b/.story_kit/work/1_upcoming/180_bug_web_ui_permissions_handling_unreliable.md index 1d72335..571c88e 100644 --- a/.story_kit/work/1_upcoming/180_bug_web_ui_permissions_handling_unreliable.md +++ b/.story_kit/work/1_upcoming/180_bug_web_ui_permissions_handling_unreliable.md @@ -9,7 +9,39 @@ name: "Web UI permissions handling unreliable" Permissions handling in the web UI chat has issues. This is a tracking bug to collect specific problems as they're encountered. Known issues: -1. **Batch tool calls failing**: When the agent fires many parallel Bash calls (e.g. 11 at once), the permission/hook validation system fails with cryptic errors (`invalid_union`, `Invalid input: expected "allow"`), cascading to cancel all sibling calls. Individual calls with the same commands work fine. Unclear if this is a Claude Code SDK limitation, a hook validation issue, or a web UI problem. +1. **Batch tool calls failing**: When the agent fires many parallel Bash calls (e.g. 11 at once), two problems compound: + - **Trigger**: The first call fails with an `invalid_union` permission/hook validation error. This may be a bug in how the permission hook response is parsed when many parallel requests hit it simultaneously. + - **Cascade**: All remaining sibling calls are cancelled with "Sibling tool call errored". This is a known Claude Code bug ([anthropics/claude-code#22264](https://github.com/anthropics/claude-code/issues/22264), 25 upvotes, still open). Claude Code uses an all-or-nothing batch model — if one parallel call fails, all siblings are killed. + + The cascade is an upstream issue we can't fix. But the **trigger** (the `invalid_union` error) may be something in our permission hook handling that we can investigate. + +## How to reproduce + +Ask the agent to check git status across all worktrees. It will attempt to run 11+ parallel Bash calls like: + +``` +git -C .story_kit/worktrees/163_story_foo status --porcelain +git -C .story_kit/worktrees/165_bug_bar status --porcelain +git -C .story_kit/worktrees/166_story_baz status --porcelain +... (11 total) +``` + +Each command individually works fine and matches the `Bash(git *)` permission rule. But when all 11 are fired in a single parallel batch, they all fail with: + +```json +{ + "code": "invalid_union", + "errors": [ + [{ "code": "invalid_value", "values": ["allow"], "path": ["behavior"], "message": "Invalid input: expected \"allow\"" }], + [{ "code": "invalid_value", "values": ["deny"], "path": ["behavior"], "message": "Invalid input: expected \"deny\"" }, + { "expected": "string", "code": "invalid_type", "path": ["message"], "message": "Invalid input: expected string, received undefined" }] + ] +} +``` + +The first call gets this error, and all remaining calls fail with `"Sibling tool call errored"`. + +Running the same commands in batches of 3 works fine. ## How to reproduce