Crash: toolUseContext.getAppState is not a function when subagent triggers a Bash permission prompt

Resolved 💬 4 comments Opened Apr 17, 2026 by mkulina Closed Apr 18, 2026

Summary

Claude Code crashes with H.toolUseContext.getAppState is not a function when a subagent requests permission to run a Bash command and the parent session goes to render the permission prompt. The prompt never appears — the CLI errors out.

Environment

  • Claude Code: 2.1.112
  • gh: 2.89.0
  • Platform: macOS (Darwin 25.4.0)
  • Shell: zsh
  • Model: Claude Opus 4.7 (1M context) — model ID claude-opus-4-7[1m]
  • Bun-compiled CLI (/$bunfs/root/src/entrypoints/cli.js)

Reproduction

  1. Dispatch a subagent (in my case, @bug-hunter) via the Agent tool.
  2. Have the subagent run a Bash command that is not already allow-listed in settings, so it must ask for permission.
  3. Parent session attempts to render the permission prompt.
  4. Crash — prompt never shows.

The command that triggered it in my session:

git show origin/main:app/Http/Controllers/Monitor/TweetMonitorController.php 2>/dev/null | sed -n '/function submitReview/,/^    }/p' | head -80

Not command-specific — any Bash command from a subagent that needs a permission prompt reproduces it.

Stack Trace

ERROR  H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()',
        'H.toolUseContext.getAppState' is undefined)

/$bunfs/root/src/entrypoints/cli.js:8231:15642

- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)
- qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)

Likely Cause

The failing line is inside the hook that fires to log tengu_tool_use_show_permission_request when a permission prompt is about to render:

// cli.js ~line 8231
let O = H.toolUseContext.getAppState().toolPermissionContext.mode;
Q("tengu_tool_use_show_permission_request", {
  messageID: H.assistantMessage.message.id,
  toolName: J7(H.tool.name),
  isMcp: H.tool.isMcp ?? !1,
  decisionReasonType: H.permissionResult.decisionReason?.type,
  sandboxEnabled: G8.isSandboxingEnabled(),
  permissionMode: O
});

When the permission request originates from a subagent, the toolUseContext forwarded through that code path does not carry a getAppState function, so the .getAppState() call throws before the prompt can render. A defensive typeof H.toolUseContext.getAppState === 'function' guard, or ensuring the subagent → parent permission-prompt bridge always forwards a full context with getAppState, would fix it.

Impact

  • Any time a subagent requests permission for Bash (or presumably any tool), the CLI crashes instead of showing the prompt.
  • Workaround: pre-approve the exact command patterns the subagent uses in .claude/settings.json, so the prompt never fires. That isn't a real fix — the underlying context-forwarding bug remains.

Related

Uses the Agent tool with subagent types that autonomously issue Bash tool calls (e.g. custom code-reviewer / bug-hunter agents). Reproduces with the default Agent tool path.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