Reference
AI agent + human handoff (P12-H)
Intercom-Fin-style flow: an in-room AI agent responds until a human operator takes over. Handoff pauses AI invokes, enqueues an agent task with thread context,
Intercom-Fin-style flow: an in-room AI agent responds until a human operator takes over. Handoff pauses AI invokes, enqueues an agent task with thread context, and resumes AI when the handoff is completed with a disposition code.
API
| Method | Path | Role | Action |
|---|---|---|---|
GET | /rooms/\{roomId\}/handoff | member+ | Current handoff state |
POST | /rooms/\{roomId\}/handoff | moderator/admin/owner | Take over from AI |
PATCH | /rooms/\{roomId\}/handoff | moderator/admin/owner | Complete with disposition |
Disposition codes: GET /agent-queue/dispositions (shared with agent queue wrap-up).
Behaviour
- Take over — builds a context summary from the last 12 messages, creates + auto-claims an agent queue task (
trigger_source=ai_handoff), insertsroom_handoffsrow (human_active), broadcaststype: handoffon the room WebSocket. - While active —
POST /agents/:id/invokeand@mentionagent invokes return409 human_handoff_active. - Complete —
PATCHwith disposition resolves the handoff and linked agent task; AI can respond again.
Dashboard
- Agent room chat —
<AgentHandoffBanner />(Take over / Complete handoff + context preview). - Agent queue —
/agent-queuewith disposition picker and resolved stats.
SDK
const { handoff } = await client.getRoomHandoff(roomId);
await client.requestRoomHandoff(roomId, { agentId, note: "VIP customer" });
await client.resolveRoomHandoff(roomId, "resolved");Database
- Migration
0056_room_handoffs.sql - Links to
agent_tasksviaagent_task_id
Related
- Agent queue (P13-T4) —
/agent-queueSLA timers; dispositions (P13-T5) —GET /agent-queue/dispositions ROADMAP_EXECUTION.md§ P12-H exit criteria
Cloudflare AI Gateway (P12-I)
FluxyChat routes shared Worker AI calls through [Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/) when gateway env vars are set. Legacy dir
Message middleware (inbound pipeline)
FluxyChat runs every inbound chat message through a shared pipeline before it is stored or broadcast (WebSocket `type: "message"` and `POST /messages`).