Skip to content
CCAF Preparation

Task Statement 1.7·Domain 127% of exam

Session State and Resumption

Manage session state, resumption, and forking

Jump to practice →

Official Exam Guide Objectives

Task 1.7: Manage session state, resumption, and forking.

Knowledge of

  • Named session resumption using --resume <session-name> to continue a specific prior conversation
  • fork_session for creating independent branches from a shared analysis baseline to explore divergent approaches
  • The importance of informing the agent about changes to previously analyzed files when resuming sessions after code modifications
  • Why starting a new session with a structured summary is more reliable than resuming with stale tool results

Skills in

  • Using --resume with session names to continue named investigation sessions across work sessions
  • Using fork_session to create parallel exploration branches (e.g., comparing two testing strategies or refactoring approaches from a shared codebase analysis)
  • Choosing between session resumption (when prior context is mostly valid) and starting fresh with injected summaries (when prior tool results are stale)
  • Informing a resumed session about specific file changes for targeted re-analysis rather than requiring full re-exploration

What You Need to Know

How an agent picks work back up after a gap is a design decision, not a detail. Anything that runs across several sittings — chasing a bug through a large system, working through a codebase, research spread over days — leaves behind an accumulation: files that were read, conclusions that were drawn, chains of reasoning that led to them. This task statement is about what to do with that accumulation, and there are exactly three answers: carry it forward, split it, or set it aside and rebuild.

Three Session Management Options

Three mechanisms exist across the Agent SDK and Claude Code. They are not interchangeable — each answers a different question about the accumulated state — and the exam presents scenarios that make exactly one of them correct.

Option 1: --resume <session-name>

Resume reopens a named session exactly as it was left, with the full conversation restored — every tool result, every analysis, every chain of reasoning still present.

When to use: What the session already knows is still true. The files it read have not moved on since, and continuing costs less than rebuilding the understanding.

When NOT to use: Files have changed since the session was last active. The tool results sitting in that history now describe a codebase that no longer exists, which produces the stale context problem below.

Option 2: fork_session

Fork takes an existing session as a starting point and splits off an independent line from it. Past the branch point the two sides are unaware of each other: neither observes the other's results and neither is affected by the other's work.

When to use: The expensive groundwork is already done and you want to try more than one direction from it. Having analysed a codebase, fork to weigh two refactoring strategies against each other — both inherit the same understanding and diverge from there.

When NOT to use: You only want to carry on. Fork exists to compare alternatives, so using it for straightforward continuation creates a branch nobody needed. Resume is the continuation tool.

Option 3: Fresh start with summary injection

Open a new session carrying nothing, then seed it with a written summary of what the previous one established. No tool results come across — only the account you chose to write.

When to use: The old tool results have gone stale, because files changed, an API moved, or dependencies shifted. Also where a long session has silted up with results that no longer matter and the context would be better rebuilt than continued.

When NOT to use: The prior context is still accurate and you want the detail in it. Rebuilding by hand what resume restores for free is wasted effort.

The Stale Context Problem

This is the idea the whole task statement turns on. It arises when a session is reopened after the underlying files have moved on, leaving the agent to reason from cached reads that describe code as it used to be.

How it manifests: A developer works with Claude Code on a codebase, changes 3 files, and resumes. The advice that comes back contradicts itself — fixes are recommended for problems already solved, and code is discussed that no longer exists in the file.

Why it happens: Resuming restores everything, and everything includes each file's contents as they were when the tool read them. A file modified since is still represented in history by its old text, and the model reasons across both that record and anything read fresh, with nothing marking which is current.

The naive fix (and why it is insufficient): Resume, then ask the agent to re-read whatever changed. That improves matters without settling them: the outdated results are still in the history, so they remain available to be reasoned from — particularly on side questions where nobody thought to re-read anything.

The correct fix: Begin a new session and inject a structured summary of what was established, naming the files that have changed so those can be re-read deliberately. Nothing stale comes across, and the knowledge does.

Targeted Re-Analysis vs Full Re-Exploration

Changed files do not justify re-examining everything. Re-reading 50 files because 3 of them moved spends the session's budget re-establishing facts that never stopped being true.

