Agent API
Streaming chat and conversation storage tied to a project and optional focus dataset.
/api/agent/chatSend one user message. Returns text/event-stream with thinking deltas, tool calls, and completion. Requires write access.
{
"projectId": "8f2c…-project",
"text": "Add a founded_year column from company websites",
"clientMessageId": "9b4e…-uuid",
"conversationId": null,
"focusDataset": "companies"
}/api/agent/conversations?projectId={uuid}&limit=50List recent conversations (pinned, archived, running flags).
/api/agent/conversations/{conversationId}?projectId={uuid}Fetch full transcript: user messages, agent text, tool results.
/api/agent/conversations/{conversationId}/stopStop an in-flight agent run for that conversation.
Streaming (SSE)
POST /api/agent/chat responds with Content-Type: text/event-stream. Each line is data: followed by one JSON ChatEvent. Subscribe with fetch and a ReadableStream reader, or EventSource is not used because the request is POST.
data: {"type":"conversation","conversationId":"c3f1…"}
data: {"type":"thinking_delta","delta":"Checking schema…"}
data: {"type":"tool_start","toolCallId":"tc_01","toolName":"query_dataset","preview":"companies"}
data: {"type":"message","message":{"key":"m1","role":"tool","toolCallId":"tc_01","toolName":"query_dataset","isError":false,"error":null,"details":{"kind":"search","query":"acme","results":12}}}
data: {"type":"text_delta","delta":"Found 12 rows"}
data: {"type":"done","status":"completed"}Event types
- conversation / duplicate — conversation id for this send
- thinking_delta, text_delta — partial model output
- tool_start, message — tool calls and structured tool cards
- error — terminal failure message
- done — status: completed | failed | stopped | busy | not_found
/api/agent/conversations/{conversationId}?projectId={uuid}Update metadata: pin, archive, or rename. Body fields are optional. Returns 409 busy if a run is still active.
{ "pinned": true, "archived": false, "title": "Q4 suppliers" }/api/agent/conversations/{conversationId}?projectId={uuid}Delete a conversation. Not allowed while running (409 busy).