Agent in Production

Using Git Blame and Merge History as the Full Audit Trail for Agent Behavior in Production

Commits record intent, not the prompts, models, and reviews behind agent code.

· 8 min read
Cover illustration for “Using Git Blame and Merge History as the Full Audit Trail for Agent Behavior in Production”
Agent-as-Code Patterns · November 24, 2026 · 8 min read · 1,850 words

Git blame and merge history are not a full audit trail for agent behavior in production. Agents-as-code puts agent definitions in version-controlled configuration files such as agents.yaml, so the instructions can go through the same code review as other code. Configuration records intent. A genuine audit trail must capture prompts, model versions, tool actions, and review status at session time, then link those records to the code and deployment.

Why git blame gives a confident answer that is now usually wrong

An authentication-token middleware change includes “skip checking expiration. Git blame identifies the developer who committed it, but that attribution cannot establish who chose the behavior. The developer may have typed a prompt, accepted an agent’s edits, and committed the result. Git records only that last step of the interaction. The prompt, model version, and depth of human review vanish unless another system captures them.

The usual reading of blame assumes a human typed the line, knew what it was meant to do, and can explain it. AI-assisted workflows break that connection between authorship and intent. CloudBees’ May 2026 research found that AI generates or assists in writing 61% of the average enterprise codebase, while most organizations still lack attribution controls for that volume. The same research found that a strong majority of leaders said they had more production issues tied to AI-generated code.

What the blame record actually shows during an incident or audit

A vulnerability surfaces in a payment module eight months after the commit, and the engineer who pushed it has left. Legal asks whether the code was human-written, AI-assisted, or agent-produced in CI, and whether anyone reviewed it. The name, timestamp, and diff cannot answer those questions. An approval does not reveal what the reviewer examined, while a bot account identifies an actor without explaining its decisions. Model provenance is absent from both records.

AI-assisted commits may follow a prompt rather than a ticket, and squashing sessions into one commit removes rejected approaches and human modifications from view. “Add validation logic” supplies no traceable requirement. The row-level security example exposes a different omission, where agent scaffolding produced a working schema without enabling the setting, no ticket requested it, and no reviewer flagged its absence. Mandiant’s M-Trends 2026 describes the parallel consequence of logging gaps in incident response, where an inability to prove intrusion scope can force worst-case assumptions and disclosure.

How multi-agent workflows make the provenance problem structurally invisible

Agent A refactors a payments file on one branch while Agent B fixes a rounding bug on another branch cut from the same base. Neither sees the other’s work. Git’s three-way merge resolves the text cleanly, but the refactor has deleted a helper function that the rounding fix still calls. The unit test that would have caught the problem was removed as “no longer relevant.” The bug ships without a merge conflict identifying the semantic break.

Without session capture, no log entry establishes that two agents worked on the file without seeing each other’s changes. A chain of agents creates a related attribution loss when one generates code, another reviews and modifies it, and a third commits under its human operator’s identity. Blame exposes the final attribution. Across a forty-engineer team, concurrent sessions create untracked shared-file changes faster than manual review can reliably reconstruct them.

What compliance frameworks and auditors now require that git cannot supply

Vendor security questionnaires ask how AI is used in development, what data models receive, and what human oversight exists. A policy alone does not demonstrate that oversight. ISO/IEC 42001 expects documented operational records of AI use, while SOC 2 and ISO 27001 auditors seek evidence of governed processes. SOC 2 Type II practitioners ask about AI-assisted code provenance, tool inventories, access controls, and review procedures. An inability to show that AI-assisted code passes through the same controls as human-authored code can become a finding.

The EU AI Act began to apply in most cases on 2 August 2026, with some exceptions. Article 12 requires high-risk systems to have the technical means to record events automatically throughout their lifetime. Articles 19 and 26(6) require retention for at least six months, or longer where other law requires it. The Digital Omnibus pushed back Annex III high-risk obligations to 2 December 2027 but left these logging requirements unchanged. These provisions concern high-risk systems.

Acquisition due diligence also asks which AI tools are used, how much code they generate, and what records show how their use is governed. Missing evidence can affect valuation as well as compliance. The common requirement is traceability of the action, the data used, and the policies applied during execution. A commit cannot supply that evidence merely because it preserves the resulting code.

Why post-hoc reconstruction from commit metadata cannot close the gap

An AI-code detector gives a probability of whether code looks machine-generated. It cannot recover the model version, original prompt, human modifications, or review status, and its accuracy degrades on short functions and heavily edited output. Code rewritten by a developer after a suggestion further weakens the inference.

AI-Assisted, Generated-By, and Prompt-Ref can make involvement machine-readable and ALM-parseable when enforced through commit-msg hooks or server-side pre-receive checks. Added after the fact, however, they preserve what the developer declares. They do not capture tool calls, intermediate steps, or rejected approaches. A trailer can reference a captured session, but it cannot substitute for one.

What a real audit trail for agent behavior has to record, and when it has to be captured

Diagram: The Five Layers of a Real Agent Audit Trail. Visualizes: Show a stepped or layered flow of the five components that must be captured during execution to constitute a genuine agent audit trail.

