Expand description
Backfill the registry record session_id from each agent’s provider
transcript, so a cross-channel open --resumes the original conversation
instead of starting a fresh session.
Background: the registry session_id is read on launch (surfaced to the
picker, which passes it as --resume <sid> on the first turn of a reattached
block — agent_handlers/session.rs) but was never written by production
code, so it was always null. A fresh-build / cross-channel open therefore
had no sid to resume and spawned a brand-new session, which then shadowed
the original.
See docs/retro/retro-cross-channel-conversation-continuity-regression-2026-06-16.md.
Production code now also writes it on every capture (core::persist_session_id,
mirrored to the registry by the instance store); this idempotent startup pass
backfills records that predate that write.
Functions§
- backfill_
session_ ids - Populate
session_idfor registry records that lack one, from the agent’s largest provider session. Idempotent (skips records that already carry a non-empty id). Returns the number populated. Best-effort per record — a record with nosource_agents_baseor no transcript is skipped, never fatal. - find_
largest_ session_ for_ working_ dir - Recovery lookup for a confirmed-stale
--resumefailure (docs/status/STATUS_CROSS_CHANNEL_RESUME_STALE_SESSION_ID_2026_08_20.md): rather than giving up and starting a blank conversation the moment a registry/inheritedsession_idturns out to be unreachable, look for the largest session actually on disk under this exactconfig_dir(theCLAUDE_CONFIG_DIRthe CLI process is about to run with) forworking_dir.Nonewhenconfig_diris empty/unset (nothing to search) or no session exists — callers fall back to starting blank in either case, same as before this existed. - largest_
session_ id - The provider session id (jsonl stem) of the agent’s largest session across
the candidate project roots (the account-wide default and, for identity-bound
agents, the account’s home). We pick the largest, not the newest, on purpose:
an accidental fresh session (one started when a blank cross-channel open failed
to resume) must never win over the real conversation.
Nonewhen there are no session files under any root. - largest_
with_ 🔒size - The largest
(size, session-id)directly underprojects_dir/<slug>, orNoneif the dir doesn’t exist / has no session files. - session_
file_ path - Absolute path of the transcript file
--resume <sid>would need to find:<config_dir>/projects/<slug(working_dir)>/<sid>.jsonl. - session_
is_ reachable - Would
--resume <sid>find its conversation under this exactCLAUDE_CONFIG_DIR? This is the whole of what the CLI checks before answering “No conversation found with session ID” — so asking it up front predicts a resume’s success without spawning anything.