Audit and Attribution for Every Agent-Consumed API Token
Teams running multiple agents need token attribution by source, harness, credential, and outcome.

When an engineering team runs coding agents across multiple models, harnesses, and tasks at once, the raw token count on a provider bill is effectively unreadable: it cannot tell a leader which task produced a merged pull request, which credential drove runaway consumption, or whether the work was worth running at all. This is not a billing inconvenience. It is a measurement collapse. Without knowing what a token bought, teams cannot validate agent value, set rational budgets, or detect when an agent consumes resources without producing anything reviewable. The fix is a rigorous attribution model that records four things for every run: source, harness, credential, and outcome.
Why token consumption without attribution creates a measurement problem engineering leaders cannot ignore
A provider bill aggregates token consumption across every model, every harness, and every trigger that drew on the account during the billing period. What it does not show is the connection between any individual run and anything an engineering leader would recognize as work: a merged pull request, a resolved ticket, an actionable reply to a code review comment. For a team running one agent on occasional tasks, that gap is manageable because a single engineer retains intuitive oversight of what ran, when, and why. But intuitive oversight does not scale.
As teams delegate more work to agents, and as they begin running several agents side by side, the distance between consumption and outcome widens into a structural blind spot. A team that triggers Claude Code from a Linear ticket, Codex from a GitHub comment, Cursor from Slack, and Opencode from a scheduled automation has, in any given week, dozens or hundreds of runs whose aggregate token count obscures rather than illuminates what actually happened. One run may have consumed an order of magnitude more tokens than another and produced nothing reviewable. One credential may be responsible for a disproportionate share of spend. One harness may be underperforming on a specific class of task. None of that is visible in a total. To answer any question about agent value, cost, or reliability, the consumption must be attributable at the level of the individual run.
The four dimensions every agent token needs to be attributed to
A rigorous attribution model requires four things to be recorded for every agent run: the source that triggered it, the harness that executed it, the credential that paid for it, and the outcome it produced. If you don't know the source, you can't tell whether a triggering channel produces proportional value. If you don't know the harness, you can't compare cost and capability across agents. If the credential is unknown, spend cannot be disaggregated by team, project, or engineer. If the outcome is unknown, a token count is merely a consumption record with no bearing on whether the work was worth running. Collapsing any one dimension leaves an actionable gap in the record.
Source attribution captures where the work originated: a Slack message, a Linear ticket, a GitHub comment, a scheduled automation, or a direct API call. Harness attribution records which coding agent ran, whether Claude Code, Codex, Cursor, or Opencode. Different agents carry different cost and capability profiles, and a team that cannot compare token consumption by harness cannot make an informed decision about which agent to assign to which class of task. Credential attribution identifies which API key or authentication identity paid for the tokens. Without it, shared credentials obscure per-team and per-project spend and make budget enforcement and key rotation impossible to perform with confidence. Outcome attribution records what the run returned: a pull request, a commit, a comment, or a completed task. A token count on a successful merge means something very different from the same count on a run that returned nothing reviewable.
Why harness-level attribution matters more as teams stay agent-agnostic
A team that locks into a single coding agent can approximate attribution by assumption. If every run goes through the same harness, you can infer that harness from context without recording it. But a team that deliberately runs multiple agents for different task types needs harness-level attribution as a first-class record, not a derived inference. Agent-agnostic operation is increasingly the rational default. Models and harnesses improve at different rates, and a team that can only run one agent is structurally slower to benefit from improvements in the others. Otherwise the team loses the ability to determine which agent is actually performing well and which is simply consuming tokens.
Harness attribution enables two decisions that aggregate data cannot. The first is assigning an agent class to a given task type based on cost-per-outcome history. A team that has recorded, over several months, what each harness costs per merged pull request for, say, bug fixes versus feature work, can route new tasks deliberately rather than by habit. The second is knowing when to rotate the primary agent for a workstream because a newer harness is producing better results per token. Replicas runs Claude Code, Codex, Cursor, and Opencode on the same environment primitives, so teams can mix agents across tasks or run several inside one workspace, and every run is attributed to its harness rather than folded into an undifferentiated total.
How the triggering source changes what token consumption means
Source attribution is not administrative bookkeeping. It tells you whether a run was intentional, reactive, or automated, and each category needs a different cost-per-outcome standard. The same token count means different things depending on who, or what, set the run in motion. A run triggered by a Linear ticket represents deliberate engineering intent: a team member read a spec, decided it was agent-ready, and delegated it. The token cost should be evaluated against the ticket's scope and the quality of what came back. A run triggered by a GitHub comment inside a pull request is reactive. An agent was asked to investigate a specific diff, and the relevant metric is whether the comment produced an actionable reply or change, not how many tokens the investigation consumed in total. A run triggered by a schedule or webhook is automated: nobody was in the room, the agent was trusted to operate on a policy, and token consumption should be evaluated against the automation's success rate over time. A single automated run's cost is nearly meaningless without the series it belongs to.
Conflating these three categories produces misleading averages. An automation that runs nightly and consumes a steady stream of tokens, most of which feed reviewable changes, looks different under source-level attribution than the same token volume scattered across one-off Slack requests. Source attribution is what makes that distinction legible.
Credential-level attribution as the mechanism for cost control and key hygiene
Shared API credentials are the default in early agent adoption, and they are the main reason token attribution breaks down at scale. When multiple agents, triggered by multiple sources, draw on the same key, you can no longer disaggregate spend. Credential-level attribution changes that calculus. A leader who can see that a specific credential has consumed a disproportionate share of tokens in a given period can act on it, by throttling, rotating, or investigating, without waiting for an end-of-month bill to arrive.
There is also a control argument that runs deeper than budgeting. Either something is misconfigured or an unauthorized trigger is drawing on the key, and aggregate token counts would never surface that signal. Key rotation, which is good operational hygiene regardless of agent usage, becomes tractable when attribution is credential-level: teams can rotate a key knowing exactly which runs it was responsible for, then verify that runs under the new key produce comparable outcomes. Credential attribution turns key management from an act of faith into an act of inspection.
Outcome attribution: connecting token spend to what actually shipped
A token count without an outcome record is a consumption record, and consumption without production is the definition of waste. The relevant outcomes for a coding agent are discrete and reviewable: a pull request the team can merge, a commit attached to a branch, a comment that answers a specific question, or a completed task that closes a ticket. Each carries a different implied value per token, so averaging them destroys information.
The sharpest distinction in outcome attribution is between a pull request that merges cleanly and one that needs extensive human revision before it is usable. Both may have consumed identical token budgets, and both show up as "PR opened" in a superficial record, but the first represents production and the second represents partial production at best. Over time, outcome attribution by harness, source, and credential produces the data engineering leaders need to make resourcing decisions with evidence rather than intuition: which agent class produces the most mergeable PRs per token for a given task type, and which triggering channel produces the most consistent results.
What a complete attribution record enables that partial data cannot
Each attribution dimension has standalone value, but the compounding insight comes from cross-referencing them. Source, harness, credential, and outcome together answer the question engineering leaders actually ask: are our agents worth what they cost, and which ones, triggered how, by whom? An automation may be triggering correctly but passing the wrong context to the agent, a failure visible only when source and outcome are examined together.
Cross-dimensional records also make the economics of agent adoption legible in terms that can be reported upward. The statement is not "we spent X on tokens this month" but something more precise: agent runs attributed to Linear-triggered Claude Code tasks produced Y pull requests, of which Z merged without revision, and here is the cost per merged PR by harness. Replicas attributes every minute of agent runtime to a source, person, harness, model, and credential, and it surfaces the skills and MCP servers the agent reached for during the run. Customers including Mintlify, Knowunity, Composio, and Dart ship a substantial share of their pull requests through agents on the platform, which at scale requires exactly this kind of attribution to remain legible to engineering leadership.
How sandboxed, per-run environments make attribution reliable rather than approximate
Attribution records are only trustworthy when each run is genuinely isolated. A shared execution environment contaminates the record because token consumption, dependency state, and side effects from one run bleed into another, so you can't draw a clean boundary around what a single run consumed and produced. An isolated VM per agent run is not primarily a security feature. It is an attribution prerequisite. When each run has its own environment, its own dependency set, its own process space, and its own network context, every token and every minute can be attributed to that run without ambiguity about what else might have affected the measurement.
Shared environments also create attribution debt over time. Replicas runs each agent in an isolated Linux VM, configured once with the team's repository, dependencies, services, MCP servers, and skills, so the agent can install packages, run databases, drive a browser, and verify its own work. The isolation is what makes the analytics dependable.
Building an audit and attribution practice: what engineering teams need to put in place
A rigorous audit and attribution practice is not a one-time instrumentation project. It is an operational posture that requires decisions at the team level about what to record, what to review, and what thresholds trigger action, and those decisions should be made before agent adoption scales, not after a billing spike forces the conversation. The first decision is to define attribution requirements before adding harnesses. Teams that start with one agent and later add others face a retrofit problem. The attribution model should be designed to accommodate multiple harnesses, sources, and credentials from the beginning, even if only one is in use at launch. Retrofitting attribution onto an existing multi-agent setup is harder than building it into the foundation.
The second practice is establishing per-credential budgets and review cycles. Credential-level attribution is only useful if someone examines it on a cadence. A monthly review of credential-level spend against outcome data is the minimum. Teams running high-volume automations should review more frequently. No attribution model helps a team that never looks at it.
The third practice is using outcome data to calibrate task delegation. Once cross-dimensional attribution data has accumulated, teams should revisit which task types they are delegating to which agents and from which sources, with the goal of finding the harness-source-task combinations that produce the best cost per merged PR and systematizing them. The final practice is treating attribution data as the input to harness decisions. The case for staying agent-agnostic is that better models and harnesses ship continuously. Per-minute attribution, the kind that records every minute of runtime against a source, person, harness, model, and credential, is what makes that comparison possible.


