{"slug": "your-agent-can-now-debug-workers-with-local-tracing", "title": "Your agent can now debug Workers with local tracing", "summary": "Cloudflare announced that its local development tools, wrangler dev and vite dev, now automatically capture OpenTelemetry traces for local Worker invocations and expose them to AI coding agents through the Local Explorer API, enabling agents to debug issues without manual instrumentation. The feature, available starting today, lets agents query traces and logs with SQL to identify failures, inspect local resources, and verify fixes in a single loop, as demonstrated with a POST /api/orders 500 error caused by a missing D1 migration.", "body_md": "# Your agent can now debug Workers with local tracing\n\nStarting today, `wrangler dev`\n\nand `vite dev`\n\nautomatically 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\n\n[, 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.](https://developers.cloudflare.com/workers/local-development/local-explorer/#use-with-ai-coding-agents)\n\n__Local Explorer API__A prompt can be as simple as:\n\n```\nPOST /api/orders is returning 500. Find the cause, fix it, and verify the fix locally.\n```\n\nThis builds on years of investment in local development, from introducing [ Miniflare](https://blog.cloudflare.com/miniflare/) to making local mode the default in\n\n[. Local traces give coding agents structured feedback from that development environment before code is deployed.](https://blog.cloudflare.com/wrangler3/)\n\n__Wrangler 3__## Agents discover the Local Explorer API automatically\n\nAs part of its normal workflow, an agent starts `wrangler dev`\n\nor `vite dev `\n\nto run and test the Worker. When the development server recognizes a supported coding-agent session, it automatically prints a hint that looks like this:\n\n```\nThis dev session is running in an AI agent.\n\nThe Local Explorer API is available at\nhttp://localhost:8787/cdn-cgi/explorer/api\n\n... \n\nDebug with traces:\nPOST /cdn-cgi/explorer/api/local/observability/query -- query traces and logs with SQL\n```\n\nThe [ 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.\n\nThe 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.\n\n## Find the failure and verify the fix\n\nConsider `POST`\n\n`/api/orders`\n\n, 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.\n\n### Without local traces\n\nThe 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.\n\n### With local traces\n\nThe 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`\n\n, and the Queue was never called. Your agent uses the Local Explorer API to access the same trace data you would see here:\n\nThe 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.\n\nIn one local loop, the agent identifies the failed operation, fixes the local environment, and verifies the result without deploying or adding temporary logs.\n\n## Explore traces and logs in Local Explorer\n\nAgents 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.\n\nLocal Explorer runs on the same localhost origin as your Worker, not in the Cloudflare dashboard. Press e in Wrangler or visit `/cdn-cgi/explorer`\n\non the local server to open it.\n\n## How it works\n\nWhen we launched [ Workers Tracing](https://blog.cloudflare.com/workers-tracing-now-in-open-beta/), we built instrumentation directly into\n\n[, the open-source runtime that powers Workers. Without requiring an SDK or any code changes, the runtime captures spans for:](https://github.com/cloudflare/workerd)\n\n__workerd__**Fetch calls:** All outbound HTTP requests, including timing, status codes, and request metadata.**Binding calls:** Every interaction with KV, R2, D1, Durable Objects, Queues, and other bindings.**Handler calls:** The full lifecycle of each invocation, from`fetch`\n\nto`scheduled`\n\nto queue handlers.\n\nAny [ custom spans](https://developers.cloudflare.com/workers/observability/traces/custom-spans/) emitted by\n\n**your application will also appear alongside these automatic spans.**\n\n[ Wrangler](https://developers.cloudflare.com/workers/local-development/#start-a-local-development-server) and the\n\n[use Miniflare to run your Worker locally in the same runtime, making this instrumentation available during local development.](https://developers.cloudflare.com/workers/vite-plugin/)\n\n__Cloudflare Vite plugin__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.\n\n## Get started\n\nUpdate Wrangler or the Cloudflare Vite plugin, whichever your project uses:\n\n```\n# Wrangler\nnpm install --save-dev wrangler@latest\n\n# Cloudflare Vite plugin\nnpm install --save-dev @cloudflare/vite-plugin@latest\n```\n\nThen 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!", "url": "https://wpnews.pro/news/your-agent-can-now-debug-workers-with-local-tracing", "canonical_source": "https://blog.cloudflare.com/local-tracing/", "published_at": "2026-08-04 13:00:00+00:00", "updated_at": "2026-08-04 13:46:18.377562+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["Cloudflare", "Wrangler", "Vite", "Local Explorer API", "OpenTelemetry", "D1", "KV", "R2"], "alternates": {"html": "https://wpnews.pro/news/your-agent-can-now-debug-workers-with-local-tracing", "markdown": "https://wpnews.pro/news/your-agent-can-now-debug-workers-with-local-tracing.md", "text": "https://wpnews.pro/news/your-agent-can-now-debug-workers-with-local-tracing.txt", "jsonld": "https://wpnews.pro/news/your-agent-can-now-debug-workers-with-local-tracing.jsonld"}}