Skip to content
BENIBIX Learn

forkSession Option

Also known as forkSession, fork_session, Agent SDK fork, Claude Agent SDK forkSession

The option that starts a copy of an old session, with a new ID. The first one stays as it was.

Think of it like

It is like a copy you make to try a new idea.

Example

Leo wants to try two fixes from the same point. He forks the session twice and lets each branch try one.

Why it matters

You can try a risky path without losing the chat you had.

Definition

forkSession is the Agent SDK option that, used with resume, starts a new session from a copy of the old one. In Python it is fork_session. The copy gets its own session ID, and the original stays as it was. It branches the chat, not the files. Edits the fork makes on disk are real and shared with any session in that folder.

Common mistake

Thinking a fork protects the files. It copies the chat only; use checkpoints for files.

Key takeaways

  1. 1
    Use with resume. Then fork.
  2. 2
    New session ID. Original kept.
  3. 3
    Chat only. Not files.

Compare