Checkpoint 1 of 6 9 minutes
Hello agent Turn the main-branch starter into a FieldTrip agent with a durable identity, local memory, and a live endpoint.
An agent is an exported, capitalized function whose file starts with 'use agent'.
Flue re-runs that function before every model call. useModel is the one required
hook, and the function name becomes infrastructure: FieldTrip generates
FlueFieldTripAgent and the FLUE_FIELD_TRIP_AGENT binding. Each conversation
ID selects a separate Durable Object with its own SQLite-backed history.
→ Why this matters
Adding an agent is a three-part change: define the agent, mount its route,
and add its Durable Object migration. Missing any one leaves the agent incomplete.
git branch --show-current
Start from main with no local changes. Keep your workshop account exported in
the terminal where you will run npm run deploy.
Delete the placeholder and create the agent file:
src/agents/field-trip.ts+8 −0
New file from main → cp/1-hello-agent
===================================================================
+++ b/src/agents/field-trip.ts cp/1-hello-agent
+import { useModel } from '@flue/runtime';
+export function FieldTrip() {
+ useModel('cloudflare/@cf/google/gemma-4-26b-a4b-it');
+ return `You are FieldTrip, a helpful team-offsite planner. You help groups plan memorable offsites by understanding their destination, dates, headcount, budget, and interests.`;
import { useModel } from ' @flue/runtime ' ;
export function FieldTrip () {
useModel ( ' cloudflare/@cf/google/gemma-4-26b-a4b-it ' );
return ` You are FieldTrip, a helpful team-offsite planner. You help groups plan memorable offsites by understanding their destination, dates, headcount, budget, and interests. ` ;
Update src/app.ts to import and mount the agent:
src/app.ts+3 −0
Changes from main → cp/1-hello-agent
===================================================================
+++ b/src/app.ts cp/1-hello-agent
import { Hono } from 'hono';
+import { createAgentRouter } from '@flue/runtime/routing';
+import { FieldTrip } from './agents/field-trip.ts';
import chatUi from './ui/index.html?raw';
// src/app.ts is the Flue route map. Its default export owns every HTTP request
// A small chat UI for trying the agent in a browser, locally and on workers.dev.
app.get('/', (c) => c.html(chatUi));
app.get('/api/ping', (c) => c.text('pong'));
+app.route('/agents/field-trip', createAgentRouter(FieldTrip));
import { Hono } from ' hono ' ;
import { createAgentRouter } from ' @flue/runtime/routing ' ;
import { FieldTrip } from ' ./agents/field-trip.ts ' ;
import chatUi from ' ./ui/index.html?raw ' ;
// src/app.ts is the Flue route map. Its default export owns every HTTP request
// the Worker receives. Agents get mounted here with createAgentRouter(...)
// starting in checkpoint 1.
// A small chat UI for trying the agent in a browser, locally and on workers.dev.
app . get ( ' / ' , ( c ) => c . html (chatUi));
app . get ( ' /api/ping ' , ( c ) => c . text ( ' pong ' ));
app . route ( ' /agents/field-trip ' , createAgentRouter (FieldTrip));
Update wrangler.jsonc to add the agent’s first migration:
wrangler.jsonc+6 −1
Changes from main → cp/1-hello-agent
===================================================================
--- a/wrangler.jsonc main
+++ b/wrangler.jsonc cp/1-hello-agent
// Durable Object migrations. Flue generates one DO class per agent
// (FieldTrip -> FlueFieldTripAgent), but YOU own the migration history.
// Checkpoint 1 adds the first entry here. Append; never rewrite deployed entries.
+ "new_sqlite_classes": ["FlueFieldTripAgent"]
"$schema" : " ./node_modules/wrangler/config-schema.json " ,
"name" : " field-trip-agent " ,
// Flue requires nodejs_compat and a compatibility_date of 2026-04-01 or newer.
"compatibility_date" : " 2026-09-01 " ,
"compatibility_flags" : [ " nodejs_compat " ],
// Workers AI binding: powers `cloudflare/@cf/...` models. No API keys needed.
// AI always runs remotely (even in `vite dev`), so `remote: true` is explicit.
// Durable Object migrations. Flue generates one DO class per agent
// (FieldTrip -> FlueFieldTripAgent), but YOU own the migration history.
// Checkpoint 1 adds the first entry here. Append; never rewrite deployed entries.
"new_sqlite_classes" : [ " FlueFieldTripAgent " ]
Account selection comes from CLOUDFLARE_ACCOUNT_ID, set in your terminal during
Session setup . Keep the account ID out of wrangler.jsonc.
npm run smoke -- https://field-trip-agent.<subdomain>.workers.dev cp1-live " Hi, who are you? Two sentences. "
npm run smoke -- https://field-trip-agent.<subdomain>.workers.dev cp1-live " What was the first thing I asked you? One sentence. "
Use the exact URL printed by the deploy command. The deployment should list the
AI binding and FlueFieldTripAgent Durable Object. The first command should end
with ✔ completed; the second should recall your introduction question.
In Terminal A, start the dev server and leave it running:
Wait for VITE ... ready, then run in Terminal B:
npm run smoke -- http://localhost:5173 cp1-local " Hi, who are you? "
npm run smoke -- http://localhost:5173 cp1-local " What was the first thing I asked you? One sentence. "
The first command should end with ✔ completed. The second should recall
Hi, who are you? because it uses the same conversation ID.
Open local chat in your browser ↗ http://localhost:5173/?id=cp1-local
This opens the same conversation as the smoke test. If you repeat this checkpoint, use a fresh test ID before copying its commands.
The deployed smoke test exits successfully and introduces FieldTrip. A second message with cp1-live recalls the first. The browser-test link opens your deployed chat and the same conversation.
Optional mini quiz Check the agent foundation 3 questions / instant feedback
Option 01 Restart this exercise Return to main, rebuild this exercise, then use its Live deploy verification tab. Stop any running dev server with Ctrl+C before switching.
git stash push --include-untracked -m "workshop recovery"
git fetch origin
git branch -f workshop-backup HEAD
git switch --no-track -C workshop origin/main
npm ciOption 02 Catch up with the room Jump to cp/1-hello-agent, then use this checkpoint's Live deploy verification tab. Stop any running dev server with Ctrl+C before switching.
git stash push --include-untracked -m "workshop recovery"
git fetch origin
git branch -f workshop-backup HEAD
git switch --no-track -C workshop origin/cp/1-hello-agent
npm ci
Next: Add persistent state →