Flue 2.0.0 and newer adds agent-shaped spans to Cloudflare automatically. One
response becomes an invoke_agent trace, each model turn becomes a chat span,
and each tool call becomes an execute_tool span. The trace keeps the causal
tree and timing. Cloudflare’s consolidated observability experience puts those
traces beside the Worker’s structured application logs.
This checkpoint follows cp/6-iterate-observe: it enables Workers Logs and Traces
in wrangler.jsonc and adds one structured forecast log in
src/tools/weather.ts. Flue installs its tracing adapter at build time, so no
manual observe() callback is needed.
In src/tools/weather.ts, add the structured log after parsing daily and
immediately before the forecast return. The diff shows the insertion in context;
Complete file includes both weather tools:
82: 'violent showers', 95: 'thunderstorm', 96: 'thunderstorm with hail', 99: 'severe thunderstorm with hail',
};
const isoDate = v.pipe(v.string(), v.isoDate());
export const getForecast = defineTool({
name: 'get_forecast',
description:
'Get the daily weather forecast (min/max °C, chance of rain, conditions) for a latitude/longitude between two dates (YYYY-MM-DD). Only works up to 16 days ahead. Get coordinates from geocode_city first.',
The trace already records the tool boundary and outbound fetch. This log adds the
application fact that a forecast was successfully parsed and how many days it
contained. It is diagnostic data, not model context.
npmrunsmoke--https://field-trip-agent.<subdomain>.workers.devcp6-live"Offsite in Lisbon from <START> to <END> for 14 people. Save the brief, then check the weather."
Use a fresh conversation ID and the exact deployed URL. The response should save
the brief, call geocode_city, call get_forecast, and return the forecast.
This opens the same conversation as the smoke test. If you repeat this checkpoint, before copying its commands.
This confirms the same agent behavior locally. Use the live deployment to inspect
the persisted session replay and trace waterfall in the Cloudflare dashboard.
Expand invoke_agent FieldTrip, the span for the complete response.
Inspect each chat @cf/google/gemma-4-26b-a4b-it span for latency and token usage.
Inspect execute_tool save_trip_brief, execute_tool geocode_city, and execute_tool get_forecast.
Expand get_forecast and follow its outbound fetch to Open-Meteo.
Compare the span durations. Do not add parent and child durations because they overlap.
The admission POST returns before the durable response finishes. The agent run in
the Agents dashboard is the complete turn, not only that short HTTP request.
Filter to the field-trip-agent Worker and the time range of your cp6-live-… run.
In Events, filter event = forecast and open the successful forecast log.
Open the correlated trace from the event context.
Confirm that the same execution contains execute_tool get_forecast and its Open-Meteo fetch.
Use Agents for the agent-native session replay and trace waterfall. Use the
consolidated Observability view when you need agent spans, Worker invocations,
subrequests, and application logs in one operational investigation.
Verification gate
Prove it works
The deployed forecast smoke test completes successfully.
Session replay shows the model and tools in execution order.
The trace has an invoke_agent root with chat and execute_tool spans.
The model span reports token usage.
The forecast tool contains the outbound Open-Meteo request.
The consolidated Observability view contains the structured forecast event for the same execution.
Optional mini quizCheck the execution story3 questions / instant feedback
Recovery lane
Get back on track in under a minute
If a dev server is running, stop it first. Uncommitted work is stashed and the current commit gets a backup branch before anything moves.
Option 01
Restart this exercise
Return to cp/5-sandbox, rebuild this exercise, then use its Live deploy verification tab. Stop any running dev server with Ctrl+C before switching.
The completed upstream branch already enables traces. The catch-up commands keep
the checkpoint-5 agent so the on-demand workspace change remains a bonus exercise.