The correct approach is targeted re-analysis: name the files that changed and let the agent re-examine only those. Everything else is already covered by the summary carried over from before.

What targeted re-analysis looks like in practice:

  1. Start a fresh session.
  2. Seed it with a written summary that states both halves: what the earlier work established, and which files have moved since — auth.ts, database.ts and api-routes.ts.
  3. Only those three get re-read and re-examined.
  4. The findings from that re-read are merged with the summary covering everything untouched.

It is quicker than starting over and safer than resuming, because the only material in context is either freshly read or deliberately written.

When to Use Each Option: Decision Matrix

ScenarioBest OptionReasoning
Continuing work from yesterday, no files changed--resumeNothing has gone stale, so the full history is an asset
Comparing two refactoring approachesfork_sessionTwo directions wanted from one shared understanding
Resuming after modifying 3 of 50 filesFresh start + summaryThe old contents of those 3 files would still be in history
Long session with cluttered historyFresh start + summaryA curated summary is worth more than accumulated noise
Exploring a testing strategy vs a documentation strategyfork_sessionIndependent lines that should not observe each other
Resuming after dependency updatesFresh start + summaryIndirect changes make it unclear which cached reads survive

Practical Example: The Contradictory Advice Bug

Two days of work across a codebase of 50 files. The first day covers the authentication module and turns up three problems. That evening all three are fixed, which means edits land in auth.ts, session.ts and middleware.ts.

Resuming on Day 2 produces recommendations to fix three issues that no longer exist, because the tool results describing the unfixed code were restored along with everything else. Asked directly about auth.ts, the answers alternate — sometimes describing the old version held in history, sometimes the current version just read — with no signal distinguishing the two.

The fix: start a fresh session with a summary. "Prior analysis identified three authentication issues in auth.ts, session.ts, and middleware.ts. All three have been fixed. Please re-analyse these three files to verify the fixes and check for any new issues introduced by the changes."

Nothing outdated exists in the new session to be reasoned from. The agent reads the files as they now stand, confirms the fixes, and gives advice that stays consistent because there is only one version of the truth in context.

Deep Dive

Where sessions actually live, and why resume can silently "fail"

A session is defined precisely: "the conversation history the SDK accumulates while your agent works. It contains your prompt, every tool call the agent made, every tool result, and every response. The SDK writes it to disk automatically so you can return to it later." Transcripts are stored as JSONL under a path keyed on the working directory: "sessions are stored under ~/.claude/projects/<encoded-cwd>/*.jsonl ... where <encoded-cwd> is the absolute working directory with every non-alphanumeric character replaced by -." This is documented as "the most common cause of resume returning a fresh session" — if you resume from a different working directory than the one the session was created in, the encoded path doesn't match and there's nothing to find.

Sourcecode.claude.com › sessionsfetched 2026-07-30

What a resumed session restores — the full list, and the two exceptions

Resume restores more than just messages: "conversation history: the full history, including tool calls and results" plus model, agent, permission mode, goals, and unexpired scheduled tasks. But permission mode has a documented carve-out: "permission mode: the mode the session was in. plan and bypassPermissions are never restored." A session that was in plan mode or bypassPermissions mode when it ended comes back in a different (safer) mode on resume — one more reason a resumed session's behaviour is not always identical to where you left it, beyond just stale tool results.

Sourcecode.claude.com › sessionsfetched 2026-07-30

Continue vs resume — the practical difference for automation

The two "keep working" options track state differently. The SDK sessions guide puts it plainly: "Continue finds the most recent session in the current directory. You don't track anything. ... Resume takes a specific session ID. You track the ID." The headless docs give the CLI form: "use --continue to continue the most recent conversation, or --resume with a session ID to continue a specific conversation." For a single interactive workflow, --continue is the low-friction choice. For scripted or multi-conversation automation, the docs recommend explicitly capturing the ID: "if you're running multiple conversations, capture the session ID to resume a specific one," typically via --output-format json and reading the session_id field from the result. That ID lookup is scoped to where you ran the command: "session ID lookup is scoped to the current project directory and its git worktrees," so a resume command run from a different directory than the original session won't find it.

Sourcescode.claude.com › headlesscode.claude.com › sessionsfetched 2026-07-30

