Reference
AI agent and human handoff
Intercom-Fin-style flow: an in-room AI agent responds until a human operator takes over.
An in-room AI agent can respond 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 and 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 plus 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 for SLA timers and dispositions
- Telephony handoff for voice and SMS escalation
Cloudflare AI Gateway
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`).