POST /api/agent/message and poll GET /api/agent/status/{call_id} until it finishes. Everything else on this page - queueing, steering, stopping - exists because turns are long enough that you will want to change your mind while one is running.
Start a run
chat_id is optional. Omit it and the run creates its own chat; pass it to continue an existing conversation. Keep the returned chat_id - every other endpoint on this page needs it.
A
200 means the turn started. A 202 means a turn was already running on
this chat and yours was queued behind it - see Queued
messages.Run options
Poll until it finishes
status is pending while the run is in flight, then completed or error. There is no intermediate event stream on this endpoint - poll it every few seconds.
result.toolOutputs names every file the agent touched, which is the quickest way to find the artifacts a run produced without diffing the whole tree.
A complete poll loop:
Resuming after a restart
If your process dies mid-run, ask the chat what is still in flight instead of holding the ids in memory:"pending_job": null means the chat is idle and there is nothing to resume.
Release the run
When a run reachescompleted or error, release it so the chat is ready for the next turn:
Queued messages
Send a second message while a turn is running and you get a202 instead:
Steering a turn in flight
Waiting for the queue is the wrong move when the agent is heading somewhere you do not want. Steering promotes a queued message into the turn that is already running, delivered at the agent’s next step boundary:409 with "status": "not_steerable" means the current turn cannot take a mid-flight message. Leave it queued - it will be delivered normally when the turn ends.
Stop a run
409 means the job was not running - it had already finished.
Putting it together
Managing the chat itself
/api/chats/* accepts a user access token or an API key. Service-account keys own their own chats; user-owned keys act on yours, within the key’s organization.
Related
- Agents overview - what an agent can reach for
- Unattended runs - running this loop with no human watching
- Tools - call the agent’s tools directly, without an agent
- Agent API reference - every field and response