LangGraph
This guide shows how to integrate the AgentDuet SDK with LangGraph for durable agent workflows, including checkpointed state, human-in-the-loop interrupts, and policy-gated tools.
What this integration provides
A voice agent that:
- Answers inbound calls and bridges 24 kHz PCM to Gemini Live
- Authenticates demo orders against a local mock database (no live store APIs)
- Speaks shipping status in one or two short sentences
- Allows address changes or cancellations only when fulfillment is
unfulfilled
How the pieces fit
PCM stays on the AgentDuet ↔ Gemini bridge. Graph checkpoints store compact business state only (order id, auth, fulfillment) — not audio.
Prerequisites
- Python 3.12+
- AgentDuet API key and connector UUID from agentduet.com
- Gemini API key for Gemini Live
Step 1: Clone the sample
Layout:
Step 2: Install dependencies
The sample pins agentduet==1.0.0.
Step 3: Configure .env
Step 4: Run locally
Call your agent. It should answer and walk order status or a change/cancel.
Demo orders
Example scripts:
- “Order 1001, zip 94107.” → short spoken status.
- “Change my address to 88 Folsom Street, San Francisco, California, 94105.” → succeeds on #1001.
- “Order 1002, zip 10001. Please cancel.” → status OK; cancel politely declined.
Step 5: How LangGraph and AgentDuet connect
SessionManager answers the call
From main.py:
LangGraph owns tools and call state
From graph.py, each call builds an OrderSession with checkpointed OrderState (thread id = call id) and LangChain tools:
authenticate_order— mock DB lookup by order id + zipcheck_fulfillment_status— policy gate before modificationschange_shipping_address/cancel_order— allowed only whenunfulfilledhang_up— end the call after the caller says goodbye
Gemini Live receives the tool declarations and dispatches through OrderSession.ainvoke_tool.
Voice prompt rules
The system prompt in prompts.py instructs the agent to:
- Greet inbound callers and collect a test order id (
#1001/#1002) plus zip - Authenticate via the mock database tool (never invent status)
- Speak shipping status in one or two concise sentences
- Check fulfillment before modifications; decline politely when
fulfilled - Say a short goodbye and call
hang_upwhen the caller is done - Keep spoken replies short
Notes
- Keep call control and PCM buffering on the AgentDuet path; put order policy in LangGraph tools.
- Map graph thread ids to stable conversation keys (this sample uses
call.id). - Restarting the process reloads seed orders from
data/orders.json. - This sample uses 24 kHz audio (
CallAudioConfig(sample_rate=24000)).
