[CLI 2.21.2] Auto-compaction loops forever and loses the uncheckpointed session
Before opening
- [x] I searched open and closed issues.
- [x] I am using the current installed Kiro CLI version available to this account.
Operating System
macOS 27.0.0 (26A5425a), Apple M3 Pro, 11 cores, 18 GB RAM.
Kiro Version
kiro-cli 2.21.2 (a4729fa233d8097438cb3dcb4c9c8d2f21cc82d9, built 2026-09-08). Kiro IDE 1.0.437 is also installed.
Bug Description
When a long Kiro CLI session reaches automatic conversation compaction, the CLI displays Compacting conversation... and enters a non-terminating local loop. The first visible compaction never completes. The TUI becomes unrecoverable, interrupts do not work, memory continues growing, and the only exit is force-closing the terminal.
The affected conversation is not checkpointed to SQLite or a transcript file, so force-closing the process destroys the entire session. --resume, --resume-id, --resume-picker, and /sessions cannot recover it.
This happens on essentially every sufficiently long session that reaches this compaction path and is a blocker for daily engineering use.
Steps to Reproduce
- Start Kiro CLI v3 with AWS IAM Identity Center authentication.
- Select
gpt-5.6-solwith effortmax. - Use a long-running agentic session until automatic compaction starts. The failing session displayed 46% context usage when compaction began.
- Use these settings:
compaction.excludeContextWindowPercent=25compaction.excludeMessages=6
- Observe
Compacting conversation.... - Wait: the spinner and in-session timer freeze, but the process continues consuming CPU and allocating memory.
- Try Ctrl+C, Esc, or Ctrl+D. None returns control.
- Force-close the terminal, then try every session-resume mechanism. The session is absent.
Expected Behavior
- Compaction completes within a bounded time or fails with an actionable error.
- Ctrl+C or Esc aborts a stuck compaction and returns to the prompt.
- Conversation turns are persisted incrementally so an unclean exit can be resumed.
- A compaction timeout or recursion guard prevents unlimited local CPU/memory growth.
Actual Behavior and Live Evidence
A failing process was measured read-only and never signalled during observation:
- Hung for at least 3h49m.
- CPU accumulated continuously at about 12.2% of one core: 68.57 seconds of CPU over 560 seconds of wall time across three sample points.
- RSS increased monotonically from 360,784 KB to 435,744 KB in nine minutes (+75 MB). Physical footprint was 749 MB; peak was 888 MB.
lsofreported zero established network connections. No model call or retry was active; the non-terminating work was entirely local.- A three-second process sample showed the main thread alternating between
kevent64and deeply recursive JIT-compiled JavaScript frames. Worker threads were parked primarily in__ulock_wait2(6,981 samples) and__psynch_cvwait(4,649 samples). - Process chain:
kiro-cli --v3->kiro-cli-chat chat --v3->bun tui.js chat --v3.
These measurements are consistent with an unbounded loop or recursion in the compaction path that also allocates without releasing.
Persistence Failure / Work Loss
data.sqlite3, tableconversations_v2, had no row for the running session. The newest row in the table was three days older.- The CLI session directory contained no transcript file for the running session. Its newest transcript was also days older.
- The failed run contained about 45 minutes of agent work within a 4h35m session.
Conversation ID
Unavailable because the affected running session was never persisted and disappeared completely after the forced exit. The absence of a recoverable conversation ID is part of the bug.
Related Issues, but Distinct Failure Mode
- #11213 tracks repeated summarization after a compaction completes. Here, the first visible compaction never completes, while CPU and RSS grow locally with no network call.
- #10535 tracks a hard 60-second
/compacttimeout. Here, automatic compaction remains inside the process for hours and does not return a timeout. - #10743 reports history loss associated with compaction. This report adds direct SQLite/transcript evidence that the live session had never been checkpointed at all.
AWS Support explicitly directed us to file this technical product report. Full process samples, diagnostics, and timestamped measurements are available through a private upload channel; they are intentionally not attached publicly because they may include local environment paths.
🤖 Potential Duplicate Detected
This issue appears to be similar to:
What happens next?
- ⏰ This issue will be automatically closed in 3 days
- 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
- 💬 Comment on the original issue if you have additional information
Why is this marked as duplicate? Both issues involve context compaction in Kiro CLI causing data loss and broken tool behavior. Issue #7491 reports fsWrite and executeBash dropping parameters after context compaction, while the new issue reports auto-compaction looping forever and losing the uncheckpointed session. Both share the core theme of compaction causing session/data integrity problems in the CLI.
Thank you for your feedback! 🙏
The 👎 reaction has been noted. The duplicate label has been removed and this issue has been sent back for maintainer review.
A maintainer will review this issue shortly.
Thanks for raising this. This might be a state machine gap in the TUI's auto-compaction path. When proactive summarization fires without a preceding /compact command, the completion event might arrive with an unresolved correlation key that doesn't match the active compaction attempt, leaving isCompacting stuck and the input loop blocked. Ctrl+C and Esc won't help in that state since input is gated on that flag.
The bot-flagged #7491 isn't a duplicate — that's about backend parameter drop after compaction, which is a different problem.
Marking this as a bug to investigate further.