AI Agent - Aug 6, 2026

How to Debug Cloudflare Agents Tool Calls

Quick answer

To debug a Cloudflare Agents tool call, use three layers in order:

  1. session replay for the recorded instructions, message, tool choice, arguments, result, and response;
  2. the agent trace for model, tool, approval, retry, subagent, token, and timing context;
  3. the full Workers trace for fetch, D1, KV, Durable Object, service-binding, and SDK spans.

Then reproduce the confirmed failure in a bounded test. A trace explains execution; it does not establish the correct answer by itself.

Tool-call triage

SymptomFirst checkNext check
Wrong tool selectedInstructions and available context in replayRouting prompt and regression case
Malformed argumentRecorded tool argumentsSchema validation and argument construction
Tool timed outTool span duration and statusChild fetch or binding spans
Duplicate side effectRetry pattern and tool callsIdempotency key and source-system log
Approval bypassedApproval event and scopeEnforcement point and destructive-action test
Stale resultRecorded result and timestampsSource freshness and cache behavior
Subagent driftParent/child trace nestingDelegated instructions and returned artifact

Debugging sequence

  1. Record the affected agent, conversation, turn, deployment, and trace identifiers.
  2. Confirm whether message and tool payloads were captured.
  3. Compare the selected tool with the user’s authorized intent.
  4. Validate arguments, scope, destination, timeout, and retry count.
  5. Follow the tool span into the relevant Worker infrastructure spans.
  6. Reconcile the tool result with the source system.
  7. Check whether the final response preserved uncertainty and failure state.
  8. Add a test covering selection, arguments, idempotency, approval, and response handling.

For data-capture boundaries, use the session replay privacy guide. For the two trace layers, use Agents vs Workers observability.

Frequently asked questions

Where should I start?

Use replay for context, the agent trace for behavior, and the Workers trace for infrastructure.

Can HTTP 200 still be an agent failure?

Yes. Tool selection, stale context, retries, or the final answer can be wrong despite a successful request.

Should I capture every payload?

No. Use payload recording only when its debugging value is compatible with the data, access, and retention policy.

Official sources

Source check: August 6, 2026. Verify current capture controls, supported spans, and access boundaries for the selected harness.