Skip to content
Claude Certified Architect – Foundations (CCAR-F) Exam Prep

Lesson 7 of 30 · 6 min

x
7/30

Session State and Resumption

Video lesson: CCAR-F 07/30: Session State and Resumption

What a session is

The conversation history the SDK accumulates: your prompt, every tool call, every result, every response. It is written to disk automatically. Sessions persist the conversation, not the filesystem.

Continue, resume, fork

WantUse
One-shot taskNothing extra
Multi-turn chat in one processClaudeSDKClient (Python) or continue: true (TypeScript)
Pick up the most recent session in the directorycontinue_conversation=True / continue: true
Return to a specific sessionCapture session_id, pass it to resume
Try an alternative without losing the originalFork: fork_session=True / forkSession: true together with resume
Nothing written to diskpersistSession: false (TypeScript)
  • Resume needs the ID; the ID comes from the session_id on the result message.
  • Fork creates a new session with a copy of the history; the original is unchanged; the fork gets its own ID.
  • Resuming is also how you recover after a limit such as error_max_turns or error_max_budget_usd: resume with a higher limit.
  • Transcripts live under ~/.claude/projects/<encoded-cwd>/*.jsonl on that machine.

Files can change under you (verified boundary, practical guidance)

Because a session stores the conversation, not files, earlier file reads inside it can be out of date if the files changed. Forking branches the conversation only; edits a forked agent makes are real files visible to every session in that directory. To snapshot and revert file changes, use file checkpointing. Practical rule: after resuming, tell the agent what changed or have it re-read the files that matter.

Resuming elsewhere

Session files are local. For CI workers, containers or serverless: use a session store adapter, move the .jsonl file, or (often most robust) save the results you need as application state and pass them into a fresh session's prompt.

Resuming a subagent

A completed subagent's result includes agentId: <id>. Resume the same session with resume: sessionId and mention the agent ID in the prompt; pass the same agents definition again. Built-in Explore and Plan agents are one-shot and return no agentId.

Exam traps

  • Using continue when several users or sessions exist. Use resume with a tracked ID.
  • Forking to "undo" file edits. It does not touch files.
  • Assuming a resumed session sees current file contents.
  • Expecting to resume on another machine with no transfer or store.

References

  1. Work with sessions — checked Oct 16, 2026
  2. Subagents in the SDK — checked Oct 16, 2026

Check your understanding

  • Try OAuth2 without losing the JWT thread: which option?Show answer

    Answer

    Fork: resume plus fork_session; resume the original later for JWT.
  • A run ended with error_max_turns. How do you continue?Show answer

    Answer

    Resume the session with a higher limit.
  • Does a fork revert file edits?Show answer

    Answer

    No; use file checkpointing.
Previous

Progress is saved in this browser.

Next Lesson