Trace the Work

Persist the agent's evidence trail alongside the artifact it changed. Future agents need the reasoning path and the final diff together.

The Problem This Solves

A code diff shows what changed. It rarely shows why the agent made that change, which files it inspected, which tests shaped the decision, or which constraints were active in the session.

That missing trail becomes a context problem later. The next agent revisits the code and has to rediscover the same evidence from scratch. Worse, it may undo a decision because the rationale lived only in a chat transcript that never traveled with the repository.

Git stores the artifact, and agent work also needs provenance when the reasoning trail matters for maintenance.

How It Works

Persist a trace of the work next to the artifact or in a retrievable project store. The trace should be structured enough for future agents to use without replaying the whole conversation.

A useful trace captures:

FieldPurpose
Changed files and line rangesShows the exact artifact surface
Read files and line rangesShows the evidence considered
User requestPreserves the original goal
Key decisionsRecords why the change took this shape
Tests or checksShows what was verified
Model and tool sessionGives audit and debugging context

Agent Trace is an open specification for this kind of record. It tracks files, line ranges, conversations, model identifiers, related resources, and VCS revisions. The important part for context engineering is that the trace becomes future context, ready to retrieve when another agent touches the same code.

Example

An agent changes a payment retry policy. The diff only shows a retry count moving from 3 to 5 and a test update.

A trace adds the missing context:

goal: Reduce false payment failures during provider brownouts
changed:
  - payments/retry_policy.ts:18-44
  - payments/retry_policy.test.ts:72-118
read:
  - incidents/2026-05-provider-brownout.md:1-80
  - docs/payments/retry-contract.md:10-36
decisions:
  - Keep exponential backoff cap at 90 seconds
  - Do not retry card_declined responses
verified:
  - npm test -- payments/retry_policy.test.ts

A future agent can now see that the retry increase was scoped to provider brownouts, with ordinary payment failures left under the existing policy.

When to Use

  • Codebases where agents repeatedly modify the same areas
  • Regulated or high-risk systems where provenance matters
  • Long-running projects with multiple agent sessions, humans, and branches
  • Changes where the reasoning depends on external evidence, incidents, specs, or tickets

When Not to Use

  • Tiny throwaway changes where the commit message contains enough context
  • Private experiments that will never be maintained
  • Traces that store sensitive conversation data without access control or retention rules