condensate

Runtime HTTP API

Every runtime HTTP route, grouped by task, with its error codes.

On this page

The runtime serves HTTP on 127.0.0.1:4741, and CONDENSATE_AGENTS_PORT changes the port. It binds to loopback only, so a caller on another machine comes in through Tailscale Serve or another front you run on the same computer. The SDK wraps most routes and decodes their answers, so prefer it from TypeScript. Request and response schemas are in packages/agents-host/src/http.ts, and the HTTP route index lists every route.

A spawn's optional engine field picks the agent that runs the thread: Claude Code (claude), Codex (codex) or Condensate's own agent (condensate). Without it, a Claude model runs on claude and most other models on condensate.

Errors

A refusal is JSON with an error message. A refusal a program should act on also carries a code, so branch on the code and not the message. A plain input error, such as a bad limit, is a 400 with only error.

StatusCodeMeaning
400spawn-cwd-requiredA build thread has no cwd. Pass a worktree
400spawn-cwd-fencedThe cwd is inside a checkout the runtime keeps agents out of
400account-not-in-rosterThe spec names an account the workspace doesn't allow. The body lists the allowed ones
400model-not-allowedThe model is outside the workspace's allowed list. The body lists the allowed models
400head-slot-without-headThe spec names a lead agent in spec.head, but the spawn is not one
404no-headThe workspace has no lead agent of that name
409head-name-takenThe workspace already has a lead agent of that name. The body names its thread
409not-a-headA role change names a thread that is not a lead agent
429session-capThe runtime is running as many sessions as it allows. Retry after Retry-After
429thread-list-rate-limitedToo many first-page listings. Retry after Retry-After
429stream-capThe thread has as many live stream readers as it allows. Use follow instead
503drainingThe runtime is getting ready to restart. Retry after Retry-After
503spawns-pausedNew spawns are paused because disk space is low. Retry after Retry-After

A path no route matches returns 404 with { "error", "build" }. build is the commit the runtime runs, the same one GET /health reports, so you can tell a route your build doesn't have yet from a typo.

Secrets in a spawn spec never come back in an answer. Any field whose name ends in a word such as apiKey, token, secret or password, every value under env and proxyEnv, and credential headers all read as [redacted]. The runtime goes by field names and does not scan text, so a key pasted into a URL or a title is shown as written.

Read threads

MethodRoutePurpose
GET/threadsA page of thread summaries. Query: limit (default 50, at most 200), after (the nextAfter cursor), sort (created or recent), archived (live, archived or all), role, type, workspace and parent
GET/threads/:idThe thread, its stage, cost so far, archive flag and location
GET/threads/:id/tailA page of the event log. after=<seq> reads forward and before=<seq> reads older events newest first. limit defaults to 200 and caps at 1000. wait=<ms> holds the request open for new events, up to 30 seconds
GET/threads/:id/followServer-sent events from the log. Resumes from after or the Last-Event-ID header
GET/threads/:id/streamServer-sent live text as the model writes it. Nothing is replayed, and a slow reader loses its oldest frames
GET/threads/:id/aguiThe thread as an AG-UI event stream, from after=<seq>
GET/threads/:id/turnWhether a turn is running
GET/threads/:id/tool-results/:seqThe full body of one tool result

A forward page returns events, nextAfter and hasMore, and a reverse page returns prevBefore and hasMore. Keep the two cursors apart.

location is null while no agent is running the thread, and its next message starts one. Otherwise it names the runner (process, k8s, container or worker), the machine and the reason it was placed there, which Where agents run explains.

To watch one thread, poll tail or open follow. To watch many, follow GET /workspaces/:name/changes and re-read only the threads that changed, because polling the first page of GET /threads gets rate-limited.

curl -fsS 'http://127.0.0.1:4741/threads?limit=20'
curl -fsS 'http://127.0.0.1:4741/threads/THREAD_ID/tail?limit=20'

Start work

MethodRoutePurpose
POST/spawnCreate a thread from a spawn spec. Returns { threadId }
POST/threads/:id/messagesAppend a message. Returns 202 with its seq and ts as soon as it is stored, before any model runs. hold: true keeps it as a draft you can edit with PATCH or remove with DELETE /threads/:id/messages/:seq
POST/threads/:id/sendSend a message and wait for the reply
POST/threads/:id/forkStart a new thread that continues this one as it stood at atSeq
POST/threads/:id/interruptStop the running turn
POST/threads/:id/approvals/:approvalIdAnswer a tool approval with { "decision": "allow" } or "deny". An approval already closed answers approval-closed
POST/threads/:id/questions/:requestId/answerAnswer a question the agent asked. /dismiss and /continue drop it or go on without an answer
POST/threads/:id/seats/replaceChange an agent's engine, model or placement, keeping its name and history
POST/threads/:id/compactShrink the thread's context now
DELETE/threads/:id?reason=Archive a thread. Nothing is deleted; one archive event is added
POST/threads/:id/restoreBring an archived thread back

A 202 means the runtime stored the request, not that the work succeeded, so read the log for the outcome.

Workspaces

