Repository navigation
fix(claude): show Needs You while an MCP elicitation dialog is open - #33517
Conversation
Claude Code emits Elicitation while an MCP server waits for the person and ElicitationResult after they answer. Those events were not installed or mapped, so the pane stayed WORKING (#25020). Install both from Claude 2.1.63, the first release whose hook enum names them, map Elicitation to waiting and ElicitationResult to working, and treat them as session-owner events.
… state ElicitationResult now restores the state Elicitation displaced instead of forcing working, so a server elicitation outside a turn settles back to done. Register the events for Claude only; OpenClaude's fixed plan is unchanged. Co-authored-by: Wooseong Kim <2222333+innocarpe@users.noreply.github.com>
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
708c1f17-0580-45c3-80ee-68bcadd9b474
Files selected for processing: 7-
src/main/claude/__fixtures__/claude-hook-event-enums.jsonsrc/main/claude/claude-hook-event-install.test.tssrc/main/claude/claude-hook-event-versions.tssrc/main/claude/claude-managed-hook-events.tssrc/shared/agent-hook-listener-claude-elicitation.test.tssrc/shared/agent-hook-listener/providers/claude-events.tssrc/shared/agent-hook-listener/providers/claude-roster-state.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
| 'PermissionRequest' | ||
| 'PermissionRequest', | ||
| 'Elicitation', | ||
| 'ElicitationResult' |
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
# Locate the changed symbols and their consumers within the reviewed tree. rg -n -F -e 'voidClaimsOfReplacedClaudeSession' -e 'CLAUDE_SESSION_OWNER_EVENTS' -e 'ElicitationResult' -e 'Elicitation' -- src/ || test "$?" -eq 1 # Print the complete changed file with line numbers. wc -l src/shared/agent-hook-listener/providers/claude-roster-state.ts cat -n src/shared/agent-hook-listener/providers/claude-roster-state.ts
Repository: stablyai/orca
Length of output: 20819
Script executed:
# Print the call site and the ElicitationResult/Elicitation branches with line numbers. cat -n src/shared/agent-hook-listener/providers/claude-events.ts | sed -n '1,160p' echo '-----' cat -n src/shared/agent-hook-listener/providers/claude-events.ts | sed -n '225,270p'
Repository: stablyai/orca
Length of output: 10647
Script executed:
cat -n src/shared/agent-hook-listener/providers/claude-events.ts | sed -n '160,224p'
Repository: stablyai/orca
Length of output: 3649
Script executed:
cat -n src/shared/agent-hook-listener/providers/claude-events.ts | sed -n '270,400p'
Repository: stablyai/orca
Length of output: 3133
Reject stale ElicitationResult events before they change session ownership.
A delayed ElicitationResult from a replaced session can reclaim pane ownership. It can then restore the lead state that the newer session's open dialog displaced. The pane can show working while the newer session's dialog is still open. The same stale result also clears the newer session's replacement-owned cron and unconfirmed roster state.
Main-agent ElicitationResult events have no agent_id. The restore check therefore matches a main-agent Elicitation wait. Reject a main-agent ElicitationResult whose session_id differs from the current pane owner before the owner is reassigned:
🐛 Suggested fix
-
} + // A stale result must not reclaim ownership or restore the lead after a session replacement. + const resultSessionId = readString(hookPayload, 'session_id') + const currentOwner = state.claudeSessionOwnerByPaneKey.get(paneKey) + if ( + eventName === 'ElicitationResult' && + eventAgentId === undefined && + resultSessionId !== undefined && + currentOwner !== undefined && + resultSessionId !== currentOwner + ) { + return null + } voidClaimsOfReplacedClaudeSession(state, eventName, eventAgentId, paneKey, hookPayload)
Add a regression test that sends an Elicitation from session B, then an ElicitationResult from session A. Assert that the lead remains waiting and that pane ownership remains B.
Co-authored-by: Wooseong Kim <2222333+innocarpe@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Major · Match an elicitation result to the session that opened the wait. · claude-events.ts:115-118
src/shared/agent-hook-listener/providers/claude-events.ts:115-118
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftMatch an elicitation result to the session that opened the wait.
If a late
ElicitationResultfromsession-aarrives whilesession-bhas an elicitation open, both events can have an undefinedagent_id. This guard then accepts the old result and closessession-b's wait. Ownership updates also run before this guard, so the old result can replacesession-bas pane owner. Retain the waiting session ID and reject results from another session before changing ownership or restoring state. (raw.githubusercontent.com)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2a765258-643c-4401-b0f2-e17a54ccbd36
Files selected for processing: 2-
src/shared/agent-hook-listener-claude-elicitation.test.tssrc/shared/agent-hook-listener/providers/claude-events.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
| : isWaitingInducing && (eventAgentId || eventName === 'Elicitation') && previousLead | ||
| ? previousLead.state === 'waiting' | ||
| ? previousLead.stateBeforeWait | ||
| : { | ||
| state: previousLead.state, |
There was a problem hiding this comment.
Do not restore a lead state from a replaced session.
If session-a owns a working lead and session-b first appears through Elicitation, voidClaimsOfReplacedClaudeSession changes the owner but leaves that lead record in place. This branch saves session-a's working state and clock. When session-b sends ElicitationResult, the listener restores that old working state, even if session-b had no turn to resume. Compare session ownership before saving previousLead; use the no-prior-lead fallback when ownership changed. (raw.githubusercontent.com)
Summary
When a Claude Code MCP server asks you to fill in a form (MCP
elicitation/create), Claude Code shows a dialog and waits for you. Orca kept showing the agent as working the whole time, so nothing told you it needed you. Now the pane shows Needs You while the dialog is open. Once you answer, decline, or cancel, it goes back to whatever it was doing before.Fixes #25020
Root cause
Claude Code 2.1.63 and newer emit
Elicitationhooks before an MCP elicitation dialog opens andElicitationResulthooks after it closes. Orca neither installed these hooks nor mapped them, so the pane stayed at theworkingset by the MCP tool'sPreToolUse.Upstream refs (Claude Code 2.1.310, from the installed native binary; it's closed source, so these are minified symbols):
[..., "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", ...]. Its first appearance is 2.1.63, pinned inclaude-hook-event-enums.json.hook_event_name: "Elicitation", mcp_server_name, message, mode: "form"|"url", url?, elicitation_id?, requested_schema?, described as "Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog."Elicitationfires before the dialog. A hook only declines if it returns a blocking error or a response, and Orca's observer script does neither.ElicitationResultfires withaction: accept|decline|cancelafter the user answers.What changed
ElicitationandElicitationResultfor Claude >= 2.1.63 through the existing version gate. It installs them for Claude only. OpenClaude's fixed plan doesn't change, and a downgrade retires Orca's entries.Elicitationtowaitingand stores the lead state the dialog displaced.ElicitationResultrestores that stored state instead of forcingworking, so a server elicitation outside a turn (for example a URL elicitation at connect) settles back todone. If the listener has no record of the session (for example its state was lost), it also settles todone.agent_idonElicitation, so a subagent's elicitation goes through the lead path.This builds on @innocarpe's original commit, kept as-is. The follow-up commit adds restore-on-result and Claude-only registration. It's a smaller alternative to the larger scoped-attention design in #25057.
Verification
Real CLI, end to end, no model spend. The setup was real
claude2.1.310 in a PTY, an isolatedCLAUDE_CONFIG_DIR/HOME, a fake Anthropic server that returns onemcp__elicit__asktool call, and a 30-line stdio MCP server that sendselicitation/create. Orca's realClaudeHookService.install({claudeVersion: '2.1.310'})script and settings posted to a realAgentHookServer. Status events seen:origin/main (dialog was visible from t=190887 to t=195005):
This branch (accept, and Esc/cancel behave the same):
Tests and checks
pnpm test src/shared/ src/main/agent-hooks/ src/main/claude/: 18956 passed.pnpm tcpasses, andcheck:code-quality:changedpasses.Risk
workingeven though the permission is still pending. The next tool hook corrects it. fix(claude): preserve MCP elicitation approval state #25057 handles that overlap with about 200 more lines of per-request tracking. This PR leaves that edge case out to stay small.ElicitationResult. Orca may then show Needs You until the next tool event or prompt..cmd) and macOS/Linux.Co-authored-by: Wooseong Kim 2222333+innocarpe@users.noreply.github.com