Skip to content

Claude agent host: a client tool hangs forever outside Bypass mode when the workbench's confirmation arrives before the CLI asks for permission #350630

Todo

Agent suggestions

Public preview

Description

@GNeras

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.148.0 (661626d), x64, local window
  • OS Version: Ubuntu 25.10 (Linux 6.17.0-41-generic)
  • Claude agent host (Agents window and the chat's Claude tab), bundled SDK 0.3.304 (Claude Code 2.1.304), claude-opus-5-5
  • Default permission mode (anything other than Bypass Permissions)

Disclosure: I investigated this with an AI coding agent (Claude Code). It attached to the agent host's inspector and recorded breakpoints on requestPermission, respondToPermissionRequest and completeClientToolCall; times from the AHP JSONL log are converted to local time. No VS Code files were modified. Line numbers refer to the 1.148.0 sources.

Summary

With any permission mode other than Bypass, a Claude turn that calls a client tool (problems, usages, the integrated browser's readPage, screenshotPage…) together with a slower tool in the same message hangs forever. The chat shows the client tool as done and then stays on "This is taking a little longer than usual" until the turn is stopped.

The workbench confirms the client tool as soon as the call is streamed (chat/toolCallReady confirmed=not-needed → chat/toolCallConfirmed approved=true, host_policy). The Claude CLI asks for permission (canUseTool → ClaudeAgentSession.requestPermission) only later, when it gets to that tool. The early answer finds nothing parked, so it is dropped, and the later request waits for an answer that has already been given.

This is a separate drop point from #322990 (client tool results delivered with respond instead of respondOrBuffer). Fixing #322990 alone doesn't help here: in the capture below my workaround for #322990 was already active, so the result itself was kept, and the turn still hung at the permission gate, before the tool handler was ever reached.

Repro (deterministic)

  1. Select the default permission mode in a Claude chat.
  2. Send, in one message: "In parallel, in a single message: run sleep 8 && echo done in the terminal, and call the problems tool."
  3. The problems call completes in the chat right away, the terminal command finishes 8 s later, and the turn never ends.

In Bypass mode the same prompt hangs too, but because of #322990: the CLI doesn't ask for permission there.

Capture (Nov 26)

Time Where Event
16:15:34.801 AHP chat/toolCallStart problems (toolu_01C8eW…, contributor client)
16:15:34.874 AHP chat/toolCallReady confirmed: "not-needed"
16:15:34.884 AHP (c2s) chat/toolCallConfirmed approved: true, permissionDecisionSource: host_policy
16:15:35.327 → .685 breakpoint ClaudeAgent.respondToPermissionRequest offers the answer to all 3 live sessions, including the right one: pending: false in each, so it's dropped
16:15:35.402 AHP (c2s) chat/toolCallComplete success: true ("No errors found.")
16:15:42.991 agenthost.log The terminal command completes
16:15:43.508 breakpoint ClaudeAgentSession.requestPermission for toolu_01C8eW… (mcp__client__problems): parks a new deferred and fires pending_confirmation. No prompt appears in the chat (the call is already complete there)
16:16:42.431 breakpoint I stopped the turn; the abort path answers the parked request with approved: false (pending: true)

Root cause

  • ClaudeAgentSession.respondToPermissionRequest resolves with respond and returns false when nothing is parked (claudeAgentSession.ts:1380-1382). ClaudeAgent.respondToPermissionRequest then tries every live session and silently gives up (claudeAgent.ts:2433-2441).
  • requestPermission uses registerAndFire (claudeAgentSession.ts:1377), which already returns a value from _earlyResults (pendingRequestRegistry.ts:35-39), but nothing ever buffers a permission answer there.
  • The Copilot session handles exactly this race: when its permission request arrives for a client tool whose result is already buffered, it approves it (copilotAgentSession.ts:9531-9538, "Auto-approving client tool … because its result arrived before the permission request"), and a client tool completion also answers a pending permission (copilotAgentSession.ts:5197-5201).

Possible fixes

  1. Do what Copilot does: after Agent Host client tool hangs after active client removal; browser click invoked with empty args #322990's respondOrBuffer change, have requestPermission approve a client tool whose result is already buffered (_pendingClientToolCalls.hasBufferedResult(toolUseID)).
  2. Or keep the early answer: if no session has the request parked, remember the answer for that tool_use_id (once, in ClaudeAgent, since ids are unique), and have requestPermission consume it before firing pending_confirmation.

Workaround tested

I've been running option 2 in my own agent host since yesterday, applied at runtime through the inspector (each session keeps the early answer in _pendingPermissions._earlyResults without claiming it, so ClaudeAgent keeps offering it to the other sessions, and copies nobody uses expire after 30 minutes). With it, the repro completes every time; the agent host logged that it used an early answer at 16:22:06 and 16:27:50, each followed by the early client tool result for the same call (#322990).

Related: #322990 (same race for the result), #324261 (the same completion-before-permission race on the Copilot side, fixed there), #347909 (another cause of the same symptom).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions