rebase_worktree

Move an agent's branch onto the latest commit of its base, rewriting the branch in the checkout it sits in.

Agentwritesnot idempotentdestructiveMCP tool

Reach for this when an agent's worktree has fallen behind the base and its work has to sit on top of what has landed since, rather than driving git by hand: komrad knows which base the agent's workflow cuts from, fetches it, parks the whole checkout at a ref of its own first so nothing is lost, replays from a cutoff when the base already holds part of the branch, and mails the agent to say its files moved under it. Read plan_rebase first, since this rewrites history and no pull request opened from the branch tracks the work afterwards. You cannot rebase the checkout you are working in, which is refused as invalid_argument and covers your own worktree and, if you are a child, your parent's. An agent komrad cannot see to be at rest is refused as failed_precondition, which covers one part-way through a turn, one still being set up, and one whose pane could not be read at all. A turn that began since its pane was last read is cut, and nothing moves until the pane says the agent has stopped, so one that will not stop is refused too. It is refused the same way for an agent that is held, archived, on a branch komrad did not cut, holding uncommitted tracked changes, or already part-way through a merge or a rebase. A rebase that hits conflicts stops part-way and is left for that agent to settle, which the response says rather than failing.

Calling it#

curl -X POST http://127.0.0.1:8787/agent.v1.AgentService/RebaseWorktree \
  -H 'Content-Type: application/json' \
  -d '{
  "agentId": "<agentId>"
}'

Request#

RebaseWorktreeRequest#

FieldTypeDescription
agentIdstring

Whose branch to move onto its base.

required

Response#

RebaseWorktreeResponse#

FieldTypeDescription
baseRefstring

The ref the branch was moved onto.

baseShastring

The commit that ref named when it was read.

commitsint32

How many of the agent's own commits the rebase carried.

branchstring

Which branch moved.

conflictedbool

Whether the rebase stopped on conflicts and is still stopped, waiting for the agent.

movedbool

Whether the branch reached the base without replaying anything, which is what a branch whose work has entirely landed gets.

landedCommitsint32

How many of the agent's own commits the base already held, and how many were replayed.

replayCommitsint32

How many were replayed onto the new base.