AI briefing agent on Cloudflare for the Agents assignment.
Chat for quick answers. Ask for a brief and a durable Workflow plans, drafts, revises, and saves it. Preferences and finished briefs survive refresh via Durable Object SQLite.
| Requirement | Implementation |
|---|---|
| LLM | Workers AI @cf/meta/llama-3.3-70b-instruct-fp8-fast (Llama 3.3) |
| Workflow / coordination | BriefingWorkflow (AgentWorkflow) with plan → draft → revise → save |
| User input | React chat UI (useAgentChat) over WebSockets |
| Memory / state | Chat transcript in SQLite; preferences + saved briefs in agent state |
- Cloudflare Agents SDK (
AIChatAgent, Durable Objects) - Workers AI via
workers-ai-provider - Cloudflare Workflows via
agents/workflows - Vite + React frontend served as Worker assets
npm install
npx wrangler login # required: local Workers AI uses a remote binding
npm run devOpen the printed local URL (usually http://localhost:5173).
Without wrangler login (or CLOUDFLARE_API_TOKEN), npm run dev and deploy will fail because ai.remote is enabled in wrangler.jsonc.
- Click Prefer short bullet briefs with an executive tone (or type it). Confirm Preferences in the Memory panel update.
- Click Brief me on Cloudflare Durable Objects (or ask for any brief). Watch Active brief steps: plan → draft → revise → save.
- Refresh the page. Chat history, preferences, and the saved brief should still be there.
- Click the saved brief (or ask what it covered). The agent should use memory.
npx wrangler login
npm run deploysrc/server.ts—BriefingAgent(chat, tools, memory callbacks)src/workflow.ts—BriefingWorkflow(durable multi-step brief)src/app.tsx— chat + Memory panelsrc/types.ts— shared types and model idwrangler.jsonc— AI, Durable Object, and Workflow bindings
- Each browser gets a stable agent instance id in
localStorage(briefly-session-id) so refresh reconnects to the same Durable Object. - Clearing chat only clears the transcript; preferences and saved briefs remain until you wipe the Durable Object / use a new session id.