AI Agents
AI agents and human handoff (HITL)
In-room AI, take-over flow, agent queue, and disposition codes.
FluxyChat supports Intercom-Fin-style flows: 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 completes.
Architecture
sequenceDiagram
participant User
participant Room as Room WS
participant AI as AI Agent
participant Queue as Agent queue
participant Human as Human operator
User->>Room: message
Room->>AI: invoke (if no active handoff)
AI->>Room: reply
Human->>Room: POST handoff (take over)
Room->>Queue: create + claim task
Note over AI: invoke blocked (409)
Human->>Room: resolve handoff + disposition
Room->>AI: invoke allowed againAPI
| 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).
SDK
import { FluxyChatClient } from "@fluxy-chat/sdk";
const client = new FluxyChatClient({ baseUrl, userId, token });
const { handoff } = await client.getRoomHandoff(roomId);
await client.requestRoomHandoff(roomId, {
agentId: "support_lead",
note: "VIP customer — billing issue",
});
await client.resolveRoomHandoff(roomId, "resolved");While handoff is active, POST /agents/:id/invoke and @mention agent invokes return 409 human_handoff_active.
Dashboard
| Surface | Component / route |
|---|---|
| Room chat | <AgentHandoffBanner /> — Take over / Complete handoff + context preview |
| Operator queue | /agent-queue — SLA timers, claim, disposition picker |
Configure agents under Agents (/agents). Each agent has model, system prompt, tools, and room allowlist.
Configure an in-room agent
- Create agent in dashboard → copy agent id
- Bind to room via project settings or
@agentmention rules - Test invoke:
POST /agents/{id}/invokewith{ "roomId": "…", "prompt": "…" }
Human-in-the-loop patterns
| Pattern | When to use |
|---|---|
| Room handoff | Escalate entire thread from AI to human |
| Tool approvals | AI proposes an action; human approves via card button (tool presets) |
| Agent queue | Pool of operators; auto-claim on handoff |
Database
- Migration
0056_room_handoffs.sql - Links to
agent_tasksviaagent_task_id
Related
- Agent queue — SLA, dispositions, wrap-up
- Custom tools — tools the agent can call
- Thread state — per-thread KV for agent memory