Send a message to an agent, read what it did, and keep the record after the agent's process is gone.
What a thread is
A thread is the record of one task. It holds every message you sent, every tool call the agent made and every result, in order. The runtime is the service that runs agents and keeps their threads. An engine session, running Claude Code, Codex or Condensate's own engine, does the work. The thread is what remains when that session is gone.
A browser tab can close and reopen, and the task is still there. Your app can show what happened in a task that finished an hour ago. A restart loses no message, because each message is on disk before any model runs on it.
How it works
- 01Your app sends a messageRequest
POST /threads/:id/messages - 02The runtime accepts and records itDurable
202 · seq · ts - 03An engine executes the turnRunning
Model → tool → result → model
- 04Events reach your interfaceStreaming
Live deltas for responsiveness; stored events for recovery.
- 05Your app reads the outcomeSettled
A completed or failed turn is distinct from acceptance.
You post a message. The runtime writes it to the thread's log and answers at once with a sequence number. That answer means the message is stored, not that the agent has acted on it. The engine session then runs one turn, which is one message to the agent and its full reply, tool calls included. Each step lands in the log with the next sequence number. You read the log forward from the number you were given, or keep a connection open and let the events stream to you.
Try it
You need a running runtime and one thread. POST /spawn creates a thread and returns its threadId. This example sends real work to the thread and spends model usage.
export THREAD_ID='replace-with-an-existing-thread-id'
curl -i "http://127.0.0.1:4741/threads/$THREAD_ID/messages" \
-H 'content-type: application/json' \
-d '{"text":"Summarize the current task and its next step."}'
You should see HTTP 202 and a JSON body with seq and ts. Keep seq. Now read what the agent did after that point:
export AFTER='replace-with-the-acknowledged-sequence-number'
curl -fsS \
"http://127.0.0.1:4741/threads/$THREAD_ID/tail?after=$AFTER&limit=20"
You should see events, a nextAfter cursor and hasMore. Pass nextAfter back to read the next page. GET /threads/:id/turn tells you whether a turn is running, which messages are still queued, and whether the thread is degraded.
What happens when
A message arrives during a running turn
A message posted during a running turn is added to that turn as guidance. Post with "hold": true to keep it behind the running turn instead. A held message cannot also carry to or from. Until it is delivered, you can edit it with PATCH /threads/:id/messages/:seq or withdraw it with DELETE /threads/:id/messages/:seq. POST /threads/:id/interrupt stops the running turn and any turns it delegated to child threads, drops queued messages and cancels any pending retry. Held messages stay held until you send the next message.
You need one awaited answer
POST /threads/:id/send holds the request until the turn finishes and returns the reply. Send "async": true to get the same 202 acknowledgment as /messages.
The runtime is stopping
While the runtime finishes its running work before a restart, POST /threads/:id/messages answers 503 with the code draining. Nothing is recorded, so retry once the runtime is open again.
The runtime restarts mid-turn
The turn that was running is marked lost, and nothing retries it. At boot the runtime writes an error message to each affected thread, starting "This turn was lost to a host restart". The thread waits until you press Resume or send a new message. The messages themselves stay in the log. Held messages and scheduled retries are stored as rows, so the runtime delivers the held messages and re-arms the retries at boot. The agent's session is recreated on its next turn from the engine's resume state and the log.
When you move a deployment, back up the thread database, its archive, the blob directory and the engine state together. Without the engine state, sessions cannot resume their provider conversations. The paths are in Reference.
You open a long thread at its end
Read the reverse page with before. Omit it to start from the newest event. The page returns events newest first, plus prevBefore and hasMore for the next older page.
A forward read from sequence 0 can include a snapshot that stands in for older events, and events then starts after it. Add history=1 to read the full event history behind the snapshot.
You build a live interface
Acknowledge a send as soon as /messages answers. Render live deltas from GET /threads/:id/stream while the turn runs, then reconcile against the stored events. Live deltas have no replay and no sequence numbers, so treat them as a preview and read the final text from /tail or /follow.
To keep a connection open instead of polling, use GET /threads/:id/follow?after=<seq>. It streams events as server-sent events, and the Last-Event-ID header works as the cursor. The SDK provides a follower, agents.follow, that manages reconnects and falls back to polling where streaming is unavailable.
You coordinate several tasks
A child thread has its own history, so its work can be inspected on its own. POST /spawn with parent: { threadId, atSeq?, forSeq? } starts one under a parent. The other routes for working across threads, fork, subscriptions, approvals and handoff, are in the table under Reference. Start with one thread and its event stream before building a coordinator.
You archive a thread
DELETE /threads/:id marks a thread archived. Nothing is deleted. POST /threads/:id/restore brings it back.
An agent ends its turn with unpushed commits
When an agent that writes code ends a turn with commits GitHub does not have, the runtime asks the pull request review server to push them. The runtime never runs git push itself, and the review server chooses the GitHub identity. If the push is refused, the commits stay in the agent's working copy and the agent is told why, with the instruction to fix the cause rather than push by hand. Security says what the review server checks before it pushes.
Reference
Routes
| Route | What it does |
|---|---|
POST /spawn | Creates a thread and answers with its threadId. With parent, starts a child thread. |
POST /threads/:id/messages | Records a message and answers 202 with seq and ts. "hold": true keeps it behind the running turn. Answers 503 draining while the runtime is stopping. |
PATCH /threads/:id/messages/:seq, DELETE /threads/:id/messages/:seq | Edit or withdraw a held message before it is delivered. |
POST /threads/:id/send | Holds the request until the turn finishes and returns the reply. "async": true answers 202 instead. |
GET /threads/:id/tail | Stored event pages. after=<seq> reads forward; before=<seq> reads the reverse page; wait=<ms> holds an empty page open; history=1 reads behind a snapshot. |
GET /threads/:id/follow?after=<seq> | The same events as server-sent events. |
GET /threads/:id/stream | Live deltas, with no replay and no sequence numbers. |
GET /threads/:id/turn | Whether a turn is active, the queued messages, and whether the thread is degraded. |
GET /threads | Thread summaries. Each carries location, where its agent runs now, or null while none runs. |
POST /threads/:id/interrupt | Stops the running turn and its delegated child turns, drops queued messages and cancels any pending retry. |
POST /threads/:id/fork | Forks a thread at a point in its history. |
POST /threads/:id/subscriptions | Watches another thread and starts a turn on its events. |
POST /threads/:id/approvals/:approvalId | Allows or denies a pending approval, with decision: "allow" or "deny". |
POST /threads/:id/handoff | Hands work to another thread, which accepts or declines it. |
DELETE /threads/:id, POST /threads/:id/restore | Archive a thread, and bring it back. |
Page sizes and waits
| Setting | Value |
|---|---|
Default page size of GET /threads/:id/tail | 200 events |
| Maximum page size | 1000 events |
Longest wait on an empty page | 30 seconds |
| Subscriptions per thread | 8 by default; CONDENSATE_AGENTS_MAX_SUBSCRIPTIONS changes it |
Storage
| What | Where | Setting |
|---|---|---|
| Thread records and ordered events | threads.db under ~/.condensate/agents-host | CONDENSATE_AGENTS_DATA_DIR moves the directory |
| Older event bodies of a compacted thread | threads-archive.db in the same directory | |
| Event bodies larger than 64 KiB | Content-addressed files in blobs/. The database keeps only their hash. | CONDENSATE_AGENTS_BLOB_THRESHOLD changes the size |
| Engine resume pointers | ~/.condensate/engine by default |
Settings
| Setting | What it does |
|---|---|
CONDENSATE_AGENTS_PORT | The port the runtime listens on. The default address is 127.0.0.1:4741. |
CONDENSATE_HEALTH_EXIT_MS | Once the runtime has answered its own GET /health, it checks again every 30 seconds. When no check has answered for this many milliseconds it exits with code 70, so Docker's restart policy starts it again. 0, the default, turns this off. The Docker install sets 90000. |
Read next
- What is Condensate, for what the runtime guarantees across accounts, logins and restarts.
- Runtime HTTP API, for every route with its fields and error codes.
- Use the TypeScript SDK, to follow a thread from TypeScript instead of curl.