create_agent

Launch a background agent with an opening prompt.

Agentwritesnot idempotentMCP tool

Requires an absolute or ~-prefixed directory: this spawns a real agent in a real tmux window, and a relative path would point somewhere unpredictable. Each call spawns another agent, so do not retry a call that may have succeeded. There is a ceiling on how many agents may exist at once, and a call past it is refused as resource_exhausted; that means there is no room rather than something being broken, so stop and tell the user instead of trying again. Set parentAgentId to attach the new agent to an existing one as its child, passing your own id from KOMRAD_AGENT_ID, which is the shape for an agent that reads the tree you are in: reach for a child whenever that is what the new agent does, and leave it off when the new agent writes work of its own and so needs a checkout of its own, or when the person asking said they wanted an agent standing on its own. Set provisionEnabled to false to keep the directory you named rather than be given one: that is how an agent reads a checkout somebody else already has open, and it is what the reviewer case wants. Leave it unset to do whatever the workflow does. A child runs in its parent's directory and provisions nothing of its own, so dir and provisionEnabled are both refused rather than quietly overridden, and workflowId is still required but has to be the parent's own. It may only mail its parent and its parent's other children, it goes when the parent goes, and it cannot be restored on its own while the parent stays archived. A child may not have children of its own, and neither may an orchestrator: it is drawn on its workflow's own row rather than a row of its own, so a child of it would be drawn nowhere at all, and a parentAgentId naming one is refused. An orchestrator fans read-only work out as an ordinary agent in its workflow with provisionEnabled false, which gives that agent a row, a mailbox and the workflow's own directory to read.

Calling it#

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

Request#

CreateAgentRequest#

FieldTypeDescription
promptstring

The opening briefing, which is everything the agent has to go on.

required, at most 50000 characters

titlestring

What to call it in the panel, blank to have komrad name it.

at most 200 characters

dirstring

Where to start it, absolute or ~-prefixed, blank to take the workflow's own.

at most 4096 characters

flagsstring

Flags for its CLI, blank to take the workflow's own.

at most 500 characters

workflowIdstring

Which workflow to launch it into, whose cwd, flags and context it inherits.

required

harnessstring

Which CLI to run, blank to take the workflow's own.

at most 40 characters, matching ^[a-z0-9-]*$

idempotencyKeystring

A key that makes a retry safe, since a repeat carrying it is answered with the agent it already launched.

at most 200 characters

provisionEnabledbool

False to keep the directory named above rather than be given a worktree, which is how an agent reads a checkout somebody else has open.

parentAgentIdstring

Which agent to attach this one to as its child, which then runs in that agent's directory and goes when it goes.

Response#

CreateAgentResponse#

FieldTypeDescription
agentAgent

The agent as launched, whose id is what mail is addressed to.

Types#

Agent#

FieldTypeDescription
idstring

The handle every other call names this agent by, and what mail is addressed to.

namestring

What the panel lists it as, which is also its tmux window name at launch.

cwdstring

The directory it is running in, its own worktree when the workflow provisions one.

flagsstring

The command-line flags its CLI was started with.

promptstring

The whole briefing it was launched with.

paneIdstring

The tmux pane its CLI is running in, which is what capture-pane reads.

stateAgentState

What the panel last decided it was doing, read off the tail of its pane.

sessionIdstring

The CLI's own conversation id, which is the handle a resume needs.

harnessstring

Which CLI it runs, such as claude or codex.

workflowIdstring

Which workflow it is filed under, whose context it took at launch.

createdAtstring

When it was launched, in RFC 3339.

archivedAtstring

When it was hidden from the panel, unset while it is live.

scheduleIdstring

The schedule that launched it, unset for an agent a person or another agent spawned.

alivebool

Whether its pane is still there, which a dormant agent's is not.

hiddenbool

Whether the panel draws a row for it, which changes nothing about the agent itself.

metadatalist of AgentMetadata

Facts it has recorded about its own work, such as the ticket it is implementing.

idempotencyKeystring

The key a retry of its create carried, which is what answers a repeat with this agent.

spawnedByAgentIdstring

Which agent called create, unset for one a person spawned.

parentAgentIdstring

The agent this one is attached to, where spawned_by_agent_id is only who called create.

branchstring

The git branch its worktree is on, unset for an agent that provisions none.

repositoryUrlstring

The canonical web address of the repository its checkout pushes to, such as https://github.com/harrisoncramer/komrad, unset when the checkout is gone or its origin is not a forge.

headShastring

The commit its checkout has checked out, unset when the checkout is gone or git cannot read it.

worktreeRemovedbool

Whether its checkout has been taken away, which leaves the record and the transcript.

sequenceInProgressbool

Whether a merge, a rebase or a cherry-pick is part-way through its checkout, waiting on somebody to settle it.

failedRunbool

Whether a script komrad fired for the agent failed and nobody has looked at it since.

failedRunLogint32

The run log that failure was written to, which is the run the panel opens on.

stateChangedAtstring

When the state above last moved, in RFC 3339.

reportedReasonstring

What the agent's own CLI last reported it was doing, which annotates the state the pane decided rather than replacing it.

roleAgentRole

What the agent was launched to do, which decides the half of the review briefing it is sent.

promptTruncatedbool

Whether prompt holds only its opening, which a summary listing returns so that a page of agents does not carry every briefing they were launched with.

treeStandingReviewTreeStanding

Where the agent's worktree stood when last measured against the round tree_standing_sha names.

treeStandingShastring

The snapshot of the round tree_standing was measured against, empty before any measurement.

movedSinceRoundstring

The snapshot of its newest round while its worktree no longer hashes to it, empty otherwise.

heldAtstring

When a person stopped this agent and took its worktree, empty while nobody is holding it.

AgentMetadata#

FieldTypeDescription
keystring

What the fact is filed under, such as pr or branch.

valuestring

The fact as the panel shows it, which is why a URL belongs here whole.

AgentState#

AgentState is what the panel last decided an agent was doing, read off the tail of its pane.

ValueDescription
AGENT_STATE_IDLE

The pane is at rest with nothing typed.

AGENT_STATE_THINKING

The CLI is working on a turn.

AGENT_STATE_WAITING

The CLI is blocked on a human answering a selection.

AGENT_STATE_SETTING_UP

The agent is being launched and has no pane to read yet.

AGENT_STATE_FAILED_TO_CREATE

The launch failed, which retry_agent is for.

AGENT_STATE_FAILED_TO_CLEANUP

A delete failed to take the worktree down, and the reason is on the row.

AGENT_STATE_UNCERTAIN

The pane could be read but its tail decided nothing.

AgentRole#

AgentRole is what an agent was launched to do.

ValueDescription
AGENT_ROLE_IMPLEMENTER

An agent that lands work on a branch of its own.

AGENT_ROLE_REVIEWER

A child that reads another agent's work and gives a review.

AGENT_ROLE_ORCHESTRATOR

The agent drawn on a workflow's own row that hands work out.

ReviewTreeStanding#

ReviewTreeStanding is where an agent's worktree stands against the round its last verdict was given on.

ValueDescription
REVIEW_TREE_STANDING_MOVED

The worktree differs from the round and the base does not hold the round.

REVIEW_TREE_STANDING_LANDED

The base holds the round whole and the worktree carries nothing beyond the base.

REVIEW_TREE_STANDING_LANDED_MOVED

The base holds the round whole and the worktree carries new work on top of the base.