Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jaypopat/cf_ai_duet/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Duet uses Cloudflare Durable Objects to maintain isolated, persistent state for each collaboration room. Each room gets its ownDuetAgent instance that stores conversation history and coordinates with the room’s dedicated sandbox.
DuetAgent State
Each DuetAgent maintains a simple state structure:~/workspace/source/cf-worker/index.ts:18-90
State Isolation
Each room is identified by a uniqueroomId. The worker extracts this from the URL and routes to the appropriate DuetAgent instance:
~/workspace/source/cf-worker/index.ts:67
This ensures:
- Each room has isolated conversation history
- Multiple rooms can operate simultaneously without interference
- State persists across requests for the same room
Message History Management
The DuetAgent maintains conversation history with automatic limits:Recent Context for AI
When generating responses, the agent uses the last 10 messages as context:~/workspace/source/cf-worker/index.ts:154-168
Total History Limit
The agent stores up to 50 messages in total to prevent unbounded growth:~/workspace/source/cf-worker/index.ts:179-180
State Updates
Every message interaction updates the state:- User message is added to history
- AI generates response
- Agent message is added to history
- State is updated with both messages
~/workspace/source/cf-worker/index.ts:147-182
Room Cleanup
When a room is deleted, the DuetAgent resets its state and destroys the associated sandbox:~/workspace/source/cf-worker/index.ts:244-266
The cleanup is triggered via DELETE request from the client:
~/workspace/source/internal/ai/client.go:106-125
Durable Objects Configuration
The worker configuration defines two Durable Object bindings:~/workspace/source/cf-worker/wrangler.toml:6-21
Migrations define the SQLite-backed storage for each Durable Object class.
Next Steps
- Cloudflare Workers - Learn about request routing
- LLM Integration - See how AI responses are generated
- Sandboxes - Understand room-specific sandbox instances