Lv.1 0 XP

fork_session — Branching Agent Execution from a Shared Baseline

Core 7 min +30 XP
💡
THE ANALOGY

Save states in a video game. You reach a decision point, save your progress, then explore two different paths — knowing you can compare the outcomes. fork_session is that save state for your agent — same starting context, different execution paths from that point.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Confusing fork_session with spawning independent subagents. fork_session creates branches from a shared baseline that have read access to the parent's context at the fork point. Independent Task subagents start completely blank.

KEY POINTS
1 fork_session creates a branch from the current conversation state — the branch inherits the conversation history up to the fork point.
2 Branches are independent after forking — changes in one branch don't affect others.
3 Primary use case: comparing two approaches to the same problem from a shared analysis baseline (e.g., two refactoring strategies after shared codebase exploration).
4 fork_session is distinct from spawning an independent subagent — forks have parent context, subagents start blank.
5 Changes to files or external state in one branch DO affect the shared environment — fork_session isolates conversation context, not external side effects.