By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
An agent resumed a session from three days earlier and quoted a price that had changed twice. On another ticket, the same agent started fresh and asked a customer to verify an identity it had verified an hour before.
Both bugs answer one question badly: what is allowed to survive? Sessions are a state decision, not a storage feature.
A session is stored conversation state: messages, tool calls and their results. Resume loads that state and continues the same thread. Fork copies the state into a new branch and leaves the original alone.
| Action | What it does | When to use it |
|---|---|---|
| Resume | Continues the same thread from stored state | The user came back to the same task |
| Fork | Copies the state, runs a different path, keeps the original | A what-if, an alternative strategy, a comparison |
| New session | Starts with no stored state | A different task, or a different user |
Forking changes the conversation, not the world. A refund that already ran is still refunded in both branches. People expect a fork to undo the side effect, and it does not.
A fork copies messages. It does not roll back a payment, an email or a file. If the what-if must not repeat a side effect, the side effect needs an idempotency key or a dry-run mode, independent of the session.
The transcript records what was said. It is not a database. Anything that must be exact belongs in a record you control, and you reload it into the prompt.
| State | Where it lives | Why |
|---|---|---|
| Verified identity, ids, amounts | A structured record | Exact values, and no paraphrase drift |
| Plan, decisions, open questions | A scratchpad file | Survives compaction, and you can re-read it |
| Conversation nuance | The transcript | Useful, but may be summarised or dropped |
| Policy limits | Code, in hooks | Must hold on every call, not on most calls |
At resume, rebuild a short authoritative block and put it at the front of the prompt. Do not ask the model to remember a number it saw forty turns ago.
In practice the scratchpad is a plain JSON or text file in the workspace. The agent appends a decision when it makes one, and the host re-reads the file at every resume. A file is boring, diffable and visible in review, which is what an auditor asks for.
The next snippet builds the authoritative block from a record. It is deliberately boring: four keys, one line each, marked so the model does not re-derive them.
def carry_forward(record):
"""Build the short block that survives a resume or a compaction."""
keys = ("customer_id", "order_id", "verified", "refund_limit")
lines = [f"{key}: {record[key]}" for key in keys if key in record]
return "Known facts (authoritative, do not re-derive):\n" + "\n".join(lines)
record = {
"customer_id": "C-88",
"order_id": "A17",
"verified": True,
"refund_limit": 100,
}
print(carry_forward(record))The label matters. Known facts (authoritative, do not re-derive) gives the model a reason to prefer the block over an older sentence in the transcript.
Design the state layer for one workflow you run, before you write code.
Key takeaways
Resume continues a session; fork branches it and leaves the original intact.
A fork changes the conversation, not the world: side effects still happened.
Keep exact state in a record or scratchpad, not in the model's memory of the transcript.
Reload a short authoritative block at resume; re-validate the facts that move.
A new session is the right choice for a different task, not a cheap reset for a mistake.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.