Coding Agent Cost Tracking: Observe, Cap or Stop
Coding agent cost tracking now comes in three kinds, and they answer different questions. Observability tools tell you where the money went: by pull request, developer, model or branch. Gateways cap model calls: past a budget, requests fail. A budget on the work itself stops a group of agents as a unit, with their claims released and their open questions closed. This article compares the three from each product's own pages, read on 25 Nov 2026, and says what each cannot see.
Kind 1: observe
LangSmith for coding agents
LangChain's "LangSmith for Coding Agents: Now track spend by outcome" (18 Nov 2026) attributes spend to pull requests. A concept called outcomes "links GitHub pull requests or GitLab merge requests to threads", and "the spend in each trace is automatically attributed to pull requests each agent contributed to." One thread can feed several pull requests and one pull request can take several threads. Spend that never produced a pull request is shown separately as unattributed. Pull requests are broken down by state (open, closed, merged), work by type, and cost by model, skill and thread length. An expensive pull request traces back to "the GitHub user behind it."
It supports Claude Code, OpenAI Codex, Cursor, GitHub Copilot in VS Code and Deep Agents, through a LangSmith plugin per agent. Coding agent traces count toward ordinary LangSmith tracing usage. The post describes no feature that caps spend or stops an agent.
Braintrust coding agent insights
Braintrust's "Optimizing coding agent usage and costs" (7 Oct 2026, public preview) shows cost and tokens over time by developer, model, tool, branch or API key, with the sessions behind each row. It covers Claude Code, Codex, OpenCode and others through its bt tracing integration, enabled by each team member in their own setup. Braintrust is candid about accuracy: "Costs come from traced model calls and may differ from your provider's subscription bill." No cap or stop is described.
What observing is good for: learning which work is worth its cost, coaching, choosing models. A pull request that cost $40 and was closed unmerged is the kind of thing only this kind of tool shows.
What it does not do: act. A runaway agent at 3 a.m. shows up in the dashboard in the morning.
Kind 2: cap model calls
Portkey
Portkey's platform team guide to coding agents (24 Apr 2026) says its CLI setup configures gateway routing for Claude Code, including "hard budget limits per developer or team." Its budget limits docs describe what happens: a cost limit, "once reached, will automatically expire the key to prevent further usage and overspending." Limits can be in dollars or tokens, reset weekly, monthly or never, and can send an email alert at a threshold while the key keeps working. The minimum is $1 or 100 tokens. Models without pricing data do not count toward a cost limit. The docs say the feature is available on the Enterprise plan and to select Pro customers.
Cloudflare AI Gateway spend limits
Cloudflare's changelog (5 Jun 2026) describes spend limits as "cost-based budgets that track cumulative dollar spend and block requests when the budget is exceeded." They can be scoped by model, provider or custom metadata such as user or team, over a fixed or sliding window, and apply only to models with known pricing.
What capping is good for: a hard ceiling per key, person or team that nothing can exceed by much. It is the right control for "no developer spends more than $500 a month."
What it does not do: know about the work. When the key expires mid-task, the agent's next model call fails. Whatever the agent was doing stops at an arbitrary point: a half-written file, a claim on paths it still holds, a question waiting for a person who will answer an agent that can no longer act. And a cap on a person's key does not distinguish a planned run of twelve agents from one agent looping.
Kind 3: stop the work
Forkit puts the budget on a unit of work: a fan-out, the group of agents one planner starts for one job.
forkit fanout create migrate-billing --agents 12 --max-cost 10
What happens, from Forkit's engineering notes (migration v18 and the 21 Nov 2026 cost work):
- How cost is known. Claude Code gives hooks no cost, so Forkit's hook reads the tokens of each model reply from the session's transcript and its subagents' transcripts, counting each reply once, and reports them at the end of a turn or session and at most every 20 seconds during a turn. For Codex it reads the session file's running totals. Any other agent reports with
forkit usageorPOST /api/v1/usage, either as tokens or as its own dollar figure, which is used as given. - How tokens become dollars. Hand-checked prices for Claude models; a catalog of about 1,500 models from LiteLLM's public price file, shipped with the service and refreshed daily; an unknown model priced as expensive ($10 in, $50 out per million tokens) and flagged, so a missing price cannot switch a budget off. A fetched price replaces a shipped one only within a fifth to five times it, so a catalog error that says a model is nearly free is ignored.
- At 80% of the budget, the fan-out is marked with a warning, shown in its views.
- At the budget, the fan-out is stopped in the same database update that adds the cost. Stopping does four things at once: every key of the fan-out answers further requests with a stop and its reason (the hook tells the agent to stop and refuses the tool in hand), its pending permission requests are denied, its file claims are released, and its working threads move to idle.
So when the budget runs out, the group ends tidily: no agent holds a file another needs, and no person is left with a question from an agent that has already stopped.
How accurate it is. Every figure is an estimate. Prices are list prices; all cache writes are priced as 5-minute writes; the transcript format Forkit reads is one the docs call internal. A fan-out can pass its budget by what its agents spend in about 20 seconds, the reporting interval. On staging, Forkit's count for real Codex 0.160.1 sessions matched Codex's own total exactly (31,731 tokens); the first attempt found a bug where the model name was forgotten, since fixed with a test. In a recorded run of twelve Claude Code agents testing hypotheses about a public dataset (20 Nov 2026, staging, one run), the fan-out showed about $1.24 of its $10 budget.
What it does not see: agents that report nothing. A custom agent that never calls forkit usage is invisible to the dollar budget; for those, set --max-tool-calls, which Forkit counts itself. Tiered prices are not modelled, and OpenTelemetry is not a source yet.
The three kinds in a table
| Observe (LangSmith, Braintrust) | Cap calls (Portkey, Cloudflare) | Stop the work (Forkit) | |
|---|---|---|---|
| Question answered | Where did the money go? | Can this key spend more? | Should this job continue? |
| Unit | PR, developer, model, branch, key | Key, user, team, model | Fan-out (one job's agents) |
| At the limit | Nothing; it reports | Key expires or requests are blocked | Agents told to stop; claims released; requests denied |
| Source of cost | Traces | Gateway requests | Transcripts, session files, agent reports |
| Accuracy | "May differ from your provider's bill" (Braintrust) | Priced models only | Estimates at list price |
| Blind to | Agents without tracing set up | Calls that bypass the gateway | Agents that report no usage |
They combine
These are layers, and a team running agents at scale may want all three:
- A gateway cap per person or team as the ceiling nothing crosses, in Portkey or Cloudflare.
- A budget per job so a single run of agents ends cleanly when it costs more than it is worth, in Forkit.
- Observability to learn, after the fact, which jobs and which models paid off, in LangSmith or Braintrust.
One caution about combining a cap with a job budget: if the gateway cap is lower than the job's budget, the cap wins and the agents stop the untidy way. Set job budgets inside the caps.
Forkit also records cost per run for its factories (saved fan-outs started by a webhook or schedule; not the company Factory): forkit factory show gives cost in all and per run beside the pass rate among judged runs, so you can see what each accepted result cost.
Related: how to stop a runaway agent, agent fan-out explained, the field guide to running agent teams and how to set a dollar budget for a fleet of coding agents.
Where Forkit fits
Forkit is the coordination system for agent teams: plans, handoffs, file claims and decisions, shared by every agent and the people behind them. It runs no agents. It is free to try at forkit-mcp.com.
Sources
Read on 25 Nov 2026:
- LangChain, "LangSmith for Coding Agents: Now track spend by outcome", 18 Nov 2026, https://www.langchain.com/blog/langsmith-coding-agents-roi
- Braintrust, "Optimizing coding agent usage and costs", 7 Oct 2026, https://www.braintrust.dev/blog/coding-agent-insights
- Portkey, "Who owns Claude Code at your company? A platform team's guide", 24 Apr 2026, https://portkey.ai/blog/platfrom-guide-to-coding-agents/
- Portkey docs, budget limits, https://portkey.ai/docs/product/ai-gateway/virtual-keys/budget-limits
- Cloudflare changelog, AI Gateway spend limits, 5 Jun 2026, https://developers.cloudflare.com/changelog/post/2026-06-05-spend-limits/