Skip to content

Enhanced Chat Stream

POST
/api/chat/enhanced/stream

SSE-stream a single chat reply through the M17 dispatcher pipeline.

Routing-shell + per-handler-summary text comes from the Authored Library; the chunk also carries the dispatched handler id, intent id, classifier confidence, and (when available) a HandlerInvocationLog row id so the frontend can render the “via {agent} → {handler}” caption + open the analysis-pane dispatch detail.

ChatDispatchRequest

M17 chat dispatch request — replaces EnhancedChatRequest.

ChatDispatchRequest is the contract for dispatching a user query through the M17 chat pipeline: classify the message intent via divinity/intent-classify, route to the matched DE handler, render the per-handler summary through the Authored Library, and return a chat-bubble-shaped reply.

Fields: message: User’s chat message content (required). project_id: Project context identifier (active project). thread_id: Existing thread ID to continue a conversation. New threads are auto-created when this is omitted. conversation_id: Deprecated alias for thread_id. Frontend still sends it for back-compat with old persisted threads; the dispatcher service treats either as authoritative. agent: Divine agent the user wants to address explicitly (hawken / lagan / lorekeeper / gamemaster / worldknowledge / ishvana). Pass-through to the dispatcher’s selected_agent. selected_agent: Same field as agent under the M17 name — both are accepted; selected_agent wins when both set. selected_handler_id: Pre-supplied DE handler id (divinity/<name>) that bypasses the intent classifier. Used by the intent-suggestion chip on the frontend to force the user’s accepted choice. confidence_floor: Minimum classifier confidence required to dispatch the matched handler. Below this floor the dispatcher emits the no_route_low_confidence reply. skip_user_persist: Skip persisting the user message before dispatch. Used by the Writers’ Room fan-out so the user message isn’t recorded N times (one per agent). images: Image attachments (preserved for context-aware handlers that accept image inputs). context: Ambient user context (active document, browser URL, etc.) forwarded to handlers that consume it. writers_room: Render this as a Writers’ Room reply — fan out to multiple agents in parallel. requested_at: Timestamp when the request was created.

Used By: - POST /api/chat/enhanced/stream endpoint (single agent dispatch) - POST /api/chat/writers-room/stream endpoint (parallel fan-out) - Intent-suggestion chip accept handler (forced-handler path)

object
message
required
Message

User message

string
projectId
Any of:
string
threadId
Any of:
string
conversationId
Any of:
string
agent
Any of:
string
selectedAgent
Any of:
string
selectedHandlerId
Any of:
string
/^divinity/[a-z][a-z0-9-]*$/
confidenceFloor
Confidencefloor

Minimum classifier confidence to dispatch a routed handler

number
default: 0.55 <= 1
projectType
Any of:
string
images
Any of:
Array<object>
ImageAttachment

Base64-encoded image attached to a chat message.

object
mediaType
required
Mediatype

MIME type (image/png, image/jpeg, image/gif, image/webp)

string
data
required
Data

Base64-encoded image data

string
context
Any of:
AgentChatContext

Ambient author context attached to a freeform agent request.

object
activeUrl
Any of:
string
pageTitle
Any of:
string
pageContentExcerpt
Any of:
string
activeDocumentTitle
Any of:
string
activeDocumentExcerpt
Any of:
string
skipUserPersist
Skipuserpersist

Skip user message persistence (used by WR to avoid duplicates)

boolean
requestedAt
Requestedat

Chat dispatch request timestamp

string format: date-time

Successful Response

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object