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 includes an AI assistant that acts as an additional pair programmer in your session. It’s powered by Meta’s Llama 3 8B model running on Cloudflare’s edge network, providing fast responses without leaving your terminal.Activating the AI
PressCtrl+G while in a room to open the AI input prompt:
Type your question
Ask anything about your code, request help with commands, or get debugging suggestions:
The AI assistant requires a Cloudflare Worker URL to be configured when starting the Duet server:
AI architecture
The AI runs as a Cloudflare Durable Object, maintaining conversation state per room:- Model
- Context window
- System prompt
Llama 3 8B Instruct
- 8 billion parameter model
- Optimized for instruction following
- Runs on Cloudflare’s global network
- Typical response time: 1-3 seconds
AI sidebar
The AI chat appears in a collapsible sidebar on the right side of your terminal:Keyboard shortcuts
| Key | Action |
|---|---|
Ctrl+A | Toggle AI sidebar visibility |
Ctrl+J | Scroll chat down (3 lines) |
Ctrl+K | Scroll chat up (3 lines) |
Ctrl+G | Open AI input prompt |
The AI sidebar only appears when your terminal is at least 120 columns wide and 24 rows tall. On smaller windows, the feature is automatically disabled.
Command execution
The AI can execute commands in a Cloudflare Sandbox by wrapping them in<run> tags:
Example conversation
Conversation persistence
AI messages are synchronized across all participants in real time:- The response is stored in the room’s shared state
- An
ai_syncevent is broadcast to all participants - Everyone’s AI sidebar updates to show the new messages
Late joiners can see the full AI conversation history when they enter the room. The last 50 messages are kept in memory.
Message format
Each message in the conversation includes:API endpoints
The Cloudflare Worker exposes these AI endpoints:Send a message to the AIRequest body:Response:
Clean up AI state and sandbox for a roomCalled automatically when the last participant leaves.Response:
Client implementation
The Go client communicates with the Worker:Error handling
No Worker URL configured
No Worker URL configured
If you press Start the server with the
Ctrl+G without a Worker URL:--worker flag.Request timeout
Request timeout
If the AI doesn’t respond within 30 seconds:Try again or check your Worker status.
Validation error
Validation error
Empty messages are rejected:
Best practices
Be specific
Instead of “help with this code”, ask “how do I parse JSON in Go?”
One question at a time
The AI works best with focused questions. Break complex tasks into steps.
Include context
Mention what you’re trying to do: “I’m debugging a Python script that…”
Review commands
Always verify AI-suggested commands before running them in your terminal.
Limitations
- The AI doesn’t have access to your terminal history or current directory
- It can’t see files in your workspace (only in its own sandbox)
- It doesn’t remember conversations across different rooms
- The 10-message context window means very long discussions may lose coherence
Next steps
Sandbox execution
Learn how the AI’s command execution sandbox works
Deploy a Worker
Set up your own Cloudflare Worker for AI features