Auto-dismiss HITL approval popup on elicitation timeout#27
Open
pragati-agrawal-glean wants to merge 1 commit into
Open
Auto-dismiss HITL approval popup on elicitation timeout#27pragati-agrawal-glean wants to merge 1 commit into
pragati-agrawal-glean wants to merge 1 commit into
Conversation
… id 0)
When a user doesn't respond to a HITL approval prompt within HITL_TIMEOUT_MS,
the popup got stuck: the user had to press Escape and retry. Root cause is a
client-side MCP SDK bug. The first server->client request in a session gets
JSON-RPC id 0. The SDK's `_oncancel` bails on a falsy requestId
(`if (!notification.params.requestId) return`), and `!0` is true — so the
`notifications/cancelled` we send on timeout for request id 0 is silently
dropped by the client, and the accept/decline popup never auto-dismisses
(it lingers with dead buttons). Prompts 2+ get id>=1 and dismiss fine, which
is why it looked flaky ("sometimes it disappears").
Fix: burn id 0 with a throwaway ping before the first elicitation, so every
approval prompt uses id>=1 and its timeout cancellation is honored. The id is
consumed synchronously inside request(), so it's fire-and-forget and tolerant
of ping failure. The real fix belongs in the SDK's `_oncancel`; this guards us
until clients ship it.
- src/tools/run-tool.ts: primeElicitationCancellation(), once per server
- tests/run-tool.test.ts: cover the burn (pings once; not when no approval)
- plugins/glean/dist/index.js: rebuilt
- bump all 3 plugin manifests 0.2.34 -> 0.2.35
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
14e8d21 to
adcacb5
Compare
swarup-padhi-glean
left a comment
Contributor
There was a problem hiding this comment.
Can you also post screenshots of its working in the slack channel?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user doesn't respond to a HITL approval prompt within HITL_TIMEOUT_MS, the popup got stuck: the user had to press Escape and retry. Root cause is a client-side MCP SDK bug. The first server->client request in a session gets JSON-RPC id 0. The SDK's
_oncancelbails on a falsy requestId (if (!notification.params.requestId) return), and!0is true — so thenotifications/cancelledwe send on timeout for request id 0 is silently dropped by the client, and the accept/decline popup never auto-dismisses (it lingers with dead buttons). Prompts 2+ get id>=1 and dismiss fine, which is why it looked flaky ("sometimes it disappears").Fix: burn id 0 with a throwaway ping before the first elicitation, so every approval prompt uses id>=1 and its timeout cancellation is honored. The id is consumed synchronously inside request(), so it's fire-and-forget and tolerant of ping failure. The real fix belongs in the SDK's
_oncancel; this guards us until clients ship it.