Input during /compact silently cancels compaction; no machine-readable compaction state (multi-session orchestration)
Open 💬 0 comments Opened Jul 12, 2026 by EvanAhern
Summary
Running many concurrent claude TUI sessions (v2.1.207, macOS 26) coordinated by an external orchestration layer (osascript keystroke injection, serialized by a lock), we hit a repeating failure class around /compact that cost us five cancelled compactions in one night on production-critical sessions. Full incident was diagnosed live with screen captures, session JSONLs, and injector receipts; details sanitized here.
Behaviors observed (reproducible)
- Typing into the composer while "Compacting conversation…" runs silently cancels the compaction. Any external inject (or human keystroke) that lands mid-compaction kills it — no notice is written to the transcript/JSONL that a compaction was cancelled, so external tooling (and humans) discover it only by noticing context % never dropped. We had retry logic re-fire
/compactbecause it couldn't tell the first fire was mid-flight — each retry's typing cancelled the compaction it was checking on. Five cancellations in ~2.5 hours across two sessions.
- No machine-readable "compaction in progress" state. The statusline JSON input and session JSONL expose context %, but nothing exposes "compacting right now." External supervisors are reduced to screen-scraping the spinner text from
history of tabvia AppleScript.
- The post-compaction summary record (
isCompactSummary) appears to be written lazily (observed: a session at ctx 0% post-compact whose JSONL showed no new summary record until its next turn). Marker-count is otherwise the best external ground truth for "did the compact land," so the lag window creates false negatives for supervision tooling.
- Synthetic single-Enter (
System Eventskey code 36) intermittently fails to register in the TUI composer, leaving submitted-looking text sitting unsubmitted. Orchestration layers work around this with double-Enter — but a second Enter is unsafe around/compact(an empty submit right after compaction start). A single reliable programmatic submit path would remove the whole class.
Feature requests (in priority order)
- During compaction: queue composer input (or require an explicit confirm to cancel), and when a compaction IS cancelled by input, write an explicit "compaction cancelled" record to the transcript/JSONL.
- Expose compaction state machine-readably (statusline JSON field and/or a JSONL event at compaction start), and write the completion summary record eagerly at completion.
- A supported programmatic way to trigger compaction with custom instructions for a session (CLI/control-channel/file-drop), so multi-session setups don't need keystroke synthesis at all.
Context
- Claude Code v2.1.207, macOS 26 (Darwin 25.5.0), Terminal.app, multiple concurrent Max-plan sessions.
- The user-side orchestration defects that amplified this (retry logic reading stale state, no inject-hold) are ours and are being fixed on our side; the four items above are the product-level gaps that made the failure silent and hard to supervise.
- Filed at the operator's direction after a live incident; happy to provide sanitized timelines or run repro steps on request. Individual sessions' full data can be submitted via
/bugfrom those sessions if useful.