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>"
}'komrad rpc rebase-worktree \
--agent-id <string>{
"name": "rebase_worktree",
"arguments": {
"agentId": "<agentId>"
}
}Offered by the komrad MCP server to orchestrator agents.
Request#
RebaseWorktreeRequest#
| Field | Type | Description |
|---|---|---|
agentId | string | Whose branch to move onto its base. required |
Response#
RebaseWorktreeResponse#
| Field | Type | Description |
|---|---|---|
baseRef | string | The ref the branch was moved onto. |
baseSha | string | The commit that ref named when it was read. |
commits | int32 | How many of the agent's own commits the rebase carried. |
branch | string | Which branch moved. |
conflicted | bool | Whether the rebase stopped on conflicts and is still stopped, waiting for the agent. |
moved | bool | Whether the branch reached the base without replaying anything, which is what a branch whose work has entirely landed gets. |
landedCommits | int32 | How many of the agent's own commits the base already held, and how many were replayed. |
replayCommits | int32 | How many were replayed onto the new base. |