State machine lifecycle bugs: messages swallowed, skills halt, plan mode traps
Resolved 💬 2 comments Opened Mar 2, 2026 by zarak Closed Mar 2, 2026
Bug Category
State machine / lifecycle bugs is the #5 bug category (~8 issues). The agent enters an inconsistent state where expected transitions don't fire or fire incorrectly.
Representative issues
- Messages swallowed after ESC interrupt, agents continue running (#30118) — user's interrupt signal doesn't propagate to background agents; subsequent messages are silently dropped
- --print mode hangs with team agents (#30008) — in_process_teammate agents cause the --print pipeline to hang indefinitely
- Parent skill halts after nested skill completes (#30028) — nested skill completion doesn't resume the parent, remaining steps never execute
- Plan mode breaks CLI session (#29725) — entering plan mode puts the session into a state where messages stop reaching the model
- AskUserQuestion auto-completes without user input (#29889, #29774, #30026) — the consent gate fires without blocking, returning empty answers
- Hook continue:false silently ignored (#29991) — PostToolUse hook sets continue=false via Agent SDK, but the control flow ignores it
- Context compaction re-enters plan mode (#29956) — compaction restores stale state, re-entering a mode the user had moved past
Root cause
These are all state machine transition bugs — the system has multiple states (idle, running, plan-mode, interrupted, skill-executing) and the transitions between them have edge cases:
- Missing transitions: interrupt signal has no transition to "cancel background agents"
- Stale state restoration: compaction restores a checkpoint from an earlier state instead of the current one
- Incorrect guard conditions: AskUserQuestion skips the blocking wait under certain permission modes
- Broken composition: skill nesting (A invokes B, B completes) doesn't correctly resume A
Proposed mitigations
TLA+ modeling is the right tool here. A SessionStateMachine.tla spec could model:
- States: idle, running, interrupted, plan_mode, skill_executing, compacting
- Transitions: user_input, esc_interrupt, tool_complete, skill_invoke, skill_complete, compact_start, compact_end
- Properties:
- S1: After interrupt, no background agent is running (safety)
- S2: After skill completes, parent resumes (liveness)
- S3: After compaction, session state matches pre-compaction state (safety)
- S4: AskUserQuestion always blocks until user responds (safety)
This is exactly the class of bugs TLA+ excels at finding — non-obvious interleavings of concurrent state transitions.
Related issues
#30118, #30008, #30028, #29725, #29889, #29774, #30026, #29991, #29956
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