Agent Desk is CXB API’s human-handoff control plane. When CXB Core escalates a live call, it enqueues the call here; agents accept it into a LiveKit room; supervisors can listen, barge in, or force-end. A background policy loop terminates calls no agent can serve. The Agent Desk logic lives in the API service’s agent-desk route, agent-desk service (the AgentDeskStore), and agent-desk policy module. Queue state lives in Redis (request.app.state.agent_desk_store); completed call records land in the calls collection with call_type: "agent".

Authentication

The route uses three auth surfaces:
SurfaceUsed for
X-CXB-Core-Secret (_verify_core_secret)CXB Core → CXB API ingress: /enqueue, transcript/recording/event updates, customer-disconnected
require_agent_or_supervisorAgent-facing queue, call accept/reject/end, status
require_supervisorSupervisor monitoring and force-end

Endpoint groups

/api/v1/agent-desk (selected — the router exposes ~28 routes):
GroupEndpointsPurpose
EnqueuePOST /enqueueCXB Core hands a waiting call to the queue (call_id, room, caller, bot, escalation_reason, transcript, variables, context)
QueueGET /queue, GET /queue/stream (SSE)Agent-scoped waiting list and live updates
Call lifecyclePOST /calls/{id}/accept · reject · decline · end · hangup · customer-disconnectedAgent handling
Call stateGET /calls/{id}/state, GET /calls/current, GET /calls/{id}State reads
Call updatesPOST /calls/{id}/events · transcript · recordingCXB Core-driven updates
Agent statusPOST /status · status/heartbeat · status/offline, GET /statusPresence (available/away/busy)
SupervisorGET /supervisor/dashboard · supervisor/stream, POST /supervisor/calls/{id}/listen · barge-in · force-endMonitoring + intervention
MetricsGET /metrics, GET /me/metricsDay-bucketed metrics (uses display timezone)
LiveKit tokens for agents/supervisors are minted by the LiveKit service (create_agent_token, create_supervisor_listen_token = subscribe-only, create_supervisor_barge_token = full publish).

Queue flow

On enqueue, if a transcript is supplied CXB API fires a background summary generation task (_generate_summary) — using a module-level cached LLM client to avoid the LLM client SDK’s per-instantiation memory leak.

Timeout & decline policy

The agent-desk policy module runs run_agent_desk_policy_loop as a background task started at application startup:
KnobSourceDefault
timeout_secondssettings.agent_desk_waiting_timeout_seconds120
poll_secondssettings.agent_desk_policy_poll_seconds5
Two policies terminate a waiting call:
  • Timeout (enforce_waiting_timeouts): calls waiting longer than timeout_seconds are ended with event agent_desk_timeout, disconnected_by="no_agent", disposition No Agent Available.
  • All available declined (terminate_if_all_available_agents_declined): if every currently available agent/supervisor has declined a call, it is ended with event all_agents_declined.
terminate_waiting_call atomically claims the call (claim_waiting_call_for_termination), tears down the LiveKit room (remove_all_participants), writes a call_type: "agent" record (idempotent upsert keyed by parent_call_id), and marks it ended. If teardown fails, the call is restored to waiting (and declines optionally cleared) rather than lost.

Transfer & escalation (CXB Core)

How CXB Core decides to escalate and calls /enqueue.

Agent Assist

Live suggestions for agents handling escalated calls.

Users & roles

Agent/supervisor roles and presence.

Settings

Display-timezone day boundaries used by metrics.