Isolating Agent Spend by Engineer When Every Run Lives in Its Own VM
Track agent costs by engineer when VMs provision with identity metadata.

Per-run agent cost attribution for engineering teams depends on attaching engineer identity when each VM is provisioned. A durable attribution record connects the source event, engineer, harness, and model credential to infrastructure usage and LLM consumption. When that record follows the run through shutdown, teams can track costs by engineer and task without reconstructing ownership from aggregate bills.
Why VM-per-run architectures make per-engineer spend attribution both possible and necessary
An ephemeral VM gives each task a distinct infrastructure boundary, but its natural billing unit is the workspace. That distinction becomes consequential when interactive copilots give way to background agents. Instead of token bursts tied to a named editor session, spend accumulates across dozens of parallel, asynchronous runs under a shared team account. Engineer identity must cross that boundary with the task.
Microsoft’s study of its early-2026 rollout of Claude Code and GitHub Copilot CLI describes organizational token spend reaching millions of dollars annually. At that scale, misunderstanding adoption, retention, or output can make a rollout expensive without improving engineering velocity. Disposable, task-scoped VMs make allocation technically tractable because each run already has its own resource boundary. Without provisioning-time attribution, however, billing remains team-level, logs become commingled, and aggregate token burn cannot identify responsibility. Teams then cannot see what drives an infrastructure bill that may grow fast.
How do teams identify which engineer is responsible for each agent run?
Engineer identity is a structured identifier that survives the delay between a human requesting work and a VM executing it minutes or hours later. The attribution tuple connects four components, namely source, engineer, harness, and model credential. The engineer field identifies the person who initiated the run, while the source records whether the request originated in Slack, Linear, GitHub, GitLab, or a dashboard.
The harness field distinguishes Claude Code, Codex, Cursor, and Opencode because model mix and token costs vary. The model credential component identifies the model and API key used for the invocation. A report can group costs by person, integration, or tool only when the underlying records preserve those relationships.
The Microsoft study used individually identifiable AI usage telemetry to distinguish initial use from retention and track output per engineer. That provides a concrete precedent for this level of observability. Unlike surveys or signals inferred from public repositories, direct telemetry connects usage to a known engineer. Agreeing on the schema before the first VM boots prevents partial records that explain harness spend but leave human ownership unresolved.
Why attribution must be wired at VM provisioning time, not recovered afterward
Provisioning binds the queued human request to a specific compute resource. Afterward, the VM operates autonomously, installing packages, forking subprocesses, calling APIs, and writing files. Those activities do not identify the initiating engineer unless the runtime receives that identity at boot.
Code-style matching, commit-message watermarks, and velocity spikes may suggest agent involvement, but they cannot distinguish engineers, interaction modes, or specific tools with the precision required for accounting. Recognizing generated work is different from identifying who commissioned it. A tool signature is not an ownership record.
For a team allocating Tuesday’s hundred agent runs on Wednesday, missing identifiers therefore create a reconstruction problem before accounting can proceed. A retained process in a shared environment may still expose ownership information, but a terminated ephemeral VM no longer has runtime context to query. Resource boundaries make attribution clean only when ownership is recorded before those boundaries disappear.
Where in the VM lifecycle to attach the attribution identifiers
The implementation begins with trigger capture, before compute is allocated. The integration should store the engineer ID, source surface, timestamp, task identifier, and intended harness in a structured queue record. The provisioning request then receives identity from that record rather than attempting to infer it from the environment.
At VM creation, the attribution tuple should become resource metadata through AWS instance tags, GCP labels, or Azure resource tags. Tags hold this data without relying on agent logs. They can be queried through management APIs and used in billing exports, although billing visibility may be delayed and is not retroactive.
Inside the VM, boot-time environment variables such as AGENT_ENGINEER_ID, AGENT_HARNESS, and AGENT_MODEL let the agent emit attributed logs, PR metadata, and tool-call records. This supplies an application-layer counterpart to infrastructure billing. It also allows comparison when a run fails quickly or subprocess activity complicates ownership. Before termination, a shutdown hook should write wall-clock runtime, token consumption where exposed, exit status, and the attribution tuple. That final record closes the run’s ledger without requiring a real-time billing API query.
How harness choice affects what attribution data is available and where to find it
Claude Code has thirty hook events and Dynamic Workflows, so teams can attach data during a session as well as at VM boot. Events at task start, tool call, and session end provide places to emit engineer-attributed telemetry. These hooks enrich the infrastructure record with execution detail. They do not replace the need to establish ownership before the session begins.
Codex provides continuity across CLI, cloud, app, and IDE extension, so one engineer’s session may span multiple compute contexts. Its attribution identifier must therefore follow the session. Headless execution and cloud runners expose separate logs, making session ID the appropriate join key when aggregating across those contexts. VM identity alone describes only one part of that activity.
Cursor Enterprise has native analytics that provide a Cursor-specific view of adoption and how people use the tool. Teams using multiple harnesses need to normalize its per-seat analytics into their shared attribution schema. Without that step, native reporting and infrastructure billing show different parts of the same engineer’s work.
Opencode is permissively licensed, supports 75-plus providers, and offers a headless server for self-hosting. Teams control the execution context and can instrument it directly. That flexibility also leaves attribution to the provisioning implementation in the absence of a default analytics surface. Across these harnesses, the durable schema belongs at the infrastructure layer, while each harness supplies whatever session and consumption detail it exposes.
Integrating attribution identifiers with the surfaces where engineers actually trigger runs
Teams can keep attribution working when each new task captures identity on its own. An engineer launching work from Slack should not need a separate form. A triggering message or slash command supplies user ID, workspace ID, channel, and timestamp to the bot handler. The handler should preserve those fields in the task record before requesting a VM, so provisioning receives ownership as an explicit parameter.
Linear assignment events provide the assignor’s identity and the issue’s project and team context. The assignor can populate the engineer field, the project can identify a cost center or team budget, and the issue can identify the task. Each integration must be clear about who counts as the owner. Otherwise, a field named “engineer” can silently mean requester in one workflow and assignee in another.
GitHub and GitLab issue or comment events provide an actor, repository, and event type. Those fields record who requested the task and what it involves before compute begins. The extraction point differs, but the downstream path does not. Each integration moves identity from event payload to task record, then to provisioning parameters and the VM’s resource tags.
What attribution data makes possible: dashboards, budgets, and retrospectives
Engineer-tagged billing data lets leaders examine who initiates agent work, which models they use, and how spend relates to merged output. Runtime records add detail by source, harness, model, and credential. Billing delays still constrain how current the reports are. The termination record provides a separate accounting event that dashboards can consume without waiting for billing exports.
That accounting event also supports per-engineer budget guardrails. A provisioning service can compare current-period spend with the engineer’s allocation and reject or queue a launch when the limit is reached. The running total must be queryable for enforcement. A final record left only in a log file cannot serve that purpose directly, while a team-wide cap cannot distinguish one engineer’s consumption from another’s.
For retrospectives, spend per merged PR connects cost to an observable output proxy. The Microsoft study used merged pull requests as its output measure while acknowledging that a merged PR is not equivalent to delivered value. LinearB’s 2026 data found that developers in the highest AI usage band merged code at 2.3 times their prior rate. That finding motivates examination of whether engineers receive the same benefit. Attributed records let teams compare harness, model, and task configurations and route future work toward better output-to-cost ratios.
The governance case for attribution: why security and compliance teams require it independently of cost
A named human owner is also the anchor for access reviews, offboarding, and incident response. An agent session without that mapping leaves accountability unresolved even if its total cost is known. Provisioning metadata establishes the resource-to-human relationship. Runtime telemetry must then preserve it through the agent’s actions.
For audit logs connected to a SIEM, file access, shell commands, PR creation, and API calls need that same ownership context. Writing identity into the VM environment allows emitted records to retain the connection. A resource tag on its own does not record every action. The tag and attributed activity logs serve complementary purposes, linking the compute resource and its behavior to the initiating person.
SOC 2 Type 2 audits require evidence that controls operated consistently across the audit period. Retained per-VM attribution records can support that evidence over time. Security therefore needs the ownership mapping even when teams do not use it for financial reporting. Cost allocation becomes an additional use of the same identity instrumentation.
Common failure modes when teams try to add attribution after the fact
Log-based reconstruction joins runtime records to identity directories using timestamps and IP addresses. Shared NAT gateways make IP addresses ambiguous, while clock drift weakens timestamp matching. Subagents that provision further VMs add another break in the ownership chain. The join may look exact even if it loses the link between the task and the person who requested it.
PR-label inference instead treats a label such as agent:claude-code as evidence of who funded the work. A harness label identifies neither the requester nor the payer. Reviewers and mergers may differ from the initiating engineer, and automation accounts may author the PR. Runs that fail before opening a PR disappear from this method entirely.
Seat-based allocation divides the bill by licensed engineers. Eligibility is not the same as actual usage. The Microsoft study separated adopters from the eligible population and found adoption concentrated among more senior, socially connected, and already-active engineers. Uniform allocation obscures that uneven consumption.
Harness-native reporting leaves work out when teams treat one tool’s dashboard as the full ledger. Cursor Enterprise analytics, for example, cover only Cursor out of all the harnesses an engineer may use. Uninstrumented runs then fall outside the reported total. A shared attribution schema, captured from the trigger and attached at provisioning throughout the VM lifecycle, removes the missing-identity premise behind all four approaches.
A practical checklist for wiring attribution into a VM-per-run pipeline
Before the first run, define and version the attribution tuple in the infrastructure repository. Choose a canonical engineer ID, such as email, GitHub username, or an internal LDAP identifier. Locate the identity extraction point for every integration. Confirm which payload field represents the initiating human and preserve it in the task record.
At provisioning, write the tuple as resource tags on every VM, including test and development runs. Pass the corresponding fields into the runtime environment. At termination, flush runtime, available token consumption, exit status, and attribution to a queryable store. Keep the record usable without log reconstruction.
Once the pipeline is running, check per-engineer budgets before each launch. Export billing-tag data to the SIEM on the same schedule as agent activity logs. Review spend per merged PR quarterly to decide where to route work, and keep it out of individual performance scoring. Use those comparisons to find which harness, model, and task type fit the work each engineer does.


