Claude Code v2.1.145 Adds Agent JSON and Better OTEL Traces: Why Observability Matters for AI Coding Spend
By Eric Bush · May 20, 2026 · 5 min read
Cost Control Starts With Seeing the Agent Tree
Claude Code v2.1.145 includes a small but important observability upgrade: JSON output for live Claude sessions via claude agents --json. It also adds OpenTelemetry attributes for agent_id and parent_agent_id on tool spans, and fixes trace parenting so background subagent spans nest under the dispatching Agent tool span.
For individual developers, this is convenient. For teams running coding agents at scale, it is a cost-control feature. You cannot optimize what you cannot see. When background agents fan out to research, edit, test, and review code, the parent-child trace is how you connect token spend to the actual engineering task that caused it.
Why Agent JSON Matters
A machine-readable session list enables status bars, session pickers, monitoring scripts, tmux restore workflows, and internal dashboards. More importantly, it lets a platform team answer operational questions:
- How many agents are active right now?
- Which sessions are waiting for user input?
- Which long-running tasks are still consuming tools and context?
- Which repositories or pull requests generate the most agent work?
Those are not just productivity questions. They are budget questions. A stale background agent can keep accumulating context and tool results even after its output is no longer needed.
OTEL Traces Turn Token Spend Into Engineering Metrics
OpenTelemetry is useful because it connects agent work to the larger software delivery pipeline. With agent_id and parent_agent_id, a team can attribute cost to a root task instead of seeing a pile of disconnected tool calls. That makes it possible to measure cost per pull request, cost per test generation run, cost per migration, or cost per security review.
This becomes essential in multi-agent workflows. If a planner launches three subagents and one of them reads hundreds of files, the cost should roll up to the planner's task. Without parent-child traces, teams may blame the wrong agent or fail to notice that one workflow pattern is causing the majority of spend.
| Signal | Cost question it answers |
|---|---|
| agent_id | Which agent consumed the work? |
| parent_agent_id | Which root task caused the spend? |
| GitHub repo / PR metadata | Which project or PR is driving cost? |
| waiting-for-input count | Which agents can be stopped or resumed? |
Permission Fixes Also Affect Spend
The release also fixes a Bash permission-prompt bypass and tightens auto-approval for bare variable assignments to non-allowlisted environment variables. That is primarily a security improvement, but it also protects budgets. Unsafe or unexpected commands can trigger expensive loops, external API calls, or broad file reads that inflate token usage.
Good permissions are cost controls. They keep agents inside the intended workflow, reduce accidental blast radius, and make spend more predictable.
How Teams Should Use This Release
- Export live session data into a lightweight dashboard so stale agents are visible.
- Attach token usage to trace spans where your platform supports it.
- Roll subagent cost up to root tasks using parent_agent_id.
- Alert on unusually long sessions or workflows that repeatedly spawn many subagents.
- Review permission allowlists so agents cannot accidentally run expensive or broad commands.
Bottom Line
Claude Code v2.1.145 is not a pricing release, but it matters for pricing. Better session JSON, better OTEL trace structure, and safer permissions help teams understand where AI coding spend goes and which workflows create the best return.
Once you know which agent workflows drive usage, use the AI Cost Estimator to compare model choices and estimate how much you can save with routing, shorter context, or cheaper models.
Want to calculate exact costs for your project?
Related Articles
Claude Code Auto-Runs DNS-Fetched Setup Scripts: Mozilla 0DIN's Disclosure and the Real Cost of AI Coding Agent Trust
Security researchers found a new attack vector on Mozilla's 0DIN bounty: a benign-looking GitHub repo whose setup script pulls payloads from DNS at install time. Claude Code runs it automatically. We dissect the cost of trust failure.
OpenRouter Launches MCP Server: One-Click Model Comparison Without Leaving Your Coding Agent
OpenRouter released an MCP server giving coding agents real-time access to model pricing, benchmark scores, and documentation. We walk through what it does, how to install it in Claude Code or Cursor, and how it changes day-to-day model selection workflow.
AI Coding Agent /goal Modes Compared: Claude Code vs Grok Build vs Codex — Cost of Autonomy
Side-by-side comparison of autonomous /goal modes in Claude Code, Grok Build, and Codex CLI. Per-hour token costs, supervision requirements, and where each one wins on cost.