Article summary — original
Cloudflare Enables Local OpenTelemetry Tracing for AI Coding Agents in Workers
Cloudflare has updated wrangler dev and vite dev to automatically capture OpenTelemetry traces during local Worker development. When local development tooling detects an AI coding agent session, it directs the agent to the Local Explorer API to inspect telemetry and debug issues without requiring SDKs, manual setup, or prompt modifications.
Wrangler dev and vite dev automatically capture OpenTelemetry traces and expose them to coding agents via the Local Explorer REST API.
The Local Explorer API features an OpenAPI schema and provides access to correlated console logs alongside state inspection for D1, KV, R2, Durable Objects, and Workflows.
Tracing is instrumented directly within workerd, with Miniflare assembling runtime telemetry and persisting it to an internal SQLite-backed Durable Object on localhost.
Automated Agent Debugging
When an agent runs wrangler dev or vite dev, the server detects the agent session and prints a discovery hint. Through the Local Explorer API's read-only observability endpoint, agents can review execution traces and correlated logs instead of repeatedly adding temporary console logs to identify failing steps. This allows agents to isolate failed operations—such as missing database migrations—in a single local feedback loop before code deployment.
Local Explorer Interface and API
Local Explorer serves as both a REST API for automated agents and a browser-based UI for human developers, hosted directly on the Worker's localhost origin. Accessible via the local server or by pressing 'e' in Wrangler, developers can inspect request spans, timings, attributes, and errors, as well as browse and edit local binding data across Cloudflare primitives.
Runtime Architecture
The feature builds on core instrumentation inside Cloudflare's open-source runtime, workerd, which automatically generates spans across handlers such as fetch and scheduled events, in addition to user-defined custom spans. Miniflare gathers these runtime events and console logs, formats them into OpenTelemetry-compliant records, and stores them in an internal SQLite-backed Durable Object that powers the Local Explorer endpoints.
Saved original article
Starting today, `wrangler dev` and `vite dev` automatically capture [OpenTelemetry traces](https://developers.cloudflare.com/workers/observability/traces/) for local Worker invocations. When Cloudflare's tooling detects an agent session, it points the agent to the [Local Explorer API](https://developers.cloudflare.com/workers/local-development/local-explorer/#use-with-ai-coding-agents), a local debugging API where it can query those traces. You do not need to install an SDK, enable tracing, configure your agent, or even mention observability in the prompt.
A prompt can be as simple as:
This builds on years of investment in local development, from introducing [Miniflare](https://blog.cloudflare.com/miniflare/) to making local mode the default in [Wrangler 3](https://blog.cloudflare.com/wrangler3/). Local traces give coding agents structured feedback from that development environment before code is deployed.
As part of its normal workflow, an agent starts `wrangler dev` or `vite dev` to run and test the Worker. When the development server recognizes a supported coding-agent session, it automatically prints a hint that looks like this:
The [Local Explorer](http://developers.cloudflare.com/workers/local-development/local-explorer) is a browser-based interface and REST API for viewing and editing local resource data and querying observability data during development. The API root serves an OpenAPI schema, so agents can discover available endpoints at runtime without hardcoded instructions.
The automatically captured traces are available through a read-only observability endpoint in that API, together with their correlated console logs. The agent can query this telemetry, then use the API's other operations to inspect local Workers and bindings or examine state in D1, KV, R2, Durable Objects, and Workflows.
Consider `POST` `/api/orders`, which retrieves an active cart from KV, saves the checkout details into D1, and sends a message to a Queue for order processing. After a schema change, the endpoint suddenly starts returning a 500 status.
The 500 does not identify which operation failed. The agent adds logs around KV, D1, and the Queue, reruns the request, inspects the output, and repeats. Each cycle takes time and burns tokens while the agent reconstructs the request from text.
The agent reproduces the error and queries the read-only observability endpoint. The trace shows that the KV read succeeded, the D1 insert failed with `no such column: delivery_window`, and the Queue was never called. Your agent uses the Local Explorer API to access the same trace data you would see here:
The agent uses the API to inspect the D1 schema. It finds that the migration adding delivery\_window exists in the repository but has not been applied locally, applies it, sends the request again, and queries the new trace. Issue resolved.
In one local loop, the agent identifies the failed operation, fixes the local environment, and verifies the result without deploying or adding temporary logs.
Agents query local telemetry through the API, but you as a human can visualize the same data in the [Local Explorer](https://developers.cloudflare.com/workers/local-development/local-explorer/), the browser-based interface built into the local development server. Alongside browsing local binding state, you can select a request to inspect its spans, timing, attributes, errors, and correlated console logs.
Local Explorer runs on the same localhost origin as your Worker, not in the Cloudflare dashboard. Press `e` in Wrangler or visit `/cdn-cgi/explorer` on the local server to open it.
When we launched [Workers Tracing](https://blog.cloudflare.com/workers-tracing-now-in-open-beta/), we built instrumentation directly into [workerd](https://github.com/cloudflare/workerd), the open-source runtime that powers Workers. Without requiring an SDK or any code changes, the runtime captures spans for:
`fetch` to `scheduled` to queue handlers.
Any [custom spans](https://developers.cloudflare.com/workers/observability/traces/custom-spans/) emitted by your application will also appear alongside these automatic spans.
[Wrangler](https://developers.cloudflare.com/workers/local-development/#start-a-local-development-server) and the [Cloudflare Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/) use Miniflare to run your Worker locally in the same runtime, making this instrumentation available during local development.
Miniflare collects runtime events and console output, assembles them into OpenTelemetry traces and correlated logs, then writes the telemetry to an internal SQLite-backed Durable Object that serves as the local trace store. The Local Explorer API exposes that data through the local development server where agents can easily query traces and logs and inspect local state.
Update Wrangler or the Cloudflare Vite plugin, whichever your project uses:
Then ask your agent to debug locally as you normally would. Your agent can already write and run your Worker locally — now it can see what happened, fix what failed, and verify the result before you deploy. Check out the [docs](http://developers.cloudflare.com/workers/local-development/local-explorer/#api) to learn more!