Domain 5 is where careful candidates lose easy points. The mechanisms sound interchangeable — resume, continue, compact, fork, memory, session — and the exam leans on that. It rarely asks what a mechanism is; it hands you a scenario and asks which mechanism fits. So the goal here is not definitions. It is a mental model precise enough that a scenario snaps to one mechanism and rules out the rest.
One fact anchors half of this guide: the Messages API is stateless. The model keeps no memory of prior calls. Every 'conversation' is an illusion maintained by a client that resends the accumulated history on each request. Once you internalize that, sessions, context windows, resume, and compaction stop being separate mysteries and become different answers to one question — what history do we replay, and how much of it survives?
This is an independent, unofficial study aid for the Foundations exam. It is not affiliated with or endorsed by Anthropic, reproduces no real exam content, and where an exact flag or option name is version-specific, it says so — verify current syntax in the official Claude Code and Agent SDK docs. Foundations tests the concept; the concept is what we drill.
resume vs compact vs new session
These three answer 'what happens to the context I've already built up?' Resume/continue reopens a prior session and appends to it — prior context is restored intact. Compact stays in the same session but replaces older turns with a summary, freeing token budget while continuing. New session starts clean — no prior context at all. The tell in a scenario is what the user wants to keep: everything (resume), the gist but with room to keep going (compact), or nothing (new).
In Claude Code, claude --continue reopens the most recent session in the current directory; claude --resume targets a specific session by ID. Both reopen the same session and append. /compact summarizes older messages in place. Exact flags can change across versions — confirm in current docs — but the three behaviors are the stable, testable idea.
| resume | compact | new session | |
|---|---|---|---|
| Purpose | continue exactly where you left off | keep going but reclaim context space | start clean, unrelated task |
| What happens to context | prior transcript restored in full | older turns replaced by a summary; recent kept | no prior context |
| When to use | returning to yesterday's task; need full history | long session nearing the window limit | new topic; want no bleed-through |
| When NOT to use | you want a fresh start (context bleeds in) | you need exact wording of every old turn | you needed the earlier context (now lost) |
Fork vs resume (and the Agent SDK forkSession idea)
Resume and fork both start from an existing session, but they differ on identity. Resume continues the same thread — new messages extend the original, one timeline. Fork branches the session into an independent copy: the fork gets its own session ID seeded with the history so far, and the original is left untouched. Fork is for exploring an alternative — a different approach, a risky refactor, a what-if — without polluting the thread you might want to return to.
In the Claude Agent SDK, forking is expressed by resuming a session and asking for a branch: pass the original session id to resume and set forkSession: true in the query() options, which produces a new session id seeded with a copy of the prior history. Without the fork flag, resuming simply continues the same session in place. Treat the exact option names as version-specific and confirm them in the current Agent SDK docs; the concept — branch a copy vs continue the original — is the durable, testable part.
| resume | fork | |
|---|---|---|
| Purpose | continue the one true thread | branch a copy to explore an alternative |
| What happens to context | same session, history extended in place | new session id seeded with a copy of history; original untouched |
| When to use | linear work; one outcome you keep | try a risky/alt direction while keeping a fallback |
| When NOT to use | you want to preserve the current state as-is | you actually want the change to land on the main thread |
resume vs summary injection
Both re-establish prior context for a new stretch of work, but they trade fidelity against compactness. Resume restores the actual transcript — every prior turn, verbatim, high fidelity, high token cost. Summary injection means you (or a tool) hand-write a condensed brief of the prior findings and drop it in as fresh context — low token cost, but only as good and as complete as the summary. Resume can't lose a detail it kept; a summary can only carry what its author thought to include.
This is the same fidelity/compactness axis as compaction, but with different authorship and timing: /compact is the tool summarizing to survive the window mid-session; summary injection is a deliberate handoff you craft — often to seed a brand-new session or a subagent with just the distilled conclusions.
| resume (transcript) | summary injection | |
|---|---|---|
| Purpose | restore exact prior context | seed fresh context with a distilled brief |
| What happens to context | full transcript replayed, verbatim | a short hand-written summary added as new input |
| When to use | detail/exact wording matters; audit trail | start a clean/cheap session with just the conclusions |
| When NOT to use | the full history is too large for the window | nuance or exact evidence must survive |
| Cost / fidelity | high tokens, highest fidelity | low tokens, lossy — only carries what you wrote |
Context window vs Memory
The context window is the finite, per-request token budget the model actually attends to — everything in this call: system prompt, history, tool results, the current input. It is bounded and volatile: exceed it and something must be dropped or summarized, and nothing in it persists on its own. Memory is anything deliberately persisted outside the window — files, a scratchpad, a database, an external store — that outlives any single request and can be selectively read back in later.
The relationship is the whole point: memory is durable but the model can't 'think' with it directly; the window is what the model thinks with but it's small and temporary. Useful memory is memory you can retrieve a relevant slice of back into the window when needed — persisting is only half the job.
| context window | memory | |
|---|---|---|
| Purpose | what the model attends to right now | durable store that outlives a request |
| What happens to context | consumed per request; lost when it ends | persists on disk/store until you read it back |
| Lifetime | one request | across requests/sessions, indefinitely |
| When to use | info the model must reason over this turn | facts/artifacts to carry forward or look up later |
| When NOT to use | storing things long-term (it won't survive) | as the thing the model reasons over (must be loaded in first) |
Context window vs Sessions
Easy to blur because a long session feels like one continuous mind. It isn't. A context window is the token budget of a single request. A session is a conversation thread that spans many requests. The bridge between them is the stateless Messages API: the model stores nothing between calls, so a session only continues because the client resends (and persists) the accumulated history on every request. The session is a client-side construct; the window is what one request actually carries.
This is why a session can outgrow the window. Turn after turn, the replayed history gets longer until it no longer fits one request's budget — which is exactly when compaction or summarization has to step in. The session (the full logical thread) and the window (what fits in one call) drift apart, and managing that gap is context management.
| context window | session | |
|---|---|---|
| Purpose | budget for one request | logical thread across many requests |
| Spans | a single API call | many calls over time |
| Persistence | nothing persists after the call (stateless API) | client persists/resends history to continue it |
| What bounds it | a hard token limit | storage + how much history you replay per call |
| When it breaks | history exceeds the token limit | history lost or not resent → thread 'forgets' |
Retry vs Escalation (and error taxonomy)
When something fails, reliable systems ask one question first: is this failure recoverable by trying again? Retry re-attempts an operation that failed for a transient reason — a timeout, a rate limit, a brief network blip — usually with backoff, because the same call may well succeed a moment later. Escalation hands the problem off — typically to a human — when retrying won't help: the error is non-recoverable, the situation is out of policy, or a human decision is explicitly required. Retrying a non-retryable error just burns time and money and can make things worse.
The distinction rests on an error taxonomy. Retryable vs non-retryable: transient/infrastructure failures (timeouts, 429 rate limits, 503) are retryable; deterministic ones (malformed request, 401 auth, 404) are not — they'll fail identically every time. Validation vs business errors: a validation error means the input is malformed or missing required fields (fix the input, don't retry the same payload); a business error means the input is well-formed but violates a rule (insufficient funds, item out of stock) — a policy decision, not a glitch, and often an escalation rather than a retry. Retrying either unchanged is pointless; the fix is correction or handoff.
| retry | escalate | |
|---|---|---|
| Purpose | recover from a temporary glitch | route non-recoverable/out-of-policy cases to a human |
| What happens to context | same operation re-attempted (often with backoff) | context handed off with the failure reason |
| When to use | transient: timeout, 429 rate limit, 503, network blip | non-retryable, policy/business violation, or human requested |
| When NOT to use | validation/auth/business errors — same input, same failure | a clearly transient error a retry would fix |
Key takeaways
- 01The Messages API is stateless — the model remembers nothing between calls; a 'session' exists only because the client resends and persists the accumulated history.
- 02Resume keeps prior context verbatim; compact keeps continuity but summarizes to free window space (lossy); a new session keeps nothing.
- 03Compact is the only session tool that both continues the thread and reclaims context space — that combination is its fingerprint.
- 04Fork branches a session into an independent copy (original untouched); resume extends the one original thread. In the Agent SDK, fork =
resume+forkSession: true— confirm exact names in current docs. - 05Transcript (resume) is high-fidelity and costly; an injected summary is cheap and lossy — choose by whether a lost detail would break the task.
- 06Context window = the finite per-request budget the model reasons over; memory = durable external storage that must be read back into the window to have any effect.
- 07A session spans many requests and can outgrow any single window — which is exactly when compaction has to step in.
- 08Retry only transient/recoverable errors (timeouts, 429, 503) with backoff; escalate non-recoverable, policy/business, or human-required cases — and never retry validation, auth, or business errors unchanged.
- 09This is an unofficial Foundations aid — no real exam items, no invented scaled-score formula; verify version-specific flags in the official docs.
Common mistakes
Starting a new session when the user is just low on context but wants to keep the same task.
Use compact — it preserves the thread and frees space. A new session throws away the context they still need.
Treating an injected summary as equivalent to resuming the real transcript.
A summary is lossy — it carries only what the author wrote. If exact wording or evidence matters, replay the actual transcript (resume).
Assuming writing to a memory file means the model 'knows' it next turn.
The model only attends to the current window. Memory must be explicitly retrieved and injected back in to have any effect.
Believing the API server holds the conversation between calls.
The Messages API is stateless. The client owns, persists, and resends the full history each request — that's what makes a multi-turn session work.
Retrying every error, including bad input, auth failures, or business-rule violations.
Retry only transient/recoverable errors with backoff. Fix validation errors and escalate non-recoverable or policy/business errors instead of looping.
Frequently asked
Resume vs continue — are they different?
Same behavior (reopen a prior session and append), different targeting. In Claude Code, --continue picks the most recent session in the current directory, while --resume targets a specific session by ID. Both restore prior context; confirm exact flags in current docs as they can change.
How is compaction different from just resuming?
Resume restores the prior transcript verbatim (high fidelity). Compaction stays in the same session but replaces older turns with a summary to free token budget — it's lossy by design. Use resume when detail matters; use compact when you're running out of window but must keep going.
Does forking a session copy my files too?
No. Forking branches the conversation into an independent copy with its own session id; the original thread is untouched. It does not sandbox your working tree — a forked and original session can still act on the same files on disk.
Why does a long session eventually hit context limits if the API is stateless?
Because statelessness forces the client to resend the whole accumulated history on every request. Turn after turn that replayed history grows until it no longer fits one request's token budget — which is when compaction or summarization has to intervene.
How do I decide between retrying and escalating?
Ask whether the identical request would succeed on a second try. If the failure was transient (timeout, 429 rate limit, 503, network blip), retry with backoff. If it's non-recoverable (bad input, auth failure), violates a business/policy rule, or explicitly needs a human, escalate — retrying won't change the outcome.
Independent, unofficial study material. Not affiliated with, endorsed by, or authorized by Anthropic. Every example is original and written to teach the public exam objectives — no real exam questions are reproduced. Technical details reflect Claude, the Anthropic API, Claude Code, and MCP as of July 25, 2026; always confirm specifics against current official documentation.
Test yourself
Turn what you just read into answers you can check.