Skip to main content
Create several ephemeral branches from one commit when you want multiple agents to solve the same task. Each branch starts from the same files without a repository copy. This guide uses the session branch from Store Session State.

Pin the start state

Read the current tip SHA from your backend session record. Use the same SHA for every attempt.

Create the attempt branches

Create each attempt from the same SHA. Branch creation writes refs only and does not copy Git objects.
Give each sandbox one branch and one credential. Use expectedHeadSha: baseSha for its first commit, then use each returned commit SHA for the next write.

Compare the results

Read each attempt tip as a commit diff from the pinned start state. Evaluate each diff with tests, code review, or your own evaluation method.
See getCommitDiff() for path filters and response fields.

Promote the winner

Promote the best ephemeral branch to a normal branch. You can then review and merge the normal branch.
Delete the other refs after you no longer need their states.
Deletion removes the refs. Git objects remain available while another ref can reach them. See Ephemeral Namespace for promotion details and Ref Policies for per-attempt credentials.