Skip to content

Feature: Fork existing agent sessions (context branching) #2026

Description

@slashdevcorpse

Feature Request: Fork Existing Agent Sessions

Summary

Add the ability to fork (branch) an existing agent session — creating a new parallel session that inherits the full conversation context up to the fork point, then diverges independently. Think "right-click → Fork" on any active or completed agent session.

Motivation

Orca already excels at parallel agent orchestration via git worktrees, but currently there's no way to branch an existing conversation context. Common scenarios where this is needed:

  1. Exploring alternatives — An agent is halfway through implementing auth with JWT; you want to fork and try OAuth2 without losing the JWT progress
  2. Splitting a complex task — An agent has built up rich context about a codebase; you want to fork that context into multiple specialized subtasks
  3. Recovering from dead ends — An agent went down a wrong path; fork from an earlier point rather than starting fresh
  4. Review + iterate — Fork a completed session to ask follow-up questions or request changes without polluting the original

Proposed Implementation

Since Orca is agent-agnostic and wraps CLI agents via PTY, forking could work at multiple levels:

Level 1: Orca-native context fork (indirect)

  • Serialize the terminal scrollback/conversation history of the source session
  • Create a new worktree (or reuse current)
  • Launch a new agent session, injecting the serialized context as initial prompt/context file
  • This works with ANY agent CLI — it's passing context through Orca's orchestration layer

Level 2: Agent-native fork passthrough

  • For agents that support forking natively, Orca could invoke the agent's fork mechanism directly
  • Map Orca's fork action → agent-specific fork command

Level 3: Full fork (folder-mode projects / no git)

  • For workspaces or directories without a git repo, forking creates a copy-on-write directory clone (cp --reflink on APFS/btrfs, full copy fallback)
  • Respect .orcaignore or .gitignore patterns to skip node_modules, build artifacts, etc.
  • Register the copied directory as a new folder-mode project linked to the parent
  • orca fork rm removes the copy and deregisters the project

orca fork CLI Command

orca fork [--message <uuid>] [--terminal <handle>] [--name <label>] [--activate] [--no-copy-files]
orca fork list [--worktree <selector>] [--json]
orca fork show <fork-id>
orca fork diff <fork-id-a> <fork-id-b>
orca fork rm <fork-id>

Flags:

  • --message <uuid> — Fork agent session at this specific message/checkpoint (truncates after this point). Without this, forks from current end of session.
  • --terminal <handle> — Which agent terminal's session to fork. Defaults to active terminal.
  • --name <label> — Label for the fork. Used as branch name suffix (git) or directory suffix (folder-mode).
  • --activate — Switch the UI to the forked worktree/project immediately.
  • --no-copy-files — Fork only the agent session, not the workspace files. Useful for retrying a prompt without duplicating the directory.

Examples:

# Fork from current state
orca fork --name "try-redis-approach"

# Fork from a specific message in the agent conversation
orca fork --message msg_a1b2c3d4 --name "before-refactor"

# List forks of current worktree
orca fork list

UX Mockup

Sidebar:
├── 🟢 auth-feature (main session)
│   ├── 🟡 auth-feature/fork-1 (trying OAuth2)
│   └── ⚪ auth-feature/fork-2 (trying Passport.js)
├── 🟢 api-refactor

Right-click context menu on any session → "Fork from here" → pick a message/checkpoint as the fork point.

Non-Git Workspace Support

For projects without a .git directory, forking still works:

$ pwd
/home/user/scratch/prototype

$ orca fork --name "approach-b"
Forked: approach-b
  Session: forked at current state
  Path:    /home/user/scratch/prototype-approach-b
  Copy:    reflink (instant)

The directory is cloned (CoW where supported), registered as a linked project, and appears in the sidebar with fork lineage.

Relationship to Existing Features

Benefits

  • Zero-cost exploration of alternative approaches
  • Preserves valuable built-up context instead of starting fresh
  • Enables tree-of-thought workflows at the agent level
  • Works with Orca's agent-agnostic philosophy (Level 1 works with any CLI agent)
  • Works on any workspace — git repos and plain directories alike
  • Natural extension of the worktree mental model (worktrees fork files; this forks conversations)

Activity

  1. AmethystLiang commented on May 18, 2026

    @AmethystLiang
    Contributor

    sounds useful.
    @brennanb2025 can look into this

  2. mmarabel commented on May 30, 2026

    @mmarabel
    Contributor

    +1 on this, I've tested a few other apps like Conductor which has something similar and it's very useful.

    It also allows you to copy a summary of the context to pass into another chat:

    Image

    Here's how the forking looks:

    Image
  3. AmethystLiang commented on May 30, 2026

    @AmethystLiang
    Contributor

    @slashdevcorpse @gatsby74 adding it now :-D

  4. AmethystLiang commented on May 31, 2026

    @AmethystLiang
    Contributor

    Added forking to a new worktree in #3976.

    will revisit the rest of the proposal here later (maybe there is nothing outstanding)

  5. added
    size/l
    on Jun 10, 2026
  6. added
    enhancement
    on Jun 25, 2026
  7. added theissue type on Jul 12, 2026
  8. nwparker commented on Aug 23, 2026

    @nwparker
    Contributor

    Closing because agent-session forking shipped in PR #3976.
    Disagree? Please respond! I will re-visit this ticket in 5 days. If you respond, I will re-open it 🙏.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementsize/l

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions