Skip to content

Fork a thread from a point, or branch it by editing a message​

POST
/api/threads/{threadId}/fork

Makes a new thread that begins as a copy of this one (ADR 0029): the parent's events up to a cut, with the same seq, then a thread_forked event, then the new thread's own. The parent is not changed. The fork has its own A2A context, the parent's title (a person's rename of the parent stays theirs in the fork), the deployment's gate for its agent, and the same owner.

  • after (a seq): fork from here. The cut is the end of the turn that holds that event: the last event before the next message or action of a person, or the end of the log. The fork is done, a finished job: its next message starts the next job and is sent to its agent with the earlier conversation in front of it. A turn that is still going on (the thread is queued, working or verifying, and nothing follows the event) cannot be copied: 409, code: turn_open. With target, this is also "continue with another agent".
  • after with text (and messageId): the fork is made with its first message (ADR 0042, decision 8). The copy, thread_forked, the message and the next job's start are one transaction, as for a new thread, so the fork is queued at once and its agent is told the conversation it continues together with the message; nothing exists if any part is refused. This route carries no mentions and no UI catalog: the AG-UI run (runAgent, forwardedProps["vymalo.fork"]) does, and is what the web sends. A repeat with the same id, the same after and the same message answers the fork it made (200) and writes no second message; the same id with another message or cut is a 409.
  • replace (the seq of a person's message) with the new text: edit. The cut is the event before that message, which may be 0; the fork then holds the new message, the next job's start and its delegation to the agent, and is queued. The thread is a branch of the one it was made from: it is left out of listThreads unless asked for, and listBranches finds its siblings. A conversation holds at most 256 threads, its first thread and the threads made from it this way: the 256th edit is a 409.

Regenerate the last answer is an edit with the same words; the server has no route of its own for it (ADR 0029, amended 2026-11-14). A client does this:

  1. Take the person's message that began the newest turn and POST {id, replace: <its seq>, text: <its words, unchanged>, messageId}. Send no tier and no locale: the server then keeps the replaced message's tier and interface locale (below). The answer is a new version of that message: listBranches finds it, and the client goes to the new thread.
  2. id and messageId are new UUIDs for each regenerate and the same ones for a retry after a failure (a lost response, a 5xx), so a retry never makes a second thread; the next regenerate, of the same message too, mints new ones.
  3. Do not offer it when the client can see, from what the API gives it, that the edit would lose something: the thread is queued, working or verifying (the turn is not over); the thread is blocked with a question open (the edit would drop it); the newest turn did not begin with a message of a person but with a form answer (ui_action, the vymalo.action activity: there is no message to replace); the message mentioned agents (vymalo.mentions in its START metadata: an edit carries none); the message was sent while the agent worked (vymalo.delivery, steer or interrupt: the turn also holds the agent's earlier work, which an edit of that message keeps, so it is not "again"); the caller holds no thread.write (getMe); or the thread is read through a share link (the owner's routes are a 404 to a reader).

The server enforces only the caller's thread.write (403), ownership (404, a share link's reader included), that replace is a message of a person (422) and the tier rules below. Everything else in step 3 is the client's courtesy: a request that ignores it is accepted. The seq of a person's message is the resume point (SSE id:) of the last frame of that message in the stream (agui.md).

tier (ADR 0061, access-tier-v1.md) is the access tier of the message the fork carries, one of plan, edits, auto, bypass, read as forwardedProps["vymalo.tier"] is; it goes with text. An edit that names none is sent under the tier of the message it replaces, lowered to what the caller's roles allow and the agent's live card honours (422 this agent no longer lists access tiers or has no tier at or below ... when it cannot be kept). A first message that names none, from a caller with a role cap, is sent under the highest tier the agent offers that is not above the lower of its default and the cap, as for a new thread.

target names the agent and release the fork talks to (the parent's when absent), validated as for a new thread: an agent the caller's audience leaves out (ADR 0045) is a 400 "unknown agent" in the words, and with the shape, of one that is not listed. id is a UUID the caller chose for the new thread: a repeat of the request with the same id answers the fork it made (200) and writes nothing; the id of another thread is a 409. The caller's own threads only; someone else's is a 404.

Authorizations​

bearerToken

A JWT signed by the configured issuer (RS256, RS384, ES256 or EdDSA), with the configured audience. Read when auth.mode is jwt or jwt_or_proxy_header. A missing or refused token gets 401 with WWW-Authenticate: Bearer; an issuer whose keys cannot be fetched gets 503.

Type
HTTP (bearer)
or
dpopToken

A JWT as bearerToken, bound to the key of the client (cnf.jkt, RFC 7638), sent as Authorization: DPoP <token> with one DPoP header holding a proof signed by that key (RFC 9449, ADR 0054). Read only when auth.dpop is configured. A bad proof gets 401 with WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256 EdDSA", a bad or unbound token error="invalid_token".

Type
HTTP (DPoP)
or
proxyIdentity

Set by oauth2-proxy after OIDC login; requests without it get 401. Read when auth.mode is proxy_header (the default) or jwt_or_proxy_header without a bearer token.

Type
API Key (header: X-Auth-Request-Email)

Request Body​

JSON
{
  
"after": 0,
  
"replace": 0,
  
"text": "string",
  
"messageId": "string",
  
"target": {
  
  
"agentId": "string",
  
  
"release": "string"
  
},
  
"id": "123e4567-e89b-12d3-a456-426614174000",
  
"tier": "plan",
  
"locale": "string",
  
"model": "string",
  
"reasoningEffort": "none"
}

Responses​

The fork this request's id named, made by an earlier request

JSON
{
  
"id": "123e4567-e89b-12d3-a456-426614174000",
  
"owner": "string",
  
"title": "string",
  
"description": "string",
  
"target": {
  
  
"agentId": "string",
  
  
"release": "string"
  
},
  
"state": "queued",
  
"tools": [
  
  
"string"
  
],
  
"job": {
  
  
"number": 0,
  
  
"attempt": 0,
  
  
"maxAttempts": 0,
  
  
"gate": [
  
  
  
"ci"
  
  
],
  
  
"sha": "string"
  
},
  
"share": {
  
  
"visibility": "internal",
  
  
"effective": "private",
  
  
"url": "string"
  
},
  
"createdAt": "2024-01-01T00:00:00Z",
  
"updatedAt": "2024-01-01T00:00:00Z",
  
"lastSeq": 0,
  
"pinned": true,
  
"archived": true,
  
"nestedUnder": "123e4567-e89b-12d3-a456-426614174000",
  
"childOf": {
  
  
"threadId": "123e4567-e89b-12d3-a456-426614174000",
  
  
"session": "string",
  
  
"agent": "string",
  
  
"state": "working",
  
  
"keepOpen": true,
  
  
"closing": true,
  
  
"closeAsked": true
  
},
  
"forkedFrom": {
  
  
"threadId": "123e4567-e89b-12d3-a456-426614174000",
  
  
"seq": 0,
  
  
"kind": "fork"
  
}
}

Samples​

Powered by VitePress OpenAPI