Skip to content

fix(claude): show Needs You while an MCP elicitation dialog is open - #33517

Merged
nwparker merged 3 commits into
mainfrom
nwparker/agint-claude-mcp-elicitation
Oct 25, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/agint-claude-mcp-elicitation

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​150 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

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 Elicitation hooks before an MCP elicitation dialog opens and ElicitationResult hooks after it closes. Orca neither installed these hooks nor mapped them, so the pane stayed at the working set by the MCP tool's PreToolUse.

Upstream refs (Claude Code 2.1.310, from the installed native binary; it's closed source, so these are minified symbols):

  • Hook event enum: [..., "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", ...]. Its first appearance is 2.1.63, pinned in claude-hook-event-enums.json.
  • Hook input schema: 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."
  • Runners: Elicitation fires before the dialog. A hook only declines if it returns a blocking error or a response, and Orca's observer script does neither. ElicitationResult fires with action: accept|decline|cancel after the user answers.

What changed

  • Orca installs Elicitation and ElicitationResult for 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.
  • The Claude listener maps Elicitation to waiting and stores the lead state the dialog displaced.
  • ElicitationResult restores that stored state instead of forcing working, so a server elicitation outside a turn (for example a URL elicitation at connect) settles back to done. If the listener has no record of the session (for example its state was lost), it also settles to done.
  • Claude 2.1.310 never sends agent_id on Elicitation, so a subagent's elicitation goes through the lead path.
  • Both events count as session-owner events, so a replacement session voids the previous session's claims.

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 claude 2.1.310 in a PTY, an isolated CLAUDE_CONFIG_DIR/HOME, a fake Anthropic server that returns one mcp__elicit__ask tool call, and a 30-line stdio MCP server that sends elicitation/create. Orca's real ClaudeHookService.install({claudeVersion: '2.1.310'}) script and settings posted to a real AgentHookServer. Status events seen:

origin/main (dialog was visible from t=190887 to t=195005):

UserPromptSubmit state=working
PreToolUse       state=working tool=mcp__elicit__ask
PostToolUse      state=working       <- no waiting while the dialog was open
Stop             state=done

This branch (accept, and Esc/cancel behave the same):

UserPromptSubmit  state=working
PreToolUse        state=working tool=mcp__elicit__ask
Elicitation       state=waiting tool=mcp__elicit__ask   <- dialog visible
ElicitationResult state=working
PostToolUse       state=working
Stop              state=done

Tests and checks

  • Added a regression test: in-turn wait/resume, idle elicitation settling to done, settling to done when the listener has no record of the session, and session replacement. The idle cases fail on the contributor commit alone.
  • pnpm test src/shared/ src/main/agent-hooks/ src/main/claude/: 18956 passed.
  • pnpm tc passes, and check:code-quality:changed passes.

Risk

  • Hook latency. Orca's observer now runs before every Claude MCP elicitation dialog, the same short-lived script every other event uses. It never prints a decision and never exits 2, so it can't decline a dialog.
  • Overlapping dialogs. If a main-agent permission prompt is pending and a parallel MCP tool elicits, answering the elicitation shows working even 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.
  • Another hook answers the dialog. If a different user hook answers or declines an elicitation, Claude skips ElicitationResult. Orca may then show Needs You until the next tool event or prompt.
  • Parallel tools. When a sibling tool running in parallel finishes, its hook clears waiting early, even though the dialog may still be open.
  • Mixed versions. A newer client writing these hooks against an older relay or listener is harmless, because unmapped events are dropped there.
  • Platforms. No platform-specific code. The same hook entry path is used on Windows (.cmd) and macOS/Linux.

Co-authored-by: Wooseong Kim 2222333+innocarpe@users.noreply.github.com

innocarpe and others added 2 commits October 25, 2026 04:39
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>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The change registers Claude Elicitation and ElicitationResult hooks for CLI version 2.1.63 and later. The listener reports elicitation as waiting and restores the saved lead state when a matching result arrives. It also adds session-ownership handling and tests for active, idle, and replacement-session cases.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 60cf7

In multi-session or replaced-session panes, the agent status can show the wrong state: working while a dialog is still open, or a stale working state restored after the dialog closes. Fix the session matching in the elicitation handling before merge. The common single-session case works as intended.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary user-facing change: showing Needs You while a Claude MCP elicitation dialog is open.
Description check Passed The description provides a clear user impact, root cause, implementation details, linked issue, verification results, and known risks. It does not include the template's dedicated Visual Proof, Review…
Linked Issues check Passed Issue #25020 requires Claude MCP elicitation dialogs to show waiting while open and return to the prior state after the user responds. The PR registers Elicitation and ElicitationResult for Clau…
Out of Scope Changes check Passed The changes stay within issue #25020. Version gating, downgrade retirement, session ownership, state restoration, and regression tests support Claude elicitation handling. The PR does not add unrelate…
Full details: Description check

Explanation

The description provides a clear user impact, root cause, implementation details, linked issue, verification results, and known risks. It does not include the template's dedicated Visual Proof, Review, or Checklist sections, but the core required information is present.

Full details: Linked Issues check

Explanation

Issue #25020 requires Claude MCP elicitation dialogs to show waiting while open and return to the prior state after the user responds. The PR registers Elicitation and ElicitationResult for Claude 2.1.63 and newer, maps Elicitation to waiting, restores the displaced state on ElicitationResult, and covers in-turn, idle, unrecorded-session, and replacement-session cases with tests.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #25020. Version gating, downgrade retirement, session ownership, state restoration, and regression tests support Claude elicitation handling. The PR does not add unrelated product behavior, and the documented overlapping-prompt limitation remains outside the change.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Commits

Reviewing files that changed from the base of the PR and between ced9a3d and 8b83976.

Files selected for processing: 7
  • src/main/claude/__fixtures__/claude-hook-event-enums.json
  • src/main/claude/claude-hook-event-install.test.ts
  • src/main/claude/claude-hook-event-versions.ts
  • src/main/claude/claude-managed-hook-events.ts
  • src/shared/agent-hook-listener-claude-elicitation.test.ts
  • src/shared/agent-hook-listener/providers/claude-events.ts
  • src/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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

🔎 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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

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 lift

Match an elicitation result to the session that opened the wait.

If a late ElicitationResult from session-a arrives while session-b has an elicitation open, both events can have an undefined agent_id. This guard then accepts the old result and closes session-b's wait. Ownership updates also run before this guard, so the old result can replace session-b as 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
Commits

Reviewing files that changed from the base of the PR and between 8b83976 and 60cf7ad.

Files selected for processing: 2
  • src/shared/agent-hook-listener-claude-elicitation.test.ts
  • src/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.

Comment on lines +245 to +249
: isWaitingInducing && (eventAgentId || eventName === 'Elicitation') && previousLead
? previousLead.state === 'waiting'
? previousLead.stateBeforeWait
: {
state: previousLead.state,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

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)

@nwparker
nwparker merged commit 0b8f519 into main Oct 25, 2026
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude Code MCP approval dialogs show WORKING instead of Needs You

2 participants