FieldTrip now remembers the trip, checks the weather, researches places, and
writes files. But what if an answer takes a long time? Was the model thinking,
or was the weather service slow?
This step gives you a recording and a timeline. Session replay lets you
follow the messages and tool calls behind an answer. A trace shows how those
steps fit together and how long each took. A log adds a small note from your
code, such as how many forecast days came back.
What you’ll add: settings to collect logs and traces, plus one forecast log.
Then you’ll ask a weather question and follow its journey in the dashboard.
Under the hood: the labels you’ll see in a trace
Flue 2.0.0 and newer adds agent tracing automatically. Each timed section is
called a span: invoke_agent covers the response, chat covers a model call,
and execute_tool covers a tool call. The trace links these sections to show
which operation called which. This checkpoint 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.
Update wrangler.jsonc to enable Workers Logs and Traces. No observability SDK is
required:
wrangler.jsonc
Replace the entire contents of this file. In your code editor (for example, VS Code), open the file named above. Copy the code in Complete file, paste it into that file's editing pane, and save.
What changes: one new observability object enables stored logs and traces
for the deployed Worker. This makes the agent’s existing work inspectable; it
does not add a new planning capability.
Walk through the change
Read the small formatting change first. The comma added after the
containers array allows another property to follow it. The container image,
instance limit, bindings, and migrations keep their checkpoint-5 values.
Enable the log record.observability.enabled: true enables Workers Logs.
Console messages, including the forecast note added in the next file, can be
stored and searched in the dashboard after redeployment.
Enable the execution timeline explicitly.traces.enabled: true enables
Workers Traces. A log records an event; a trace connects timed operations and
shows which operation called which. The two settings serve different purposes.
Connect platform tracing to the agent. Flue installs its Cloudflare
tracing adapter at build time. The enabled traces include invoke_agent
for a response, chat for model calls, and execute_tool for tools. No
application observe() callback or extra observability SDK is needed here.
Deploy, generate work, then inspect it. Editing config does not record
earlier executions. Redeploy and make a fresh weather request so there is a
new run to inspect after ingestion.
Follow it in the workshop: use Session replay to read what happened, then
the trace waterfall to find where time was spent. Parent and child spans overlap,
so adding all their durations together would count some time twice.
Update src/tools/weather.ts to record how many forecast days came back.
Complete file includes both existing weather tools with that one log added,
ready to replace the file. Choose Changes to see where the log was inserted:
src
tools
weather.ts
Replace the entire contents of this file. In your code editor (for example, VS Code), open the file named above. Copy the code in Complete file, paste it into that file's editing pane, and save.
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.',
What changes: a single structured log is inserted in get_forecast, after
the successful response is parsed and before the daily results are returned.
The Complete file tab includes both existing weather tools with this line added.
Walk through the change
Log the application milestone. Reaching this line means the request
succeeded and its forecast response was parsed. HTTP failure paths throw
earlier, so they do not produce this success note.
Use searchable fields.event: 'forecast' gives the record a stable
name. Latitude and longitude identify the queried location, while
days: daily.time.length reports how many daily entries came back. It counts
returned data rather than assuming every requested day was supplied.
Keep diagnosis separate from model output.console.log writes a
diagnostic record; it does not add a chat message or change the { output: ... }
returned by the tool. The model still receives the same forecast objects.
Add detail inside the traced boundary. The existing tool and fetch spans
show timing. This log adds a fact about the result inside that execution,
making the trace easier to investigate.
Follow it in the workshop: find event = forecast in Observability and
compare its days field with the forecast result. Open the correlated trace to
locate the same get_forecast execution.
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
FieldTrip answers the weather question successfully.
Session replay shows it saving the brief, finding the city, and checking the forecast.
The timeline shows the whole reply (invoke_agent), model calls (chat), and tool calls (execute_tool).
You can see how long the model took and how many tokens it used.
You can follow the weather tool’s request to Open-Meteo.
The Observability dashboard shows your forecast note for the same run.
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.