MethodRoutePurpose
GET/workspaces, /workspaces/:nameThe configured workspaces, or one of them
PUT/workspaces/:name/policyReplace the workspace's policy
GET/workspaces/:name/headsEvery live lead agent
GET/workspaces/:name/approvalsEvery tool call waiting on approval, with its thread
GET/workspaces/:name/questionsOpen questions across the workspace
GET/workspaces/:name/changesServer-sent changes to the workspace's threads
POST/workspaces/:name/memory/recall, /retainSearch and add to the workspace's memory

A workspace can have several lead agents. A spawn names one in spec.head, for example { "name": "triage", "lane": "incoming bug reports" }, where name is 1 to 48 lowercase letters, digits or dashes and lane is one sentence on its area of work. A spawn with no name starts the default lead agent.

Reviews and code

MethodRoutePurpose
POST/workspaces/:name/roomsStart a review of a pull request
GET/workspaces/:name/rooms?repo=&pr=Find a pull request's review and its newest round
POST/rooms/:id/roundsRun another review round
POST/rooms/:id/finalizePost a round's verdict as a GitHub review
POST/workspaces/:name/prs/:number/agentsStart a build thread on the pull request's branch, in a worktree the runtime owns
GET/code/roots, /code/files, /code/readBrowse and read the registered repositories
POST/code/searchSearch code with a pattern
GET/github/:owner/:repo/prsThe repository's pull requests

Completions

POST /v1/chat/completions and GET /v1/models are an OpenAI-compatible endpoint over your signed-in accounts. Each call is one model call with no tools and no thread, so use POST /spawn for agent work. Name the workspace to charge in the x-condensate-workspace header, which you can leave out when CONDENSATE_COMPLETIONS_DEFAULT_WORKSPACE is set. x-condensate-session takes an optional label of up to 128 characters, and x-condensate-traffic: smoke marks a test call. stream: true returns server-sent deltas.

Errors use OpenAI's shape, { "error": { "message", "type", "code" } }. Common codes are unknown_workspace (400), model_not_found (404), no_eligible_account (409), accounts_exhausted (429) and rate_limited (429).

Operator inbox

A lead agent writes to the operator, the person who runs this machine, with its message_operator tool. The operator answers here. The POST route files an agent's message under the caller's own thread. The runtime gives each MCP server it starts a key for its thread, in CONDENSATE_THREAD_KEY beside CONDENSATE_THREAD_ID. The caller sends both in the x-condensate-thread and x-condensate-thread-key headers. A restart of the runtime makes new keys.

MethodRoutePurpose
POST/operator/messagesAn agent's message (text, urgency, refs, and an optional from_thread that must be the caller's thread), or the operator's reply (in_reply_to, text), which is delivered to the asking thread as a message. 400 bad-request for a body that does not decode; 403 caller-unbound for an agent message without a valid thread key; 403 sender-mismatch when from_thread is not the caller's thread; 403 caller-refused for a reply from an agent client; 404 thread-not-found when the caller's thread is gone; 404 operator-message-not-found for an unknown in_reply_to; 502 steer-failed when the reply cannot reach the asking thread; 503 draining for a reply while the runtime waits to restart
GET/operator/messages?after=<seq>Up to 500 inbox rows after seq, and last_seq. 400 bad-cursor when after is not a nonnegative integer
GET/operator/messages/streamThe same rows as server-sent events, live. after=<seq> or Last-Event-ID resumes

Operate the runtime

MethodRoutePurpose
GET/healthThe build commit, the fields /spawn accepts, and any open memory alert
GET/liveLive threads
GET/metricsRuntime metrics
GET, POST, DELETE/drainRead, start or cancel a drain before a restart
GET/keeper/spawn-pauseWhether spawns are paused. POST /keeper/spawn-pause/clear lifts it
GET/attentionEverything waiting on a person
GET/incidentsTurns that failed

During a drain or a spawn pause, new threads get 503 with Retry-After, and running turns carry on. Account routes are under /accounts, covered in Accounts.

Setup and Tailscale

These four routes back Dex's setup page. They answer only a page on the same computer, and refuse anything else with 403 and a code: peer-refused for a caller on another machine, proxied for a request with a forwarding header such as X-Forwarded-For, and origin-refused for a page on another site. The two POST routes also need an application/json body, and answer 415 json-required without one.

MethodRoutePurpose
GET/setupThe four steps, github, claude, codex and tailscale, each with a state (not-started, waiting, done, skipped or failed), and firstRun
POST/setup/:step/skipSkip claude, codex or tailscale. GitHub can't be skipped, because cloning needed it
GET/tailscaleThe node's state, a loginUrl while it needs a login, and its node name and address once it serves
POST/tailscale/login/startAsk the node for a login address

firstRun is true while no Claude or Codex account is signed in and no step is skipped. A failure answers { "code", "id" }, and the log line tailscale_failed id=<id> or setup_failed id=<id> has the detail.

StatusCodeMeaning
503tailscale-unreachableNo Tailscale node answers, or this install runs none
410tailscale-login-expiredThe node's key expired. POST /tailscale/login/start gets a new login address
409tailscale-login-refusedThe tailnet refused this node, or has not approved it yet
502serve-failedThe node runs but has no certificate name. Turn on HTTPS certificates for the tailnet
503setup-write-failedThe skip could not be saved
404answer-unreadableThat step can't be skipped