ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsMaterial3 min readDisconfirmAI Editorial

Pydantic Engineer Duncan McKinnon: Enabling Coding Agents to Query Their Own Traces, Turning Repeated Failures into Verified Skills

The opacity of coding agent processes is one of the major challenges. Duncan McKinnon proposes using the Logfire MCP server to allow agents to query their own historical trace records, forming a closed-loop improvement process from failure evidence collection and skill creation to controlled experiment verification. Specific experimental data is provided through two cases: querying skills for dashboard panels and selecting code review agents.

2026-11-13 17:00 GMT+8

Coding agents read files, query databases, call tools, and edit code in the background, while people outside the terminal only see a line saying "working on it...". Model invocations, tool executions, retries, and dead ends all occur out of sight, without records or the ability for long-term reflection. Pydantic engineer Duncan McKinnon believes that process opacity is one of the major challenges currently facing coding agents. Trace data should not be used solely for passive monitoring; instead, the Logfire MCP server should enable coding agents to query their own historical operation records, forming a closed-loop improvement process from failure evidence to skill creation and finally to experimental verification.

The specific path involves four steps. First, collect evidence from traces. McKinnon found that he repeatedly encountered invalid queries and rework when creating dashboard panels, so he used the Logfire MCP to search coding agent traces, pinpointing specific correction records in each case—for example, a query that double-counted cached input tokens in one instance. Second, identify the correct path with the agent and create skills, encoding patterns from historical successes and failures into reusable workflows. Third, run controlled experiments using the same agent configuration, sessions, and prompts, varying only whether the skill is loaded. Fourth, verify whether the improvement truly solved the problem without introducing new issues.

He selected 12 dashboard panel creation scenarios, which included various errors, and ran them on the same Codex agent both with and without the newly created logfire-dashboard-query skill loaded. Without the skill, 9 out of 12 runs failed, and formatting errors appeared; with the skill, all scenarios succeeded, raising the assertion pass rate from 57/72 to 72/72, with sql_executes improving from 25% to 100%.

Sign in / Sign up
ReadingResearchRadarInvestment framework

The same closed-loop approach was also applied to agent configuration evaluation. In McKinnon's software factory pipeline, the review-fix phase ($43.30) and the review phase ($36.80) together accounted for about 60% of the $132 total cost, indicating that the agent was stuck in a cycle of reviewing and fixing. He collected 5 small PR review cases from traces, built a dataset, and then ran controlled experiments on Claude Code (haiku-5.5), Codex (gpt-6-luna), and Cursor (composer-2.5). Using two evaluation criteria—whether the review was overly nitpicky about format and style, and whether it adhered to the coding conventions specified in the instructions—the results showed that Codex scored highest on every panel (overall 3.93), followed by Cursor (2.80), with Claude Code scoring lowest (2.60).

The boundaries of this method are also clear. It relies on Logfire's ability to capture traces for specific agents and providers, and cost estimates cover only instrumented calls. Experimental conclusions are limited by the specific task types and the design of the evaluation criteria. McKinnon himself stated that these examples are "not comprehensive," but they represent the use cases he has seen having the greatest impact within his team.

Sources

  • pydantic.dev↗
Continue researching →