OpenProgram Docs

Branch collaboration

A branch is a (session_id, head_id) pair, the same within a session and across sessions. Branching is not a special operation: checkout moves HEAD, and the next user turn becomes a sibling.

ModeEntryWhat is writtenIn the DAG
Messaging: A delivers into Bsend_message(message, to)A turn on B's tip; a busy target queues it in the inboxDotted 1 5 line, target branch colour, shown on hover; no effect on lanes or depth
Dispatch: B works for A and reports backagent(prompt, ...)Sub-branch B, plus an attach pointer in A at the spawning nodeSpawn edge from the task node to B's root; B is its own lane, starting one column right of A's rightmost
Merge: branches converge/merge or WebSocket action merge_branchesOne attach pointer per peer, one merge assistant node, a multi-parent commitDouble ring, the only convergence shape, in the base branch's lane; convergence lines drawn, attach pointers not

Line styles, colours and shapes: DAG rendering section 3; scenarios 8 (merge), 9 (messaging), 10 (dispatch). Addressing, delivery and limits: Agent collaboration.

Merge

Syntax
/merge sid_a sid_b:head_b: message; a * before a peer makes it the base
Without a base
Peers are equal; the merge produces a new tip
With a base
The other peers are supplemental context and the reply continues the base; the multi-peer form of dispatch
Omitted head_id
That session's current HEAD
NodeFields
Merge noderole=assistant, synthesized from each branch's output
Attach pointer, one per peerfunction=attach, predecessor=target_head, attach.session_id, attach.head_id=peer tip, attach.is_base, attach.merge_temp
Commitcommit_parents = [target prior commit, *peer commit ids]

Attach is the embedding primitive: one branch's content enters another point as a pointer. A worktree merge is unrelated: a git fast-forward of files, by worktree_merge.

Code
ItemLocation
Merge engineopenprogram/runtime/conversation/peer_agents/merge.py process_merge_turn
WebSocket actionopenprogram/interfaces/server/ws_actions/merge.py
Slash commandopenprogram/runtime/conversation/turn_runtime/slash_actions.py
Attach parsingopenprogram/state/store/session/graph/branches.py _attach_info
DAG edges and shapesapps/web/lib/runtime-bridge/dag/render/edges.ts, shapes.ts
Merge node laneopenprogram/state/store/session/graph/layout/lane.py
Check a graphscripts/maintenance/dag_dump.py

Switch, start again, rewind

OperationWhat it createsWhile a branch runs
Switch to an existing branchNothing; the view and the head move to that branch's tipAlways allowed
Start again from an old point: edit and resend, retry, send from a message selected in the graphA new branch beside the original, with its own record (branch_identity of the new message). Both stay and both can run. A retry of a prompt that never got a reply reruns that prompt instead. A retry of a turn whose reply is only an error (nothing written, no tool run) takes that turn's place: the failed turn is removed once the new one is written: a branch per failed attempt holds nothing to go back toAllowed from any point while other branches run; waits while the selected branch's own turn runs
A turn that continues its branch: a message, a Goal continuation, a background-command notice, a sub-agent's returnNothing, whichever branch is selected. Its messages go under its branch's tip and that branch's record follows them (follow_line while it is selected; point_branch for the prompt and carry_branch for the reply while it is not, leaving the head and the selection alone). A turn that ends after a later turn was written under its reply leaves the head on the later one (behind_selected_tip)Always; two runtime turns on one branch follow one another on its line
RewindNothing. The tail of the current branch is retracted in place: same branch id, name, settings and usage; the tip moves back before the chosen prompt, which returns to the composerRefused while that branch runs; one that changes files, while any branch runs

The DAG is append-only, so a rewind deletes nothing. It lists the retracted nodes in the session meta (rewind_hidden_nodes; the old tip in rewind_hidden_heads), written in the head's compare-and-set by rewind_view.view_update. Every reader skips them:

  • transcript, message reads and search;
  • branch list and version counts, so a message sent after a rewind continues the branch instead of adding a version;
  • the request's context, which walks back from the tip;
  • compaction: a summary of retracted turns is retracted too, and the summary before it applies again (active_summary_for_chain skips the graph's retracted set);
  • the context-commit timeline.

Undo and Redo of a rewind take the nodes off and back on the list. A switch to a retracted tip is refused and points to Undo. Conversations whose earlier rewinds left an extra branch keep it; nothing is migrated. File restoration: File management.

Only a message that names an earlier point (branch_from) makes a branch. Conversations saved while each runtime turn on an unselected branch was recorded as its own branch keep those records; nothing is migrated.

  • The branch list marks them runtime_started: every prompt on the branch's own part was written by the runtime, or the part holds only reports (report_…) posted where the head stood.
  • A part whose prompts all came from the scheduler is marked scheduled_task, like a task's own branch: its runs are the task's.
  • The Activity panel gives them no row.
  • Their Goal moves onto the line of its last turn at its next continuation.

Peers agree that a rewind removes recent turns from the current line rather than starting a new one. Claude Code's /rewind slices the conversation in place and gives the prompt back; forking copies the session. Codex writes ThreadRolledBack with a turn count; the turns stay in the rollout file, leave the history and cannot anchor a fork.

The retracted list plays the part of Codex's rollback marker and keeps an Undo, which neither peer has in-session. Starting again stays a separate operation, so a person never loses the original by rewinding, and never gets a stray version by retracting.

Work that belongs to a branch

Work started on a branch keeps acting on it after the person selects another:

  • A Goal records the branch it was started on (branch_id). Its check-ins and verification continue and read that branch; a turn on another branch gets neither its instructions nor its accounting. A Goal saved before this follows the selected branch.
  • A Goal stays on the line of its last turn (follow_last_turn, before each continuation). When that turn's reply is not on its branch's line (the person started the turn again from an old point), the Goal takes the branch whose line holds the reply, the selected one first; its tasks and steps go with it (carry_board).
  • /merge and merge_branches write the reply to the branch they started on (target_branch_id) and move the head only while that branch is still selected.
  • A send_message queued for a busy conversation continues the branch it addressed, from that branch's tip.

Implementation status

StateItems
ImplementedFork and checkout; merge backend and /merge; attach; spawn and attach edges; send_message; agent dispatch with report back; worktree merge
Not yetThe messaging line: send_message writes no source-branch metadata for the renderer to read. A graphical merge dialog: the web client only reports merge_branches failures.
OpenWhether a send-several-then-merge workflow is needed; whether auto-merge needs confirmation
Last updated · 2026-11-25