Fork semantics, precisely

Forking is not a variant of resume — it is resume plus a divergence point. The SDK sessions guide: "forking creates a new session that starts with a copy of the original's history but diverges from that point. The fork gets its own session ID; the original's ID and history stay unchanged. You end up with two independent sessions you can resume separately." The Claude Code sessions doc says the same thing about /branch: "branching creates a copy of the conversation so far and switches you into it, leaving the original intact." Practically, "sessions created with /branch or --fork-session get their own session IDs and appear as separate rows" in the session picker — they are first-class, independently resumable sessions from the moment they're created, not temporary branches of the parent.

Sourcescode.claude.com › sessionscode.claude.com › sessionsfetched 2026-07-30

Sessions persist conversation, not files — checkpointing is the separate mechanism

A session captures conversation state only: "sessions persist the conversation, not the filesystem. To snapshot and revert file changes the agent made, use file checkpointing." Checkpointing runs on a different cadence — with checkpointing enabled, "each user message in the response stream has a UUID that serves as a checkpoint" — and has its own blind spot: "only changes made through the Write, Edit, and NotebookEdit tools are tracked. Changes made through Bash commands (like echo > file.txt or sed -i) are not captured by the checkpoint system," and neither are edits a subagent applies. This matters for the stale-context problem: even if you could perfectly "undo" file changes with /rewind, resuming the conversation afterward still carries whatever stale tool results were already in history — checkpointing reverts code, not what the model believes about the code. The checkpointing docs make the same point from the other side: "file rewinding restores files on disk to a previous state. It does not rewind the conversation itself."

Sourcescode.claude.com › sessionscode.claude.com › file-checkpointingfetched 2026-07-30

Capturing a session ID headlessly, for the resume-vs-fresh-summary decision

In scripted/CI usage, the documented pattern for tracking a session to resume later is to read its ID straight out of the JSON result: session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id'). This is the concrete mechanism behind choosing resume over fresh-start-with-summary in an automated pipeline — the script has to explicitly decide, per run, whether to pass that captured session_id to --resume (prior context still valid) or to start a new session with an injected summary (prior tool results are stale), exactly the decision rule from this lesson's "Three Session Management Options."

Sourcecode.claude.com › headlessfetched 2026-07-30

Quick Reference

FactValue
Session storage path~/.claude/projects/<encoded-cwd>/*.jsonl (cwd with non-alphanumerics replaced by -)
Most common cause of resume returning a fresh sessionRunning resume from a different working directory than where the session was created
What resume restoresFull conversation history (tool calls + results), model, agent, permission mode, goals, unexpired scheduled tasks
Permission modes NEVER restored on resumeplan, bypassPermissions
--continueFinds most recent session in current directory; no ID tracking needed
--resume <id|name>Requires a specific session ID or name; you must track it
Session ID lookup scopeCurrent project directory and its git worktrees
Capturing a session ID in scriptsclaude -p "..." --output-format json | jq -r '.session_id'
Fork mechanicsNew session gets its own ID; copies history up to the fork point; original's ID and history stay unchanged
Forked session visibilityAppears as a separate row in the session picker, independently resumable
What sessions persistConversation only — not the filesystem
What reverts file changesCheckpointing (separate mechanism), not sessions
Checkpoint cadenceOne checkpoint per user prompt
Checkpointing blind spotDoes not track changes made via Bash commands, only Claude's own file-editing tools

Exam Traps

Practice Scenario

A developer resumes a Claude Code session after modifying 3 files in a 50-file codebase. The agent gives contradictory advice about the modified files — recommending changes that were already made and referencing code that no longer exists. What is the most appropriate approach?

Build Exercise

Implement Session Management Strategies

Difficulty: Intermediate (2/4)

45 minutes

  1. Create a Claude Code session that analyses a 10-file codebase and name it with --name for later resumption

Why: Named sessions resumed with --resume enable continuation of work across breaks. The exam tests when resume is appropriate (no files changed) versus when it creates the stale context problem (files have been modified since the last session).

You should see: A named Claude Code session that reads and analyses 10 source files. The session name should be memorable for later resumption. The agent should produce findings about each file.

  1. Record the key findings from the initial analysis as a structured summary (file names, issues found, recommendations)

Why: This structured summary is the knowledge you will inject into the fresh session later. The exam tests whether you preserve prior findings without carrying stale tool results. A good summary captures conclusions without raw tool output.

You should see: A structured document listing each file name, the issues found in it, severity ratings, and specific recommendations. This should be concise enough to inject into a prompt but complete enough to preserve all key findings.

  1. Modify 3 files in the codebase to fix some of the identified issues

Why: Modifying files after a session creates the conditions for stale context. The old file contents remain as tool results in the session history while the actual files now contain different code. This is the exact scenario that triggers the contradictory advice bug.

You should see: Three files modified with fixes for the issues identified in the initial analysis. The changes should be substantive enough that the old and new versions would produce different analysis results.

  1. Attempt to resume the session with --resume and observe any stale context issues (contradictory advice, references to old code)

Why: This demonstrates the stale context problem. The resumed session contains old tool results showing the unfixed code. The agent may recommend fixing issues that are already fixed, or give contradictory advice by referencing both old and new file contents.

You should see: The agent giving contradictory advice: recommending fixes for issues already resolved, referencing code that no longer exists, or providing inconsistent guidance about the modified files. These are the hallmarks of stale context.

  1. Start a fresh session with the structured summary injected into the initial prompt, specifying the 3 changed files for targeted re-analysis

Why: Fresh start with summary injection is the correct approach when files have changed. The exam specifically tests this: no stale tool results, preserved knowledge from the prior session, and targeted re-analysis of only the changed files instead of wasteful full re-exploration.

You should see: A clean session that knows about the prior findings (from the injected summary), targets only the 3 changed files for re-analysis, and produces consistent advice without contradictions.

  1. Compare the quality and consistency of advice between the stale resume and the fresh start with targeted re-analysis

Why: This comparison demonstrates why the exam favours fresh start with summary injection over naive resume after file changes. The fresh start produces consistent, accurate advice while the resume produces contradictions from stale context.

You should see: A clear quality difference: the resume session gives contradictory or outdated advice about the modified files, while the fresh session gives accurate, consistent analysis based on the current file contents.

Sources


Appendix A — Build Exercise Step Hints

Progressive hints revealed by the "Stuck? Get a nudge" control on each step.

Step 1. Create a Claude Code session that analyses a 10-file codebase and name it with --name for later resumption

Why: Named sessions resumed with --resume enable continuation of work across breaks. The exam tests when resume is appropriate (no files changed) versus when it creates the stale context problem (files have been modified since the last session).

You should see: A named Claude Code session that reads and analyses 10 source files. The session name should be memorable for later resumption. The agent should produce findings about each file.

Stuck? Get a nudge

Step 2. Record the key findings from the initial analysis as a structured summary (file names, issues found, recommendations)

Why: This structured summary is the knowledge you will inject into the fresh session later. The exam tests whether you preserve prior findings without carrying stale tool results. A good summary captures conclusions without raw tool output.

You should see: A structured document listing each file name, the issues found in it, severity ratings, and specific recommendations. This should be concise enough to inject into a prompt but complete enough to preserve all key findings.

Stuck? Get a nudge

Step 3. Modify 3 files in the codebase to fix some of the identified issues

Why: Modifying files after a session creates the conditions for stale context. The old file contents remain as tool results in the session history while the actual files now contain different code. This is the exact scenario that triggers the contradictory advice bug.

You should see: Three files modified with fixes for the issues identified in the initial analysis. The changes should be substantive enough that the old and new versions would produce different analysis results.

Stuck? Get a nudge

Step 4. Attempt to resume the session with --resume and observe any stale context issues (contradictory advice, references to old code)

Why: This demonstrates the stale context problem. The resumed session contains old tool results showing the unfixed code. The agent may recommend fixing issues that are already fixed, or give contradictory advice by referencing both old and new file contents.

You should see: The agent giving contradictory advice: recommending fixes for issues already resolved, referencing code that no longer exists, or providing inconsistent guidance about the modified files. These are the hallmarks of stale context.

Stuck? Get a nudge

Step 5. Start a fresh session with the structured summary injected into the initial prompt, specifying the 3 changed files for targeted re-analysis

Why: Fresh start with summary injection is the correct approach when files have changed. The exam specifically tests this: no stale tool results, preserved knowledge from the prior session, and targeted re-analysis of only the changed files instead of wasteful full re-exploration.

You should see: A clean session that knows about the prior findings (from the injected summary), targets only the 3 changed files for re-analysis, and produces consistent advice without contradictions.

Stuck? Get a nudge

Step 6. Compare the quality and consistency of advice between the stale resume and the fresh start with targeted re-analysis

Why: This comparison demonstrates why the exam favours fresh start with summary injection over naive resume after file changes. The fresh start produces consistent, accurate advice while the resume produces contradictions from stale context.

You should see: A clear quality difference: the resume session gives contradictory or outdated advice about the modified files, while the fresh session gives accurate, consistent analysis based on the current file contents.

Stuck? Get a nudge

Appendix B — Interactive Study Prompts

Two prompts to paste into Claude. B1 drills the judgement the exam actually measures; B3 reviews the work you did for the Build Exercise above. The exam simulator between them is the interactive quiz on this page.

B1. Concept Check — Discrimination Drill

Prompt — paste into Claude

You are examining me for the Claude Certified Architect – Foundations (CCAR-F) exam, Domain 1: Agentic Architecture & Orchestration (27% of the exam), Task Statement 1.7: Session State and Resumption. Use British English throughout.

What this exam actually measures. Not one item on the official exam asks what something is. Every item drops you into a production system that is already misbehaving, offers four defensible engineering responses, and asks which is best. The skill being tested is proportionality: fix the root cause with the cheapest instrument that gives the guarantee the situation demands. So do not quiz me on definitions. Make me choose between options that are both defensible, then attack whatever I chose.

How to run this session.

  • One question at a time. Stop and wait. Never answer your own question, and never move on until I have committed.
  • Never reveal which option is right before I commit to one.
  • Do not praise me. A correct answer earns "Yes" and the next question. If I am right for the wrong reason, say so — that is the failure that costs marks on exam day.
  • When I am wrong, quote the exact phrase in my answer that gave it away, correct it in one sentence, and move on. One correction at a time.
  • If I write something fluent but empty, name it: "That is a restatement, not a reason."
  • Set every scenario inside one of the exam's production contexts: the Customer Support Resolution Agent (Agent SDK, MCP tools get_customer, lookup_order, process_refund, escalate_to_human), the Multi-Agent Research System (a coordinator delegating to web-search, document-analysis, synthesis and report-generation subagents), or Developer Productivity with Claude (an agent over an unfamiliar codebase using Read, Write, Bash, Grep, Glob).

Session plan — about twelve questions.

Round 1 — Anchor (1 question). One concrete question to check I have actually read the material. If I cannot answer it, stop the session and tell me to read the lesson before continuing.

Round 2 — Discrimination (5 questions). Each one: describe a symptom in one of the contexts above, with a number or a log observation in it. Offer exactly two responses, both defensible. Ask me to pick one and justify it in a single sentence. Then argue the case for the option I rejected as strongly as you can, and ask whether I am holding or changing my answer. Only after I answer that, tell me which is right and why the other one is the more tempting trap.

Round 3 — Proportionality (2 questions). Take one symptom and run it twice with different stakes: once where the cost of an error is a wasted retry, once where it is an incorrect refund or a corrupted production branch. The right answer must change between the two. If I answer the same way both times without noticing the stakes moved, that is the finding — tell me.

Round 4 — Code review (3 questions). Present a colleague's confident proposal containing one of the trap errors listed below, written the way a teammate would write it in a pull request. Ask me what is wrong with it. Do not signal that anything is wrong.

Round 5 — Verdict. Rate me green, amber or red on each concept below. Name the single weakness most likely to cost me marks, and give me one specific next action: a section of this lesson to re-read, or a step of the Build Exercise to redo. If I am not ready for this task statement, say so plainly.

Concepts in scope

  1. --resume <session-name> — continues one specific named session with the whole conversation history restored, tool calls and tool results included; the right choice when the prior context is still valid and the files have not moved underneath it.
  2. fork_session — branches to a new session ID from a copy of the history so two approaches can be explored independently; the original's ID and history stay untouched, and neither branch can see the other's work.
  3. Fresh start with summary injection — a new session carrying a curated summary of the prior findings and none of the prior tool results; the right choice when those results have gone stale or a long session's history has degraded.
  4. The stale context problem — resuming after code changes restores the old file contents as tool results, so the agent reasons from them and produces contradictory advice: recommending fixes already applied, citing code that no longer exists.
  5. Targeted re-analysis — name the specific files that changed so the agent re-reads only those and lets the summary carry everything that did not; sending it back over the whole codebase is waste, not thoroughness.

Trap errors to plant in Round 4

  • Sending the agent back over all fifty files when three of them changed.
  • Recommending a resume after files have been modified, leaving the stale tool results sitting in history to be reasoned from.
  • Treating forking and resuming as interchangeable rather than one for divergence and one for continuation.
  • Forking a session to escape stale context, when the fork copies that stale history along with everything else.

Stay inside the material above. If I raise something outside it, tell me it is out of scope for this task statement and return to the drill. Begin with Round 1.

B2. Exam Simulator

Exam simulator

Question 1 of 10

Scenario · Developer Productivity with Claude

You resume yesterday's session after fixing three of the fifty files it analysed. The agent recommends changes you made last night and quotes a function you deleted. What's the most effective way to get it working from the current state of the code?

B3. Build Coach — Code Review

The Build Exercise and its hint ladder are already on this page. This prompt is for the one thing the page cannot do: review what you actually ran and what came back.

Prompt — paste into Claude

You are a staff engineer reviewing my work on a build exercise for the Claude Certified Architect – Foundations exam, Domain 1, Task Statement 1.7: Session State and Resumption. This exercise produces session commands, a written summary and two sets of agent output rather than a program, so review those artefacts as you would review code. Use British English throughout.

I am building a side-by-side comparison of session management strategies: a named session that analyses a ten-file codebase, a structured summary of what it found, three files modified afterwards, a resumed run that exhibits stale context, and a fresh run carrying the summary plus the list of changed files for targeted re-analysis — with the two runs compared against each other.

It has to satisfy all of the following:

  • The initial analysis runs in a named session and produces per-file findings for all ten files.
  • The summary records conclusions, severities and recommendations, and carries no raw file contents.
  • Three files change substantively enough that the old and new analyses would genuinely differ.
  • The resumed run shows at least one stale-context symptom, quoted from its actual output rather than asserted.
  • The fresh run knows the prior findings from the summary alone and re-reads only the three changed files.
  • The comparison names the specific differences in the advice, not just a verdict that one run was better.

How to review.

  • Ask me to paste my commands, my summary and both runs' output. If I have not pasted any, ask for them and nothing else. Do not do the exercise for me, do not offer a reference solution, and do not fill in a step I have skipped.
  • Work through the criteria above in order. For each one, quote the line of my artefacts that satisfies it, or say plainly that nothing does.
  • Then hunt for the failure modes below. Each is a real production bug, not a style preference.
  • Rank everything you find: (1) would fail in production, (2) would lose marks on the exam, (3) style. Give me the first item under (1) and then stop — wait for my fix before giving me the next one.
  • If my work satisfies everything, do not congratulate me. Change the requirements — the three changed files also changed a public interface that two unchanged files call — and make me say what the summary now has to carry.
  • If I ask you to just do it for me, refuse once and give me the smallest nudge that would unblock me instead.

Failure modes to probe

  • A "summary" that is really a paste of the old tool results, which carries the stale context straight into the session that was supposed to be free of it.
  • A fresh prompt that names the changed files without stating what the prior analysis concluded, so the agent re-explores the whole codebase anyway.
  • A resume run from a different working directory that quietly starts an empty session, with the missing history then misread as evidence about stale context.
  • A "fresh" run that is actually a fork of the original, inheriting the stale tool results it was meant to leave behind.
  • A comparison that asserts the resume contradicted itself without a quoted line showing it, which makes the finding impossible to check.

Start by asking me for my commands, my summary and both runs' output.