POST /api/chat/generate → 202 { runId } (async workflow run) — chat#1813
PR 1 (docs, the contract) of the async chat-generation migration tracked in recoupable/chat#1813 — docs → api → tasks order.
What
POST /api/chat/generate is being re-pointed from a synchronous legacy ToolLoopAgent onto the durable runAgentWorkflow. It now starts a workflow run and returns { runId } with HTTP 202 instead of the full completion body.
- Replace the
200 ChatGenerateResponsewith202 ChatGenerateAcceptedResponse { runId }. - Drop the now-unused
ChatGenerateResponse/ChatGenerateResponseMeta/ChatGenerateUsage/ContentPartschemas (each was referenced only by the old 200 — verified, no dangling$refs). 400unchanged.
Why the contract can change
The only caller (tasks/src/recoup/generateChat.ts) used the response only for logging; message persistence + email happen server-side. The api PR makes the caller fire-and-forget.
Merge order
This docs PR lands first (contract), then api re-points to fulfill it, then tasks goes fire-and-forget.
🤖 Generated with Claude Code
Summary by cubic
Expose chat-generation as async runs. POST /api/chat/runs starts a durable workflow and returns 202 with runId, chatId, sessionId, and a Location header; poll GET /api/chat/runs/{runId} or watch live via GET /api/chat/{chatId}/stream (chat#1813).
- Migration
- Replace
POST /api/chat/generatewithPOST /api/chat/runs; addGET /api/chat/runs/{runId}for status. - Request schema: removed
excludeTools,roomId,topic; now matchesPOST /api/chat(prompt | messages, artistId, model). - Removed
ChatGenerateResponse,ChatGenerateResponseMeta,ChatGenerateUsage,ContentPart; 400 unchanged. - Docs: removed
generate.mdx; addedruns.mdxandruns-status.mdx; updated nav/index, reordered Streaming section, fixed{param}link rendering, added bidirectional cross-links, simplified run descriptions, and standardized endpoint-link formatting (backticked method links) in the touched descriptions including theSessionschema.
- Replace
Summary by CodeRabbit
- New Features
- Added an asynchronous chat run flow:
POST /api/chat/runsnow returns immediately with HTTP202, along withrunId,chatId, andsessionId. - Added
GET /api/chat/runs/{runId}to retrieve the run’s current status.
- Added an asynchronous chat run flow:
- Bug Fixes
- Updated the chat API contract from the prior synchronous generate response to an async accepted response.
- Documentation
- Updated API reference pages and navigation to replace the former “Generate Chat” documentation with “Start Chat Run” and “Get Chat Run Status.”