Skip to content

fix(connector): put the hard prompts bypass mode still raises on a card, and name what a waiting terminal waits on (release 0.3.8) - #967

Merged
weilei0120 merged 2 commits into
mainfrom
fix/bypass-hard-prompt-card
Nov 30, 2026
Merged

weilei0120 merged 2 commits into
mainfrom
fix/bypass-hard-prompt-card

Conversation

@zoroyihan7

@zoroyihan7 zoroyihan7 commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A Claude Code session in bypassPermissions mode (--dangerously-skip-permissions) was skipped by the approval hooks entirely (UNATTENDED_MODES), on the premise that such a session is unwatched. A few prompts still appear in that mode, and they block the session until someone answers: a safety check (an rm -rf on a variable path that may be empty, circuitBreaker: "dangerousRemoval", classifierApprovable: false) and AskUserQuestion. They reached no phone. The owner got only the "waiting for you in a terminal" notice a minute later, with a bare "permission prompt". In one real bypass-mode session 1 of 198 permission decisions was such a prompt: rare, but each one stops the session.

Measured (Claude Code 2.1.332, real terminal in tmux, a PermissionRequest hook that logs its stdin and answers on demand)

PermissionRequest raised in bypass mode the hook's answer honoured
safety check (rm -rf $VAR/*, $VAR set outside the command) yes, permission_mode: "bypassPermissions", permission_suggestions: [], dialog shown at the same time allow: ran, "Allowed by PermissionRequest hook" (also when the hook answers 4 s after the dialog opened); deny: "Denied by PermissionRequest hook", files kept
AskUserQuestion yes updatedInput.answers honoured: "Which color? -> Blue"

Also measured: Claude Code blocks the safety-check dialog itself after about two minutes ("to avoid holding up an unattended session"; no PermissionDenied event, the turn ends and Stop follows). A question dialog has no such timer. A plain rm -rf /literal/path and an in-command D=...; rm -rf $D/* raise nothing in bypass mode.

End to end with this change: the built approval-hook.js under a real Claude Code in bypass mode, the real ApprovalBroker behind the socket. The safety check became a card (Run: rm -rf $VICTIM/*, buttons Yes / No / No, and stop), Yes ran the command, No denied it with the phone's message, the question's answer reached Claude Code, an answer typed at the terminal first withdrew the card, and the card was withdrawn when the turn ended after Claude Code's own two-minute block.

Change

  • Connector: Claude Code in bypass mode is no longer skipped; the request goes to the card path with the usual buttons (the hook's answer is honoured, so no "answer in the terminal" card is needed). dontAsk, claude -p, a session the connector runs, CLAW_APPROVAL_HOOKS=off and CLAUDE_CODE_SESSION_ATTENDED=0 are unchanged. Codex keeps skipping bypass mode: its hard prompts there were not measured. The broker's own check (approvals.ts) follows the same rule.
  • Connector: a waiting conversation reports waiting_on, the tool calls it has no result for as a card says them (Run: rm -rf $VICTIM/*, Edit src/main.ts, Question: Which color?; several joined by ; , at most three named), read from the end of its transcript (Claude Code writes the call before it asks; measured). Calls of a run are answered in any order and one without a result may be running rather than asking, so all of them are named. Credentials are masked like every title. Claude Code's own registry only says "permission prompt".
  • Claw: the "waiting for you" notice names those calls and says Claude Code's reasons in the owner's language ("权限确认", "需要你输入"), instead of the English words inside the Chinese sentence. An older connector reports no waiting_on; then the reason alone is said. Everything the notice quotes from a machine (its name, the agent, the title, the reason, the calls) now goes through inertMd, so [Confirm](https://x) is shown as characters and not as a link.
  • toolTitle moved to connector/src/tool-title.ts so the card and the notice use one wording. Connector 0.3.8, CHANGELOG, README.

Tests

Written first and failed before the change: approval-unattended.test.ts (6 of 23 red), pending-tool.test.ts (module missing; after review the out-of-order case returned nothing with the first version), the waiting_on heartbeat case in attach.test.ts, remote-agents-terminal-wait-text.test.ts (5 of 5 red at first, 2 red against the pre-review source), and T1, T10, T11, T12 of remote-agents-terminal-waits.test.ts against a real Postgres (4 of 12 red with the old source). All green after: the whole connector suite (1013 tests), the Claw terminal-wait suites on a real Postgres (18), typecheck, the lint scripts, check-pack, and the public scans. CI is green.

Notes

  • A card for the safety check can outlive Claude Code's two-minute block; a tap after that changes nothing (Claude Code ignores a late answer, as it does for any answer given at the terminal first). The card is withdrawn when the turn ends.
  • waiting_on carries command text to Claw for every waiting terminal, as titles already do; the opt-out CLAW_APPROVAL_HOOKS=off is per process and cannot be seen from the connector.

…rd, and name what a waiting terminal waits on (release 0.3.8)

A Claude Code session in bypassPermissions mode was skipped by the approval hooks entirely, on the premise that such a session is
unwatched. The prompts that still appear in that mode (a safety check such as an rm -rf on a possibly empty variable path, and
AskUserQuestion) block the session until someone answers, and reached no phone: the owner got only the "waiting for you in a
terminal" notice a minute later, with a bare "permission prompt".

Measured with Claude Code 2.1.332 in a terminal: both raise PermissionRequest in bypass mode, and Claude Code honours the hook's
allow, deny and chosen answer for them, including the safety check (classifierApprovable: false). So in bypass mode the hook now
forwards the request to the card path with the usual buttons. dontAsk, claude -p, a session the connector runs, the opt-out and
CLAUDE_CODE_SESSION_ATTENDED=0 are left alone as before, and so is Codex in bypass mode (unmeasured).

The connector also reports waiting_on with a waiting conversation: the tool call it waits on as a card says it, read from the end
of its transcript with credentials masked. Claw's notice names it and says Claude Code's reasons in the owner's language.

Signed-off-by: zoroyihan7 <Yihan.Wang@amd.com>
@zoroyihan7
zoroyihan7 requested a review from a team as a code owner November 30, 2026 12:19
… and show what a machine reported as characters

Review findings on the first commit:

- pending-tool: a later call of a run that had finished (a read) hid an earlier one that was still asking, so waiting_on was left
  out. The calls without a result are now collected across the newest run (several are named, oldest first, at most three), since a
  call without a result may also be running, not asking.
- terminal-waits: the notice quoted what the machine reported (waiting_on, and likewise its name, the agent, the title and the
  reason) with only backticks removed, so a value such as "[Confirm](https://x)" became a link in the owner's chat. All of them go
  through inertMd now, as the other cards that quote machine text do.

Signed-off-by: zoroyihan7 <Yihan.Wang@amd.com>

@weilei0120 weilei0120 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No blocking findings.

Read: connector/src/approval-skip.ts (neverAsksIn, skipReason), approval-hook.ts (how agent is passed), approvals.ts (ask() unattended-mode check, toolTitle re-export, sessionRules), tool-title.ts, pending-tool.ts (pendingToolsOfTail, pendingToolsIn, titleOf, waitingOn), attach.ts (describe → pendingCall, heartbeat summary, cleanTitle, fitResumable), claw remote-agents/terminal-waits.ts (terminalWaitText, sweep query), assistant/inert-md.ts, and the Claw protocol's capabilities check (resumable items are stored unchanged, so waiting_on passes). No other user of the removed UNATTENDED_MODES or the old toolTitle(PermissionEvent) signature in connector, claw or personal-agent; Codex bypass is still skipped both in the hook and in the broker.

Ran: connector npm ci, npm run typecheck (ok); tsx --test test/approval-unattended.test.ts test/pending-tool.test.ts test/cli.test.ts 83/83 pass; test/attach.test.ts test/approvals.test.ts 149/150, the one failure is a pid-namespace assertion of this sandbox ("linux::pid:[…]"), unrelated to the change. claw npm ci && npm run build ok; remote-agents-terminal-wait-text.test.ts 5/5 pass; remote-agents-terminal-waits.test.ts skipped here (no DATABASE_URL), CI ran it green with Postgres.

Second pass (independent reviewer over the whole diff) checked heartbeat validation, removed exports, whether a bypass-mode card can change the session mode (it cannot: only session-scoped allow rules), and transcript parsing; it added only the non-blocking truncation note below.

Non-blocking suggestions and open questions

  • connector/src/attach.ts:1142: cleanTitle cuts the joined waitingOn string to MAX_TITLE (80), so with a first command longer than ~75 characters the second and third calls and the +N more count are dropped, and Claw's WAITING_ON_MAX (100) never applies. The README/CHANGELOG say several calls are joined by ; . Consider truncating each title before joining (or a larger cap for this field).

Reviewed by Clawy on behalf of weilei0120 (requested by Wang, Yihan), run 9fc284904459

@weilei0120
weilei0120 merged commit 3745f37 into main Nov 30, 2026
63 checks passed
@weilei0120
weilei0120 deleted the fix/bypass-hard-prompt-card branch November 30, 2026 12:48
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.

2 participants