Design: let a managed Claude actor start from an existing conversation
Why this matters now
A daemon restart (here: a routine version upgrade) relaunched a long-running managed Claude actor on a fresh conversation, and the operator lost the conversation it had been having for weeks. Switching that actor to the managed claude runtime afterwards did not help either: actor switch attached a new Agent View session instead of the conversation the actor had been in. The only way back today is outside CCCC's contract (a hand-written --resume <id> in a custom-runtime command). The two requirements below are what an operator needs so that a restart or a runtime switch never costs the conversation.
Requirement
An operator restarts an actor and must keep its conversation.
Two halves of that:
- Restart keeps the conversation. Stop a managed Claude actor, start it again, and it must come back on the conversation it was having — not on a fresh one that happens to carry the same context window.
- The operator can name the conversation when nothing is saved. When there is no saved session to come back on (a new actor, a receipt cleared by an explicit new session, a changed command/workspace/model/configuration, resume disabled for the process, or a conversation that already exists only on the provider side), the operator must be able to point the actor at that conversation by id instead of being handed a brand new one.
Neither half is available to the operator today: (1) holds only in the narrow case set out below, and (2) has no input at all.
What cccc does today (v0.4.53, 8f5b6a79)
The contract already promises half (1). docs/guide/runtimes.md:413-420:
Daemon-managed Claude agents persist the Agent View session id in the shared runtime-session state. An ordinary stop/start validates the runtime, workspace, command, complete effective configuration identity, and saved-state status. It re-adopts one matching live idle job or uses Claude's exact cold-resume form; a copied, busy, ambiguous, or mismatched job fails closed instead of being guessed.
actor_new_sessionclears the receipt, andCCCC_RUNTIME_RESUME=0disables reuse.
The implementation.
crates/cccc-daemon/src/ops/runtime_session/claude.rs:50prepare_managedreads the saved receipt: resume must be enabled at all (:58), the record must bev+kind=runtime_session+transport=claude_agent_view+runtime=claudewith the sameworkspace_path,command_fingerprint,modelandidentity_fingerprintand a non-emptyprovider_thread_id(:64-75), and a validprovider_session_id(:77-80), and statususablewithresume_eligible=true(:87-91). Any mismatch returnsOk(None).crates/cccc-daemon/src/ops/codex_voice_analyst/launch_claude.rs:93-96turns that intoresume_session_id= the saved session id, else the explicitly requested one, else nothing.crates/cccc-daemon/src/ops/codex_voice_analyst/claude.rs:142-158re-adopts one matching live idle job when there is one;claude.rs:169-177builds the launch arguments:- with a saved session id, only
--bg --resume <id>is passed (claude.rs:173, comment at:171-172: "Agent View resumes the exact durable session only when no launch configuration is repeated. Any additional flag intentionally forks."); - with nothing saved, the usual configured launch plus
--name <actor> --bg(claude.rs:174-177) — a new conversation.
- with a saved session id, only
- The resume is verified fail-closed: if the job reports a different session id than the one
requested, the launch is rejected as a copied session
(
claude.rs:243-251, error at:246; message incrates/cccc-daemon/src/ops/codex_voice_analyst/claude/resume_failure.rs:19-20: "Claude Agent View copied a requested session instead of resuming it exactly").
So half (1) holds only while the receipt matches exactly. Every way the receipt stops
matching — a new actor, actor_new_session, a changed command/workspace/model/configuration,
CCCC_RUNTIME_RESUME=0 — takes the else branch at claude.rs:174-177 and silently starts a
new conversation. The contract at runtimes.md:410 even documents that "New session
deliberately clears its CCCC receipt before selecting fresh work"; after that clear there is no
way back onto the previous conversation.
Half (2) has no input at all.
- A managed Claude actor's launch passes
Nonefor the requested session id (crates/cccc-daemon/src/ops/codex_voice_analyst/launch.rs:208-214, theNoneat:213). Only the saved receipt can produce a resume. - Naming one through the runtime command is refused outright:
crates/cccc-daemon/src/ops/codex_voice_analyst/claude/command.rs:257lists--resumeamong the CCCC-owned session values,command.rs:271among the owned flags, andcommand.rs:327-331rejects the launch with "Claude runtime command contains a CCCC-owned session or transport argument: {flag}" (regression test atcommand.rs:583).
There is therefore no supported path that puts an existing conversation id in front of a managed Claude actor.
The smallest change
Four files, +250 / −12 against v0.4.53 (see DIFF-LINECOUNT.txt); no new crate, no schema
change, no CLI surface:
crates/cccc-daemon/src/ops/codex_voice_analyst/launch_claude.rs— one public actor environment key,CCCC_CLAUDE_ADOPT_SESSION, holding the conversation id to adopt. It is read from the actor's own environment (which is already part of the configuration identity fingerprint), only when the launch is for an actor, and passed as one new optional argument. The environment is the smallest input that already reaches every launch unchanged, so the feature is opt-in per actor, visible in the recorded configuration, and needs no new field, CLI or TUI change.crates/cccc-daemon/src/ops/codex_voice_analyst/claude.rs— when there is no saved session to resume and an id was named, CCCC appends--resume <id>to its own launch arguments in the fresh-launch branch (claude.rs:174-177), then reads the conversation Agent View actually resumed from the job's ownstate.json(resumeSessionId) and refuses if it is not the named conversation — the job is killed rather than left attached to a foreign one ("Claude Agent View did not resume the conversation this actor adopts"). The adopted id travels on the job so the transcript follower may follow that conversation (transcript_identity,read_resumed_conversation).crates/cccc-daemon/src/ops/codex_voice_analyst/claude/transcript.rs— the per-record identity check compares each record'ssessionIdagainst the conversation the job is allowed to carry (its own job id, or the adopted id) instead of only the job id.crates/cccc-daemon/src/ops/codex_voice_analyst/claude/workspace_trust.rs— one test call-site gains the new argument.
The change is deliberately one-way: with the key unset, every line of behaviour above is byte-for-byte today's.
The refusal rule for a foreign session
Adoption is opt-in, exact, and verified. Nothing attaches to a conversation the operator did not name:
- No key, no change. The transcript identity defaults to the job's own session id
(
transcript.rs:66, set in the constructor attranscript.rs:79-91), so an unrequested attach is refused exactly as it is today. - The id must be well-formed. The named id is validated as a session id before launch, the
same way the saved-session path already validates one (
claude.rs:143,validate_session_idatclaude.rs:1494). - Adoption only ever happens on a first launch. It is considered only when there is no saved session to resume, so it can never displace an actor's own saved conversation.
- The resumed conversation must be the named one. If Agent View reports a different
resumeSessionId, the launch fails closed and the job is killed ("Claude Agent View did not resume the conversation this actor adopts"); the existing copied-session rejection (claude.rs:243-251) still governs the saved-session path. - The transcript must be the named conversation's. The transcript path must be
<allowed id>.jsonl(claude.rs:1397-1403, "Claude Agent View state referenced a different transcript identity"), every non-meta record'ssessionIdmust equal it (transcript.rs:132-139, "Claude transcript record belongs to a different session"), and meta records carrying a foreign id are dropped, never accepted (transcript.rs:328-336). - The runtime command still cannot resume by itself.
--resumeremains a CCCC-owned argument (command.rs:327-331). - No automatic fallback. If adoption cannot be verified, the launch errors; it never falls back to a fresh conversation and never silently keeps a mismatched one.
Test env
- Offline unit tests, no network and no provider account, in the Claude adapter:
only_the_adopted_conversation_becomes_the_transcript_identity,follower_reads_the_adopted_transcript_and_refuses_an_unrequested_one(crates/cccc-daemon/src/ops/codex_voice_analyst/claude.rs),records_of_an_adopted_conversation_are_accepted_once_named(crates/cccc-daemon/src/ops/codex_voice_analyst/claude/transcript.rs). They cover the acceptance path, the refusal path, and the fact that an unrequested attach stays refused. - The patch applies cleanly to v0.4.53 (verified with
git apply --checkon a clean worktree at the tag); the four files are unchanged between v0.4.50 and v0.4.53. - Demonstrated against a real account (macOS, Claude Agent View, the same four files applied to v0.4.51; they are unchanged through v0.4.53): an existing conversation held by a native session was freed, the actor was switched to the managed
clauderuntime withCCCC_CLAUDE_ADOPT_SESSION=<that id>, and started. Agent View's job state reportedsessionId == resumeSessionId == <the named id>, the transcript identity was the adopted id, and a delivered message was answered in the same conversation with its prior context intact. - The refusal path also fired for real: for a second conversation, which Agent View had registered under a different project directory than the actor's workspace, Agent View ignored
--resumeand served a new session. The check refused it and killed the job (twice, identical), and the actor was left on its previous state. So Agent View's project scoping is one more case the fail-closed check has to catch, and it does. Whether CCCC should instead launch in the conversation's own project directory is a question for review.
@ChesterRa this has been a persistent bugbear for months for me. every upgrade (of which there have been like 999999 in the past 48 hours) I have had to manually resume every claude actor like some kind of super meat boy proxy. this is my own fork of a patch that I have carried forward every patch and now I can rest easy I can tell it 'go lifecycle upgrade' and my claudes have a quick nap, then come back.
Thanks for clarifying that this has been recurring across upgrades. Reconnecting every Claude actor manually should not be part of an ordinary upgrade; we'd like to diagnose the automatic-resume path.
We would still rather make the automatic resume work than add a Claude-only way to adopt a conversation by id, so we are not taking the patch as it is.
To find out why the resume fails for you, one concrete upgrade is enough. For the most recent one, could you tell us:
- How the Claude actors were configured before it: the
clauderuntime managed by CCCC, or a custom command (if so, the command line, with anything private removed). - How you upgraded and restarted: the installer or command you used, and how the daemon was started again afterwards (the same terminal, a service, a script, an agent).
Please leave out credentials, environment values and conversation contents.
The next release does not change which conversation a start selects. It does record, when a managed actor comes back on a new conversation, when that happened and which of the compared settings had changed, so a later occurrence will be easier to explain.
Agreed: the target should be reliable automatic resume, not a separate adoption interface. I'll withdraw #208 and keep this issue focused on that path. My earlier comment did not specify those details for a particular upgrade, so it is not yet a reproducible case. I'll collect one upgrade's managed-versus-custom configuration and exact sanitized update/restart procedure, without credentials, environment values or conversation contents, before proposing another change.
Thanks, that matches our view. We have a narrow fix, not yet released, for reusing a saved, stopped conversation when the recognized launch identity differs only in PATH. It does not adopt a still-running session under a changed PATH or relax the other launch-identity checks. For the upgrade case, the useful evidence is what changed in the executable/command, model, workspace, settings and environment. Information from the upgrade you already went through is enough to start; there is no need to repeat it.
The narrow PATH-only case discussed above is now covered by 0.4.55: a saved, stopped managed Claude conversation may be reused when the recognized launch identity differs only in PATH. This does not adopt a still-running job under a changed identity and does not relax the other identity checks. The broader upgrade report remains open pending one concrete sanitized configuration and upgrade sequence. Information from an upgrade that already happened is sufficient; no new reproduction or adoption PR is needed.
Thank you, Chester, for the 0.4.55 fix and for taking the time to explain the identity checks so clearly. You asked for one concrete configuration and sequence, so here is one, offered in case it helps. This one is a configuration change, not a version upgrade.
Setup
- Machine: cccc 0.4.58 on Ubuntu 24.04 x86_64, 16 vCPU AMD EPYC, 30 GiB RAM.
- Build: ours carries unrelated patches. The session-selection and Claude launcher files (
ops/runtime_session/claude.rs,launch_claude.rs,claude/command.rs) are byte-identical to tag v0.4.58. - Claude Code: 2.1.325.
The actor: a managed claude-runtime actor, running for days on one conversation.
Sequence
- The actor runs with
claude --model claude-opus-5-5[1m] --advisor fableplus other flags. - The operator changes only the model and advisor flags, to
--model opus --advisor claude-fable-5-2, withcccc actor update <id> --command "...". Other flags are unchanged. The running session keeps going; the new command applies at the next launch. - Hours later the actor is restarted (
cccc actor restart <id>).
Result
- The launcher passed no
--resume, and the actor came up on a new, empty conversation. - The saved receipt (
state/runtime_sessions/claude.json) shows the replacement at the restart time. - It names the previous session id, and the reasons
command,model,launch_identity. - Nothing told the operator. The actor looked healthy (running, idle) until someone noticed it no longer knew its context.
Two observations
- The rejection reads as intended. Model and command are in the launch identity, so the saved receipt is rejected after a flags-only change. What hurts is that the replacement is silent. An event or notice when a saved conversation is dropped on launch would have let us recover in minutes instead of hours.
- The old conversation was not lost. Its transcript was intact, and once it was reachable,
claude --resume <previous id>in a custom-runtime actor brought it back. That is how we run these actors now. It is outside the managed contract you describe, though, and changing that actor's flags later is safe only because the id is pinned by hand.
If either of these fits your plans, we'd be grateful for a visible notice when a saved conversation is not reused, and a way for an operator to keep the saved conversation across a flags-only change.
Thank you again for maintaining cccc and for your patience with our reports.
sorry @ChesterRa lemme find out who was impolite.
Thanks for the concrete configuration and sequence. We checked both points in an isolated environment, without any provider calls.
1. No visible signal when the saved conversation is not resumed. We reproduced the sequence with the released 0.4.58 and Claude Code 2.1.327: a managed Claude member with a saved conversation, only --model changed through cccc actor update, then cccc actor restart. CCCC started a new conversation and recorded the reasons command, model and launch_identity, the same as in your report. It also wrote a notice to the user ("runtime_session_replaced (runtime_sessions_replaced for a Group start, one entry per member whose saved conversation was replaced), the Web shows a notice with the known reasons, and the CLI prints a note on stderr so its JSON output stays parseable. 0.4.58 does not include this change.
2. Keeping the conversation when only launch flags change. We tested Claude Code 2.1.325 and 2.1.327 directly, with a loopback model:
--bg --resume OLD_IDalone keeps the same session ID and its history.- With the model and advisor flags from your example, Claude created a new session ID and sent the earlier conversation to the model. Both Opus spellings resolved to the same main model in our test. In a separate run, switching to Sonnet changed the model in the actual request and kept the earlier turns.
- We could not observe the advisor taking effect in this environment, so we make no claim about
--advisor.
On the CCCC side, a saved conversation is reused only when the launch command and model match. A worker that is still running is reattached without applying new flags, and a cold resume must return the same session ID it asked for. So in the stop/edit/restart sequence you reported, changing the member's saved --model starts a new conversation (which main now tells you), and relaxing the command check alone would not apply the new flags.
What works today is switching the model inside the member's own session, without changing its launch command. Open the member's terminal in CCCC and run /model. In a session that already has history, Claude asks "Switch model?" either way. Confirm it with Enter, and wait until it shows "Set model" and the input box before more messages arrive: a message that arrives while the prompt is open can be taken as the confirmation, and then it does not reach the model, even though CCCC records it as accepted.
- In the model picker, choose the model and press
sto switch only this session. We checked this on Claude Code 2.1.327, both natively and with a real CCCC member and a group message: same session, the next request used the new model with the earlier history, and the default model in Claude's settings was not changed. - Typing
/model <name>also works. We checked this with a real CCCC member and a group message: same session ID, the reply came from the new model, and the earlier replies were still in its context./model <name>also saves the model as the default for new sessions in the Claude configuration the member uses, so if that configuration is shared with your own Claude Code, your default changes too.
Either way, Claude saves the new model with the session. In our test, resuming the session the way CCCC restarts a member kept the new model, so later restarts should keep it as long as you don't change the member's launch command; changing the launch command still starts a new conversation.
Continuing into a new branch automatically when the launch flags change is a different matter. When we resumed with CCCC's own launch flags, Claude Code 2.1.327 kept the new model and settings for the branch, and a later restart kept its ID and history. But in this run the transcript first appeared after the first new message, and it carried copies of earlier records. CCCC cannot yet reliably tell those copies apart from the reply to the new message, which could make the start fail or handle earlier turns again. We are not adding this for now. Switching inside the session covers the model change in your example; we could not verify changing the advisor this way in our offline test environment.
Your manual recovery with claude --resume matches what we observed: the old conversation is still there. That continues it in Claude Code itself; it does not reattach it to the CCCC member.