Claude PTY actor exits on first delivery: CCCC types into Claude Code's startup dialogs (workspace trust / bypass-permissions warning)
Follow-up to #94, item 5 ("message delivery kills the actor"). The Windows fixes in
750b224 / 388f29d address the launch path, but the delivery kill has a different,
platform-independent cause. Reproduced on Linux (WSL2 Ubuntu 24.04, kernel 6.18, native
PTY) with cccc version 0.4.37 and Claude Code 2.1.259 / 2.1.260. A fix on top of
current main (388f29d) is in the linked PR.
Symptom
A claude actor with runner: pty starts, stays up while idle, and exits a few seconds
after the first message is delivered. LF/none submit sequences do not kill it, but
nothing is ever submitted either. runner: headless works.
| runtime / runner | submit | result |
|---|---|---|
| claude pty | Enter (one CR) | process exits ~1–11 s after delivery, exit code 1, every time |
| claude pty | Newline (LF) | survives, never submits |
| claude pty | None | survives, never submits |
| claude headless | – | works |
| codex pty | Enter (CR CR) | works |
Reproduce
- Create a group whose scope directory has never been opened interactively by a human
(the default
~/.ccccscope is enough), add a Claude actor withrunner: ptyand a command that carries--dangerously-skip-permissions, start it. - Send it one message (
cccc send --to <actor> ...). - Watch
ledger.jsonl:runtime.deliveryis accepted, then the actor process exits with code 1 a few seconds later and the daemon restarts it. Repeat forever.
Root cause
Claude Code's interactive TUI opens behind up to two blocking startup dialogs whose
default (focused) answer is "No, exit" and whose confirm key is \r:
- Workspace trust — shown whenever the cwd is not in
~/.claude.jsonprojects[<cwd>].hasTrustDialogAccepted. CCCC launches actors in the group scope directory, which has never been trusted by a human.--dangerously-skip-permissionsdoes not skip this dialog (verified below). - Bypass Permissions mode warning — shown for
--dangerously-skip-permissionsuntilskipDangerousModePermissionPrompt: trueis present in settings.
CCCC delivers the preamble as soon as it believes the terminal is in input mode, then
sends \r. That \r confirms "No, exit" and Claude exits cleanly (exit code 1). \n
is not Enter for the Ink TUI, so LF just leaves the dialog on screen forever — which
looks identical to "alive but never submits".
claude --help documents why headless is unaffected: "The workspace trust dialog is
skipped when Claude is run in non-interactive mode (via -p, or when stdout is not a
TTY)".
Why CCCC cannot see the dialogs
actor_delivery_worker::wait_for_input_mode treats "bracketed paste enabled" as
"prompt ready". Claude enables bracketed paste (ESC[?2004h) before the dialogs are
drawn, so the heuristic is satisfied while a dialog is up. The SessionStart hook, on the
other hand, only fires once the dialogs are dismissed and the session really starts;
until then the hook state stays awaiting_session_start (working reason
claude_pty_fail_closed_HookPending).
Evidence
pty.fork() harness, claude --dangerously-skip-permissions, 14 s capture, TERM=xterm-256color:
# trusted cwd, no acknowledgement anywhere
bracketed_paste_on=True alive=True
... WARNING: Claude Code running in Bypass Permissions mode ...
❯ No, exit Yes, I accept Enter to confirm · Esc to cancel
# trusted cwd, --settings /tmp/s.json ({"skipDangerousModePermissionPrompt": true})
bracketed_paste_on=True alive=True
... ❯ Try "edit <filepath> to..." ⏵⏵ bypass permissions on <- prompt ready, no dialog
# untrusted cwd, same --settings file
bracketed_paste_on=True alive=True
Accessing workspace: /tmp/probe-untrusted
Quick safety check: Is this a project you created or one you trust? ...
❯ No, exit Yes, I trust this folder Enter to confirm · Esc to cancel
Sending text + a single \r while the trust dialog is up: process gone within ~0.5 s,
waitpid status 256 (exit code 1), output ends with the normal shutdown sequence, no
stack trace. After Down + \r (accept) the same text + \r submits normally and the
reply streams back. Two independent agents reproduced the same thing with os.forkpty().
Fix (linked PR, on top of 388f29d)
- Pre-trust the scope before spawning (
claude_hooks::configure): writeprojects[cwd].hasTrustDialogAccepted = trueinto$CLAUDE_CONFIG_DIR/.claude.json(else~/.claude.json), atomically, preserving everything else. This is exactly the state Claude writes when a human picks "Yes, I trust this folder"; the operator attached the scope on purpose. - Acknowledge the bypass warning in the managed settings file CCCC already writes:
skipDangerousModePermissionPrompt: truewhen the command carries--dangerously-skip-permissions/--permission-mode bypassPermissions, unless the operator's settings set it explicitly. - Gate PTY delivery on SessionStart for Claude: when the launch has hook projection,
wait for the hook state to leave
awaiting_session_start(30 s per attempt; the worker already defers and retries) instead of trusting bracketed paste. With hooks unavailable it falls back to the old heuristic. This stops CCCC from ever typing into a dialog, including ones this patch does not pre-answer (e.g. login).
Kimi Code problems found on the way (double Enter, ~/.kimi-code/mcp.json) are filed
separately as #96 and fixed in the same PR.
Result with the fix (same machine, 2026-09-04)
| actor | before | after |
|---|---|---|
| claude-1 (pty) | exits on first delivery | ~/.claude.json gains the scope, managed settings carry the acknowledgement, SessionStart hook arrives ~30 s after launch, delivery accepted, reply 9 s later, process stays idle |
| codex-1 (pty) | works | unchanged, reply 9 s after delivery |
Unit tests for claude_hooks, actor_delivery_worker and runtime_mcp pass, including
new ones for the trust write and the bypass acknowledgement.
Status update from the reporter.
The fix originally attached to this issue (PR #97) targeted the PTY-paste delivery path that existed at 388f29d: pre-trust the scope in ~/.claude.json, acknowledge the bypass-permissions prompt in the managed settings, and gate PTY delivery on the SessionStart hook. 4a1e529 replaced that path with managed Agent View sessions (claude attach, no Hook or PTY-paste fallback), so I have rebased #97 down to its Kimi Code part only.
What is still worth checking on the new path: .claude.json has no hasTrustDialogAccepted entry for the scope directory on a fresh host, and nothing in 4a1e529 writes one (the live test fixture pre-seeds bypassPermissionsModeAccepted / skipDangerousModePermissionPrompt but not workspace trust). If the Agent View session or the attached terminal still shows the "Is this a project you trust?" dialog for an untrusted cwd, a first delivery would hit the same "No, exit" default. Happy to re-test once I move to a build with 4a1e529; leaving this open for that.
Thanks a lot for your support!