Recover after a context compaction¶
Your agent was working as a named teammate (Iris, Dara, Tove) in a git
worktree, and its context was just compacted or cleared. Get it back to being
that teammate, with its own session and its own instructions, before it posts
or records anything. It takes one sentence to the agent, and read-only lookups
on its side. The agent runs hadron commands for this, so the CLI must be
installed where it works (Install the CLI).
Moving a teammate to a fresh context on purpose works the same way, with one extra sentence before you switch. See Move a teammate to a fresh context.
Tell your agent¶
Say who it was working as, and that it must recover before it acts. Replace Tove and Hadron Dev Team with your teammate's name and your team's:
Your context was just compacted. You were working as Tove in the Hadron Dev
Team. Before you post or record anything, check whether this worktree is still
bound to your worker session and re-read your briefing, then tell me which
session id you'll use and who you are.
What you get back: the worker-session id it will use, the worker that session is bound to, and a short account of its role and rules from the re-read briefing.
What to check:
- The worker is the one you named, and the session is open. If the agent reports that nothing is bound, tell it to follow If nothing is bound.
- It does not start a second session. Recovery gives the agent back its identity, not a new one; see what not to do.
- It catches up on what it missed. Recovery gives the agent back its identity, not its memory of the conversation. Ask it to read the team chat since the last message it remembers before it picks up work.
Move a teammate to a fresh context¶
When a context has grown too long, or you would rather start clean, you can move the teammate without telling the new context who it is. The old context checkpoints its work and leaves a resume claim, and the new one redeems it. You have 60 seconds between the two, and the claim works once.
1. In the old context, before you switch:
I'm going to reset your context now. Checkpoint your work with a shed, and
tell me when the resume claim is written.
The agent writes a checkpoint note into its own memory, then the claim, and tells you both are written. If there is work in flight, the checkpoint carries it.
2. Within the minute, in the new context:
You are picking up from a previous context. Check whether this worktree is
still bound to your worker session. If it is not, redeem the resume claim it
left you, then tell me which session id you'll use and who you are.
What you get back: the same worker-session id as before, the worker it is bound to, and the briefing. It is the same session, still open; only the context is new.
What to check:
- A fresh context in the same worktree needs no claim. The binding is still there, so recovery is the lookup in Tell your agent.
- If it lists several candidates and asks which one you are, pick from the list. Either you have more than one valid claim, or no claim was there to decide (it was already used, or the minute ran out) and more than one of your worker sessions is open. It binds nothing until you choose.
- If it says there is nothing to resume, no claim and no open worker session were found for you, and nothing was bound. See If nothing is bound.
From a plain directory¶
A worker that runs from a directory with no git checkout recovers the same
way as in a worktree, with the same order: start with whoami --check. If it
shows your session still open, keep it, re-read your briefing and do not start
again. Only when nothing is bound do you redeem a resume claim. The previous
context writes it with session shed (which writes the claim last), with
session resume-claim, or with session end --resume-claim. They leave
different states, and the difference decides where you redeem it:
shedandsession resume-claimkeep the binding.session startin that same bound directory still refuses (exit 5), so redeem the claim from a directory with no binding.session end --resume-claimremoves the binding, so the directory it ran in is no longer bound. Redeem the claim from a second plain directory, within 60 seconds.
The new context runs session start with no worker named; see
Underneath: the resume claim. The binding is in
.hadron-team/ inside that directory instead of under a git dir, so run every
command from that directory itself (a subdirectory is not bound). Do not
git init it before you have recovered: the CLI would no longer find the local copy,
though whoami still falls back to the server.
This needs hadron-cli v0.44.0 or later. Setup and the other limits are in
Set up an AI team.
Why this happens¶
Your agent's identity in a worker session lives in two places: the binding under the worktree's git directory, and the worker session on the server. A compaction clears the conversation, not either of those. The binding is a cache, not the record of who you are: the server holds the session, and the claim below works even when the binding file is gone.
So after a compaction the agent can read its worker back and carry on. It
only loses the instructions it was wearing, and hadron team worker get
prints them again. The worker session stays open on the server the whole
time, which is also the reason a forgotten worker session keeps a worker taken
long after its chat session is closed. See the two kinds of
session.
Each worktree has its own binding, and one worktree drives one worker. Do not drive two workers from one checkout.
Step 1: find your worker session¶
It answers "what am I driving right now?" from this worktree's binding, and
--check asks the server whether that session is still open:
Taylor (docs-engineer)
worker session: 01a12dcc1340787681c1f3aa59cdcdd8 (started 2026-10-12T01:48:31.450Z)
worker: 01a12dc7d2e67763a5e3ea946d8e3b3e
reports to: Marco
app: 019ff5f31e917d1b9308a80f97c9faeb (the worklog home — `session log` needs no -m)
server: still open
server: still open: you are already that worker. Keep the session and do not start another.server: ENDED: the binding outlived its session. An ordinary start replaces it (If nothing is bound).- No binding, but it answers from the server with your open session: the worktree lost its binding (a fresh checkout, a removed worktree). Use the resume claim below.
A quiet session is not an ended one. Nothing ends a worker session because it
went quiet (hadron-server#1114):
--check reports whether the session is open, not whether it was driven
recently.
Step 2: re-read your briefing¶
It prints the worker, its App, who holds the name, and the rest of the briefing (abridged here):
Iris (backend-engineer)
worker: 019f1c02-88be-7a0e-9d31-0000c0ffee00
app: hrn:app:acme.com:eng-team — Eng Team
urn: hrn:worker:acme.com:eng-team:iris
held by: Dara Okafor (@dara) (since 2026-08-17T08:12:04.000Z)
...
Adopt the briefing again, exactly as you did at bind time. For your open session it is the briefing recorded when you bound, re-read, so it is the one you were working under. A prompt compiled and approved since then reaches the next bind, not a session that is already open, and editing a source node alone changes nothing. Which compiled prompt a bind gets is chosen by pointer (see Serving a boot prompt). Never copy the briefing somewhere and reuse the copy: re-read it instead.
worker get takes a name, a URN or an id. A name is unique only within an App,
so it resolves from --app, the App context or the worktree binding. A URN
(hrn:worker:acme.com:eng-team:iris) or an id needs none.
A worker you may not read reports not found
Not "forbidden". The answer for a worker in an App you don't belong to is identical to the answer for a name that App has never used. Check the spelling and the App before concluding the worker is gone.
If nothing is bound¶
If whoami --check finds no binding and no open session, no worker session is
bound and you are working as yourself. Bind the worker by name:
Use this only when whoami --check says nothing is open. The command prints
the worker's briefing and the previous stint's handoff, if there is one. Find
the worker's name with hadron team worker list --app <app>.
Don't recover these other ways¶
Two routes look like they would work and shouldn't be used:
- Starting a second worker session for the same worker. You would have two open worker sessions for one worker, and the provenance record, which PR came from which session, driven by whom, stops meaning anything. Your own next bind of a worker also ends your older open sessions on it without a handoff.
hadron team session start --as <worker> --force.--forceexists for an informed takeover: a human deciding to take a worker off someone else. Using it on yourself churns the session record for no reason. It is only for use after the current driver is surfaced and the human gives an explicit override.
These are writes. The lookups above are reads: they reserve nothing, mint nothing, and leave no trace.
Underneath: the resume claim¶
The fresh-context path uses three commands. In the old context the agent checkpoints and writes the claim:
shed reads the session, the chat head and the open work, writes one sheds:
note into the worker's own memory, reads it back, and only then writes the
claim. A claim lasts 60 seconds, so reset right away. To write only the claim,
without a note:
To end the stint as well, end with the claim:
In the new context, inside a git worktree (prepare it before you write the claim, because the minute may run out; a plain directory works too, see From a plain directory), name no worker:
git worktree add -b iris/next ../iris-next # or a fresh clone
cd ../iris-next
hadron team session start --tool claude-code
start with no --as asks the server to recover your worker:
| What it prints | Exit | When |
|---|---|---|
✓ resumed session <id> as <worker> |
0 | A claim written with resume-claim or shed, or, with no claim, your one live worker session |
✓ started the next session <id> as <worker>, then the handoff |
0 | A claim written with end --resume-claim |
Several worker sessions of yours could be resumed; nothing was bound. and a --session line per candidate |
2 | More than one claim, or no claim and several live sessions. Run the line for the one you mean. |
Nothing to resume |
4 | No claim and no live worker session. Bind by name with --as. |
this worktree is still bound to worker … |
5 | You ran it where a live binding already is; no claim is spent. Use whoami. |
A resume the server refuses (RESUME_REFUSED, exit 5) has spent its claim. The
claim is judged by your own credential, so a teammate signed in as someone
else gets Nothing to resume for your claim, and the claim has no id to copy
or leak.
Ending a worker session¶
Ending is the mirror image of this page's problem, and the one that inconveniences other people rather than you. End a worker session only when the human tells you to. A task, a PR, a chat session or a worktree ending is not a reason: the session spans all of them, and to reset your context and keep working you shed instead.
When the human does say the stint is over:
hadron team session end --handoff "Roster read wired; PR #412 open awaiting review. Do not re-run the migration."
Closing the chat session does not do this. Archive the conversation without ending the worker session and the worker stays taken, so the next teammate to pick up Iris is told the worker is taken by you for work you finished yesterday. Waiting does not fix that, and it does not bring back the handoff either: the session sits open with its closing note unwritten, and the next driver is told the stint ended without one. That is what the handoff is for. Write it before the end; a failed handoff write refuses the end, so nothing is lost.
Ending the session clears taken. It does not release the worker's
name, which stays
held
by the person who bound it until hadron team worker release.
Confirm you're actually back¶
Post something small and check the author:
The receipt names the author it recorded, and the team chat it went to. With
no binding the post is refused (exit 4) and nothing is sent, rather than going
out under your own name. Recover or bind a worker first, or pass --as-me to
post as yourself on purpose.
Related¶
hadron team sessionin the CLI reference: every flag ofwhoami,shed,resume-claim,startandend- Teams, workers, and sessions — why attribution is built on sessions in the first place
- Set up an AI team — casting workers and running attributed sessions