Repository navigation
Description
Operating system
macOS
Orca version
1.4.156 — the code path is unchanged on main @ eb35c7f (2026-07-31), so v1.4.162 / v1.4.163-rc.0 are affected too. Agent: Claude Code 2.1.220.
Details
Short summary
After approving a Bash permission prompt, the agent visibly resumes work, but the pane glyph, sidebar agent row and worktree dot stay on the amber "needs you" question mark until the turn ends. The row keeps rendering the already-answered approval card, so jumping to the pane to "handle the request" lands on a pane with nothing to approve.
It happens whenever the permission request cannot be paired with the tool_use_id of the call it belongs to. Reproduced end to end by delaying the PreToolUse POST so it arrives after the PermissionRequest — a delivery order the hook script's 1.5s curl timeout makes reachable under load, and the one that matches a live pane found stuck here (its cached permission carried no toolUseId).
This is the real-permission counterpart of #8310, which was fixed for AskUserQuestion only.
What happened?
Hook arrivals at the server, and the pane state they produced (real Claude Code session, real AgentHookServer, approval sent through a PTY):
UserPromptSubmit → working
PermissionRequest Bash "chmod 644 alpha.txt" → waiting (no tool_use_id in the payload)
PreToolUse Bash id=toolu_…kXhSY4ih → dropped
[user approves]
PostToolUse Bash id=toolu_…kXhSY4ih → dropped
PermissionRequest Bash "chmod 644 beta.txt" → waiting
The pane never leaves waiting. Everything after the first prompt is suppressed for the rest of the turn, including the approved tool's own completion — only Stop or a new user prompt releases it. On a long turn that is many minutes of a wrong "needs you" indicator on every surface that reads agent status.
How can we reproduce it?
- Run Claude Code in an Orca pane with agent status hooks enabled.
- Make the
PreToolUsePOST land after thePermissionRequestPOST — under load this happens on its own; deterministically, wrap thePreToolUsehook so it posts from a background subshell after ~600ms. - Ask for a command that needs approval (e.g.
chmod 644 some-file), then approve it. - Watch the pane glyph and sidebar row for the rest of the turn: the amber question mark stays while the agent keeps running tools, and the stale approval card stays rendered.
A parallel tool batch reaches the same dead end without any delivery race, because Claude announces sibling calls between a PreToolUse and its PermissionRequest. That is the shape of the unit repro below.
Failing test (drop into src/main/agent-hooks/, fails on main)
import { expect, it } from 'vitest'
import { makePaneKey } from '../../shared/stable-pane-id'
import { AgentHookServer } from './server'
const PANE_KEY = makePaneKey('tab-scratch', '22222222-2222-4222-8222-222222222222')
function ingest(server: AgentHookServer, event): void {
server.ingestRemote(
{
paneKey: PANE_KEY,
tabId: 'tab-scratch',
worktreeId: 'worktree-scratch',
hookEventName: event.hookEventName,
...(event.toolUseId ? { toolUseId: event.toolUseId } : {}),
payload: {
state: event.state,
agentType: 'claude',
toolName: event.toolName,
toolInput: event.toolInput
}
},
'connection-scratch'
)
}
it('resumes working after approving a tool from a parallel batch', () => {
const server = new AgentHookServer()
ingest(server, { state: 'working', hookEventName: 'PreToolUse', toolName: 'Bash', toolInput: 'cmd-A', toolUseId: 'toolu_A' })
ingest(server, { state: 'working', hookEventName: 'PreToolUse', toolName: 'Bash', toolInput: 'cmd-B', toolUseId: 'toolu_B' })
ingest(server, { state: 'waiting', hookEventName: 'PermissionRequest', toolName: 'Bash', toolInput: 'cmd-A' })
ingest(server, { state: 'working', hookEventName: 'PostToolUse', toolName: 'Bash', toolInput: 'cmd-A', toolUseId: 'toolu_A' })
expect(server.getStatusSnapshot()[0]?.state).toBe('working') // received 'waiting'
})Dropping the second PreToolUse (single call, in-order delivery) makes the same test pass, which isolates the pairing failure as the cause.
Anything else that might help
In src/main/agent-hooks/server.ts, a cached permission wait suppresses every later Claude working event (shouldKeepClaudePermissionVisible, L428, applied at L1124), and the only release path requires proving the approved tool resumed via a matching tool_use_id (isClaudePermissionResumingApprovedTool, L454). Claude's PermissionRequest payload carries no tool_use_id, so Orca inherits it from the previous event only when that event is the matching PreToolUse (L500). Anything that breaks that adjacency — a late PreToolUse POST, a sibling call of a parallel batch — leaves the permission without an id, and no later event can clear it. The suppressed events include PreToolUse, so the next prompt of the same turn has nothing to inherit from either.
Verified against Claude Code 2.1.220: PreToolUse and PostToolUse carry tool_use_id, PermissionRequest does not.
Happy to open a PR with a fix and regression tests if that would help.
Activity
giirrr commentedon Jul 31, 2026
Correcting the reproduction above after testing it end to end.
The original text pinned the trigger on a parallel tool batch. Driving a real Claude Code session through a PTY against a real
AgentHookServershows Claude serialises permission prompts (PreToolUse→PermissionRequest→ approval →PostToolUse, one call at a time), so a plain parallel batch of prompts does not reproduce it — the issue body would have sent anyone straight into a "cannot reproduce".What does reproduce it live is a
PreToolUsePOST arriving after itsPermissionRequest, which the hook script's 1.5s curl timeout makes reachable under load. With arrivals in that order, the pane never leaveswaiting; every later event, including the approved call's ownPostToolUse, is suppressed for the rest of the turn. That also matches the pane I originally found stuck: its cached permission carried notoolUseId.The parallel batch is still a real path to the same dead end — sibling announcements break the
PreToolUse→PermissionRequestadjacency the id inheritance depends on — so it stays as the unit repro.Body updated with the corrected steps and the observed hook/state trace. A PR is on the way.
AmethystLiang commentedon Aug 1, 2026
thanks for reporting. will look into it
giirrr commentedon Aug 31, 2026
Reporter here. Your reading matches what I measured, and the parallel-batch case you describe is exactly where my attempt at this broke.
On carrying
tool_use_idinto the cached record — it is blocked upstream, not in Orca.Claude Code's
PermissionRequesthook input has notool_use_id. I captured raw stdin for 8 permission prompts on CLI 2.1.221 and the field was absent in all 8. The top-level keys aresession_id,transcript_path,cwd,prompt_id,permission_mode,effort,hook_event_name,tool_name,tool_input,permission_suggestions.PreToolUseandPostToolUsedo carry it: per the CLI changelog, 2.0.43 addedtool_use_idto those two input types, and thePermissionRequesthook was introduced afterwards in 2.0.45 — so this looks like an ordering gap rather than a deliberate omission. I re-read the changelog through 2.1.235 and found no change.I filed anthropics/claude-code#83748 for it. Still open, no comments,
area:hookslabel added 2026-08-17.prompt_idis not a substitute: it identifies a turn, and one turn can contain several tool calls.Orca already does the inheritance you are describing, and it predates my PR.
shouldInheritClaudeToolUseIdForPermission(src/main/agent-hooks/server.ts:653) copies the precedingPreToolUse'stool_use_idonto aPermissionRequestwhen the agent id, agent type and tool name match and the tool inputs are either both known-equal or both unknown. So the cached record can carry an id today — but one inferred from adjacency, not one the CLI asserted.That inference is where the batch case bites.
toolInputis a truncated preview (Bash is cut at 160 characters) and isundefinedfor MCP, Task and TodoWrite, so two sibling calls in one batch can be indistinguishable on every field the payload exposes. The hooks are independentcurlPOSTs with--max-time 1.5, so they can arrive late, out of order, duplicated, or not at all.I tried to make this safe in #11711 and it did not hold. Adding an "inherit only when exactly one candidate is pending" rule produced a further regression, because "only one sibling exists" and "the sibling's declaration has not arrived yet" are the same observation from the client side. The maintainer review caught it and the PR was closed.
For the same reason I would be careful with re-driving the render from hook-server state (your option b): a late POST still cannot be attributed to a specific request while the distinguishing signal is absent, so it moves where the guess happens rather than removing it.
What I would suggest instead
Until the CLI carries the id on
PermissionRequest, treat an unpairable permission as unresolved rather than resolving it against "something in this session was approved". A stale card that stays is recoverable by the user; a card that clears while an approval is still live hides a blocked agent, which is the more harmful direction. Every regression I produced landed on that asymmetry.If a stronger client-side signal is wanted without waiting on upstream, the only one I found is the
PostToolUsetool_use_id. It arrives after the fact, so it can retire a pending row retroactively — useful for reconciliation, not for deciding what to render at prompt time.giirrr commentedon Sep 2, 2026
I went and read the current code before answering, and I have to correct myself on one point.
The retroactive retirement already exists — it is not a proposal.
isClaudePermissionResumingApprovedTool(src/main/agent-hooks/server.ts:607) clears a waiting permission on eitherPreToolUseorPostToolUse, and only when there is a non-conflictingtool_use_idplus a matching concrete agent id, explicit agent type, or tool use id, with the tool name equal and the inputs either both known-equal or both unknown.server-claude-permission-visibility.test.tspins both directions, including "keeps Claude permission visible when approved tool execution has no identity". So the conservative behaviour you and I agreed on is already the shipped one; I described it as something to add, which was wrong.On your first edge — the tombstone. It is real, but narrower than "permanent". There is no max-age sweep over pending permissions in the hook server. The only age bound I found is
HYDRATE_MAX_AGE_MS(7 days,server.ts:242), and it applies when rehydrating persisted last-status from disk at startup, to cap disk growth — not to live session state. So a tool whosePostToolUsenever lands keeps its card for the life of the session, and the 7-day cut-off only takes effect after a restart. The "executed without attribution" record you suggest has nothing to write into today.On your second edge — the redundant approval. I do not think it is reachable here, because Orca never gates an approval on the stored row. The mobile Allow/Deny card writes raw terminal bytes into the PTY — a number to allow, Escape to deny,
enter: false, since those are already complete control sequences (mobile/src/session/mobile-native-chat-permission-send.ts). The decision is answered by the TUI exactly as if it had been typed. Nothing reads the pending record to decide whether a later identical request still needs approval, so a delayed retirement cannot queue a second one. I searched for such a gate and only found unrelated hits.There is a hazard in the opposite direction from the one you name, though, and it comes from the same raw-byte design: a card left up for a prompt that was already answered is not merely cosmetic, because tapping it still writes into whatever is on screen now. That is why the card is gated on a paused agent (
PAUSED_STATES = blocked | waiting) rather than on the envelope alone.So the asymmetry we agreed on holds, with one qualifier I would add: keep the state unresolved, but gate the actionable control on the agent still being paused. Those are two different decisions, and conflating them is what produced my worst regression.
harden(agent-status): make the Claude approval ledger replay-safe and…