kiro-cli TUI: "Session not found" on startup wedges init and silently queues input (--classic unaffected)
kiro-cli TUI fails to init with "Session not found" on startup; silently queues all input (--classic unaffected)
Summary
Launching kiro-cli (default TUI) in a directory hung on "Initializing..." with
Failed to start session: Session not found: <uuid>. Every subsequent prompt was
accepted but shown as "queued" and never executed. Running with --classic (legacy UI)
in the same directory worked normally.
Impact / why this is a bug (independent of root cause)
- No self-heal: the runtime does not fall back to creating a fresh session when it can't start the resolved one.
- No user escape hatch: no prompt/option to reset or reinit the offending session.
- Misleading error: "Session not found" for a session that demonstrably exists and
resumes fine via
--classic/--resume. - Poor UX: input is silently queued behind an init that never completes.
Environment
- kiro-cli version: 2.21.2
- OS: Ubuntu 24.04.5 LTS (Linux 6.8.0-139-generic)
- Terminal: interactive SSH session from Cygwin + MinTTY (not piped)
- Notable: identical SSH client/terminal to a different host works fine → host-local state.
Error (from /tmp/kiro-log/kiro-tui.log)
ERROR: Failed to initialize Kiro: {"code":-32603,"data":"Failed to start session: Session not found: <session-uuid>","name":"RequestError"}
Occurred on two consecutive launches, then did not recur.
Investigation (read-only + reversible DB inspection; backup taken first)
The affected session (<S1>) is a valid ~3MB conversation in conversations_v2,
keyed to the cwd, and was the most-recently-updated row for that cwd at failure time.
Findings that narrowed the cause:
<S1>resumes perfectly via--classic/--resume(loads full context, no error, writes nothing to the TUI log). So the conversation data is not corrupt/unreadable.- The failing path is only the default TUI startup harness;
--resume/--classicuse a different harness and never logged an error. <S1>is a currently-live session in another process (it was the session actively in use while a second TUI was being launched in the same cwd). Its row grows/changes as that process writes to it.--resumeof a live session from a second process returns a checkpoint snapshot that lags the live in-memory state (the second process saw content frozen at the last flush, not the live tip) — i.e., resume forks from the last persisted checkpoint.- After making a different, quiescent session the newest row for the cwd, the TUI started cleanly every time. The failure has not reproduced since.
Leading hypothesis (not proven)
A startup race between the TUI's session resolution and checkpoint-based persistence:
when the cwd's newest session is concurrently live / mid-flush in another process, the TUI
tries to start/resolve that session against a backend state where it isn't cleanly
committed/registered, and returns -32603 "Session not found" instead of either
(a) creating a fresh session, or (b) reporting an accurate "session busy/among-writers"
condition. Once the checkpoint settled, subsequent launches succeeded.
This is consistent with all observations but we could not produce a deterministic repro from outside the app.
What we could NOT confirm
- Whether the trigger is strictly the concurrency/flush state vs. some attribute of that
specific row. A clean-room test (restore a pre-failure DB snapshot into an isolated
KIRO_DATA_DIRwith no concurrent writer) would discriminate, but we stopped short. - Exact backend behavior — the CLI is closed-source, so external tracing is limited.
Expected behavior
- If the resolved session can't be started, create a fresh session (or prompt to), never wedge on "Initializing...".
- Surface an accurate error (e.g., "session busy in another process") rather than "Session not found" for a session that exists.
- Never silently queue input behind a failed initialization.
Workarounds (for other users hitting this)
- Launch with
--classic(legacy UI), or kiro-cli --resume(uses the working resume path), or- Avoid launching a second TUI in a directory whose most-recent session is currently live in another process.
Thanks for the detailed and well-investigated report! 🙏 The issue you've described — where the TUI startup fails to recover from a stale session reference and silently queues all input while --classic works fine — is a really valuable find, and your diagnostic work narrowing it down to the TUI init harness is super helpful. A maintainer will review this shortly and take a closer look. We appreciate you taking the time to document this so thoroughly!
Follow-up: this is session identity/branching, not just checkpoint lag
Additional user-confirmed reproduction refines the root cause. The earlier "checkpoint
race" framing undersells it — the real defect is that a session_id does not uniquely
identify a single conversation lineage.
Reproduction
- A long-running session is live (call it timeline-1) under the legacy/
--classicharness. /exit(clean exit) of that session.kiro-cli --resumefrom the same cwd.
Observed
--resumedid not resume the tip of timeline-1. It resumed a diverged fork missing the most recent turns — even though step 2 was a clean/exit.- A clean
/exittherefore does not flush live state such that a subsequent--resumeis current. If this were one lineage with periodic checkpoints, exit-on-close should have made--resumecurrent. It did not. /chat save(in the original) →/chat load(in the new session) was the only way to carry the full current conversation across. Critically, this did not reconcile the two — it serialized timeline-1's transcript and replayed it into timeline-2. The new session now contains the story of timeline-1 but is a distinct instance, not timeline-1 continued.
Refined root cause
The same session_id can back multiple divergent conversation instances. --resume,
/chat save, and /chat load move content between instances without preserving or
reconciling identity:
- no merge,
- no "these histories have diverged" warning,
- no canonical/most-recent lineage guarantee.
This is consistent with the original -32603 "Session not found" symptom: startup
session-resolution against a set of forked/uncommitted instances sharing one id can fail
to resolve a single valid session, then wedge with no fallback.
Expected
- A
session_idshould identify exactly one conversation lineage, or the tooling should surface divergence explicitly and offer a deterministic choice (continue newest / fork explicitly / merge). - Clean
/exitshould persist the live tip so--resumeis current. - Never silently resurrect an older fork as if it were the continuation.
Workaround (confirmed)
/chat save then /chat load reliably transplants the current transcript into a fresh
session when --resume returns a stale fork.
Thanks for raising this. The diagnostic work here is excellent, and the reproduction steps isolating the concurrent-session condition are exactly what's needed.
The "Session not found" error on startup might be caused by the TUI's session resolution racing with a concurrently-live session in another process. When the most-recently-updated session for the cwd is held by an active process, the startup path might fail to start it and not fall back to creating a fresh session. The silent input queuing and the misleading error message look like separate UX gaps on top of the core race condition.
The session divergence finding in your follow-up, where --resume after a clean /exit returns an older fork, might point to a separate issue with how session state is flushed on exit versus how the resume path resolves the current session.
Marking this as a bug to investigate further.