Session-level provenance starts with who took part, including the person or service account that started the interaction. It also records the specific model and version, because behavior changes between versions. Input and output connect the prompt to the generated code. Chain linkage then links prompt, code, review, and deployment so they can be traced in order across the systems that hold the evidence. Review status must be explicit even when a merge exists.

Agent work requires a record of the intervening actions. Tool invocations, touched files, and sub-agent contributions make the session reviewable step by step. An autonomous agent also needs its own named non-human identity that has least-privilege credentials. Its tool-invocation trail must be kept long enough to meet the rules that apply. These artifacts must be captured during execution, while the interaction and its context still exist.

How existing tools approach session-level capture, and what each still misses

Diagram: What Each Tool Captures — and What It Still Misses. Visualizes: Show a ranked or grid comparison of five agent session-capture tools against the key provenance gaps they leave open.

Aider commits agent actions to Git natively, preserving changes without requiring a separate manual commit for each action. Its diff does not capture the producing prompt or model. aGiTrack extends that approach by wrapping terminal agents and committing each turn with the prompt, backend, model, and token counts in the commit message, with sub-agent tokens counted separately. The trace therefore lives in version control.

Claude Code stores transcripts at ~/.claude/projects/, with a trace of multi-step work across files. Local storage is the governance gap in that approach. The transcript must be explicitly captured and moved into a governed log store. Devin’s documentation describes a unified Progress view of shell commands, code edits, and browser activity, including command outputs. That is execution visibility, although the described view alone does not establish every identity, retention, and deployment-linkage property of a complete audit trail.

Agent Trace RFC v0.1.0, published January 2026, defines a vendor-neutral JSONL attribution format. Each implementation decides how to store the records, and the reference implementation uses .agent-trace/traces.jsonl, which is committed beside the code. The format does not prescribe a governed storage system. LineageLens instead intercepts traffic between the terminal and provider, parses structured tool calls, and tracks proposed edits and whether the developer applied them. Its local searchable trail connects code to the model and exact prompt, while leaving the broader execution controls to other infrastructure.

How do agent definitions stored in Git become reviewable governance artifacts?

Agent definitions stored in Git become governance artifacts when their changes receive the same review as code that controls production behavior. Files such as CLAUDE.md, AGENTS.md, and agents.yaml separate instructions from implementation and make behavior diffable, reviewable, and reversible. This is the agents-as-code model. Configuration in a structured data format can serve as a versioned definition, but a file format alone does not establish that a platform can declare an entire agent without implementation code. The named tools’ capture capabilities do not establish that broader platform claim.

In the two-layer model, CLAUDE.md expresses behavioral intent that becomes the system prompt, while settings.json constrains capabilities, much as IAM policies constrain cloud actions. A change to database-migration instructions should receive the same review as a change to migration logic. Version control then provides a rollback path if the updated instructions produce poor decisions. Without that history, a session log shows what happened but cannot establish which instructions governed it.

What managed infrastructure adds that session logs and config files alone cannot provide

Capture and versioned configuration address attribution. An agent with broad credentials on shared infrastructure can still act outside its intended scope. Governed execution therefore adds isolated sandboxes, credentials minted per session and revoked on completion, and hard budget caps enforced before spending. Every tool call, diff, and token must also be attributable to a person or trigger.

Running Claude Code or Codex on a laptop can leave transcripts in local directories, persistent credentials, and concurrent sessions without isolation or budget enforcement. That architecture helps explain why adoption can outrun instrumentation. Managed infrastructure adds the controls around the agent, rather than relying on each developer to assemble them. Versioned configuration remains the instruction artifact, while the execution environment enforces its operational boundaries.

LiteLLM supplies one part of that infrastructure layer. Its hierarchical budget controls put agent sessions, CI jobs, and pipelines under scoped virtual keys in place of a provider master key. Organization, team, user, and session caps constrain spending before it accumulates. Cost records also belong in the audit trail because token consumption describes part of the agent’s activity. A budget control is therefore useful evidence and enforcement, though it does not replace sandbox isolation or session provenance.

The minimum viable audit trail: what teams can put in place now

Teams can start with the toolchain they already have. Enforcing AI-Assisted, Generated-By, and Prompt-Ref trailers through commit-msg hooks or server-side pre-receive checks establishes machine-readable declarations. To preserve the context those declarations omit, teams should record the prompt and model version in the pull request description or a linked design note when the work is created. Reviewers then have evidence beyond the resulting diff. These records remain a partial measure because they depend on what the developer records.

The next layer is reviewable configuration and automatic capture. Teams should commit CLAUDE.md, AGENTS.md, or agents.yaml and require pull request review for changes that alter behavior. aGiTrack, LineageLens, or a managed platform can then capture sessions when they run.

Each session should run in its own sandbox with credentials minted for that session, separating concurrent work and limiting access. Per-session, per-developer, and per-period token budgets should be enforced before spending at the infrastructure layer. Unexpected consumption then becomes an audit signal as well as a cost concern. The resulting record comes from how agents run.

More in Agent-as-Code Patterns