When an AI agent takes a wrong or harmful action, most teams can show that something happened but cannot show which model version, which instructions, which tool definition and which retrieved data produced it. That gap is a provenance gap, not a logging gap: the events exist, but they are not linked to the versioned inputs that shaped each decision. This guide covers end-to-end agent provenance: the provenance graph for a single run, the identifiers to capture at each step, how to version prompts, tools and data sources so a run can be replayed, and how to trace an output back through a chain of agents. It is written for platform engineers, AI engineers and security architects building or running agents in production. For what regulators expect to see in the record and how long to keep it, see the AI Agent Audit Trails for Regulators Guide; this page is about building the lineage that makes those records explainable.
Key takeaways
- Provenance answers "with what and why", not only "what". An audit event says the agent called a refund API; provenance links that call to the model version, system instructions, tool schema, retrieved documents and delegating user that produced it.
- Use an existing model rather than inventing one. W3C PROV (entities, activities, agents) gives the shape, and the OpenTelemetry GenAI semantic conventions give field names for agents, tools, models and data sources.
- Version everything the model sees. Prompts, system instructions, tool definitions, retrieval indexes and memory stores need immutable identifiers, or a trace points at something that has since changed.
- Store content by reference, record the digest. Keep the trace light and safe by recording a content digest and a reference URI for prompts and outputs, with the bodies held in an access-controlled store.
- Test provenance by reconstruction. The only proof that it works is picking a past action and rebuilding its full lineage within an agreed time; measure that, not log volume.
What breaks when agent provenance is not tracked
An agent run is assembled at runtime from parts owned by different teams: a hosted or self-hosted model, a system prompt in a repository or prompt manager, tool definitions served by an MCP server or framework, retrieval from an index that is rebuilt on a schedule, and long-term memory written by earlier runs. Each part changes on its own release cycle. Without provenance, the following questions become guesswork.
- Root cause: was a bad action caused by a model upgrade, a prompt edit, a changed tool description, a poisoned document or a malicious instruction in tool output? Indirect prompt injection (MITRE ATT&CK T1698, MITRE ATLAS AML.T0051) and RAG poisoning (AML.T0070) look the same as model error unless you can see the exact content the model was given.
- Blast radius: if a document, memory record or tool version is found to be malicious, which runs used it and which downstream outputs were derived from those runs? Without usage records, the only safe answer is "all of them".
- Accountability: which human or upstream agent delegated the task, under which authority, and did the agent act inside that authority? See Delegation Chains and Attenuated Authority for AI Agents.
- Change control: a model or prompt change approved last week cannot be linked to a behaviour shift today unless runs carry the version identifiers. See the AI Model Change Approval Template.
- Audit readiness: auditors increasingly ask how an AI-assisted outcome was produced. NIST AI 600-1 suggests recording data provenance details such as source, signatures and versioning in AI system inventory entries (GV-1.6-003) and keeping a tamper-resistant history of content changes with version control (MS-2.8-003).
The provenance model: entities, activities and agents
The W3C PROV Data Model (PROV-DM, a W3C Recommendation since 30 April 2013) describes provenance with three core types. An entity is a thing with fixed aspects, an activity happens over time and uses or generates entities, and an agent bears responsibility for an activity or entity. Its relations map directly onto an agent run, and borrowing them gives teams a shared vocabulary even if they never emit RDF.
| PROV relation | Meaning in PROV-DM | Agent run example |
|---|---|---|
| used | An activity begins using an existing entity | Model call used system instructions v14 and retrieved chunk doc-881#3 |
| wasGeneratedBy | An entity is produced by an activity | Draft email was generated by model call span 7f2c |
| wasAssociatedWith (with plan) | An agent is responsible for an activity, optionally following a plan | Tool call associated with agent "claims-triage" v3.2 following plan step 4 |
| actedOnBehalfOf | One agent acts for another that keeps some responsibility | Sub-agent acted on behalf of orchestrator, which acted on behalf of user u-4471 |
| wasDerivedFrom | A new entity is based on an existing one | Summary derived from ticket text and two knowledge base articles |
| wasAttributedTo | An entity is ascribed to an agent | Memory record attributed to the agent run that wrote it |
In practice the graph is stored as linked spans and records, not as a formal ontology. The point is discipline: every activity names the entities it used and generated, and every activity names the identity responsible for it.
The five provenance layers to capture
A complete run lineage has five layers. Each needs a stable identifier and, where content is involved, a digest so that later tampering or silent changes are detectable.
| Layer | What to capture | OpenTelemetry GenAI attribute (where defined) | Versioning source |
|---|---|---|---|
| Agent and model | Agent ID, name and version; provider; requested and actual model; response ID | gen_ai.agent.id, gen_ai.agent.name, gen_ai.agent.version, gen_ai.provider.name, gen_ai.request.model, gen_ai.response.model, gen_ai.response.id | Agent registry; model registry or provider model identifier |
| Instructions and prompts | Prompt template name and version, variables, system instructions digest | gen_ai.prompt.name, gen_ai.prompt.variables, gen_ai.system_instructions or gen_ai.system_instructions_ref (opt-in) | Prompt repository commit or prompt manager version |
| Tools | Tool name, type, call ID, arguments, result, definition offered to the model, MCP session and method | gen_ai.tool.name, gen_ai.tool.type, gen_ai.tool.call.id, gen_ai.tool.call.arguments, gen_ai.tool.call.result, gen_ai.tool.definitions (opt-in), mcp.method.name, mcp.session.id, mcp.protocol.version | Tool server release; digest of the tool definition as served |
| Data and memory | Data source ID, document and chunk IDs returned, index build version, memory store and record IDs read or written | gen_ai.data_source.id, gen_ai.memory.store.id, gen_ai.memory.record.id | Index build manifest; dataset version; memory write log |
| Identity and delegation | Workload identity of the agent, delegating user or agent, token or grant ID, policy decision ID, human approvals | Not defined in the GenAI conventions: add as custom attributes under your own namespace | Identity provider and policy engine logs |
The GenAI conventions are maintained in the OpenTelemetry semantic-conventions-genai repository and the agent span definitions are marked Development status (checked November 2026), so attribute names can change. Pin the convention version in your instrumentation and record it in your telemetry resource attributes. Well-known values of gen_ai.operation.name include create_agent, invoke_agent, invoke_workflow, plan, execute_tool, retrieval, chat and embeddings, which gives each step of a run a predictable span type.
Content by reference
The conventions mark system instructions, input messages, output messages and tool definitions as Opt-In, and define matching _ref attributes holding an absolute URI to external storage. Use that pattern: write prompt and output bodies to a restricted store, put the URI and a SHA-256 digest on the span, and keep the trace pipeline free of personal data and secrets. This also lets you apply a different retention period to bodies than to the lineage skeleton. See Agent Observability vs Audit Logging for how sampling and redaction differ between the two pipelines.
Correlating a run across systems and agents
Provenance is only useful if the pieces join up. Four identifiers do most of the work.
- Trace context: propagate the W3C Trace Context traceparent header (version, a 16-byte trace-id, an 8-byte parent-id and trace-flags) across every HTTP hop, including calls to tool servers and between agents. Without it, a sub-agent's work appears as an unrelated trace.
- Run or conversation ID: gen_ai.conversation.id ties multi-turn activity together even when traces are split by timeouts or queues.
- Tool call ID: gen_ai.tool.call.id links the model's decision to call a tool with the execution span and the downstream system's own log entry. Pass it to the target system as a request header or correlation field so its audit log carries it too.
- Delegation chain: record the full chain of principals (user, orchestrator, sub-agent) on each action, not only the immediate caller. Token exchange flows that keep an actor claim make this easier; see AI Agent Service Accounts vs On-Behalf-Of Access.
Sampling is the most common way lineage breaks. Head-based sampling that drops 90 per cent of traces is acceptable for performance dashboards but not for provenance. Keep 100 per cent of the lineage skeleton (IDs, versions, digests, identities) for any run that calls a tool with side effects, and sample only the verbose content.
Versioning the inputs so a run can be explained later
A trace that says "prompt: claims-triage" is worthless if the prompt has been edited ten times since. Each input type needs an immutable version reference.
- Models: record the provider's dated or versioned model identifier from the response (gen_ai.response.model), not only the alias you requested. Aliases such as "latest" move without notice. For self-hosted models, record the registry version and weights digest; see the AI Model Provenance and Watermarking Guide.
- Prompts and system instructions: store them in version control or a prompt manager that issues immutable versions; record template name, version and the digest of the rendered text.
- Tool definitions: the description and schema the model sees steer its behaviour as much as the prompt. Record a digest of each tool definition as served at run time, so a tool server that changes descriptions between sessions is visible. See Static Tool Allowlists vs Dynamic Tool Discovery for AI Agents.
- Retrieval data: record the index build ID and the document and chunk IDs returned, plus their digests. An index manifest that lists source documents per build lets you answer "which runs saw document X". See Data Lineage vs Data Provenance.
- Memory: treat every memory write as a generated entity attributed to the run that wrote it, and every read as usage. This is what lets you unwind memory poisoning (ATLAS AML.T0080 AI Agent Context Poisoning) instead of wiping the store. See the AI Agent Memory Poisoning Guide.
- Agent build: an agent is itself software. Build provenance in the SLSA style (an in-toto attestation with predicate type https://slsa.dev/provenance/v1, recording buildDefinition and runDetails) ties the deployed agent version to its source and dependencies. See the SLSA and Build Provenance Guide and the AI Supply Chain and AI-BOM Guide, which covers CycloneDX ML-BOM records for models and datasets.
Where identity fits
Every provenance record needs a "who", and for agents that is a non-human identity plus a chain of delegators. Give each agent its own workload identity registered in an AI agent registry (see the AI agent registry guide), with the registry ID used as gen_ai.agent.id, so the provenance graph and the identity inventory share a key. Shared API keys across agents destroy attribution: two agents using one key are indistinguishable in downstream logs. Record per-run session identity separately from the long-lived agent identity, as described in Agent Identity vs Agent Session Identity.
Decision guidance
| Situation | Recommended provenance depth | Trade-off |
|---|---|---|
| Read-only assistant, no tools with side effects | Model, prompt version and data source IDs; sampled content | Low cost; limited ability to investigate harmful outputs |
| Agent with write tools (tickets, email, code) | All five layers for every run; content by reference | Storage and engineering effort; needed to scope incidents |
| Agent moving money, changing access or acting in regulated processes | All five layers plus signed or hash-chained records and human approval content | Highest cost; supports non-repudiation (NIST SP 800-53 AU-10) |
| Multi-agent systems across vendors | Trace context propagation contractually required; delegation chain on every action | Depends on partners; write it into agreements |
Small organisations using a single framework can get most of the value from the framework's built-in OpenTelemetry instrumentation, a prompt repository with tagged versions and a rule that every tool call carries the call ID downstream. Large organisations with many agent teams should publish a provenance schema (required attributes, custom namespace, digest algorithm, content store) and enforce it at the gateway or collector, rejecting spans that miss mandatory fields. Build versus platform: an observability platform may capture traces well but hold them in a vendor store with its own retention; keep the lineage skeleton in a store you control as well. Third-party model and tool providers should be asked for provenance commitments in contract, in line with NIST AI 600-1 GV-6.1-004.
How to implement
- Pick one high-risk agent and map its run. List every input (model, prompt, tools, data, memory, identity) and every output with side effects. This becomes the reference design.
- Define the schema. Adopt the OpenTelemetry GenAI attributes, pin the convention version, add a custom namespace for identity and policy fields, and choose a digest algorithm (SHA-256) and content store.
- Version the inputs first. Put prompts, system instructions and tool definitions under version control and make index builds produce manifests. Instrumentation without versioned inputs gives you IDs that point nowhere.
- Instrument and propagate. Enable framework instrumentation, propagate traceparent to tool servers and sub-agents, and pass tool call IDs into downstream audit logs.
- Pilot in shadow. Run for two to four weeks, then run a reconstruction drill on a sample of past actions. Fix gaps before widening.
- Enforce at the collector. Reject or flag spans missing mandatory lineage fields; alert on agents emitting no provenance.
- Protect and retain. Write the lineage skeleton to append-only storage with integrity checks (NIST SP 800-53 AU-9) and set retention per layer. Retention rules for regulators are covered in the audit trail guide linked above.
- Roll back safely. If instrumentation hurts latency or leaks content, switch content capture to reference-only or off; keep the ID and version skeleton, which is small and should not be removed.
Detection and measurement
Provenance data is also detection data. Useful signals include a run whose gen_ai.response.model differs from the approved model, a tool definition digest that changes without a matching release, retrieval from a data source ID outside the agent's approved list, memory writes from runs that also processed untrusted external content, and actions with no delegating principal. Feed these into the SOC alongside identity events (NIST CSF 2.0 DE.AE-03, information correlated from multiple sources).
- Lineage completeness: percentage of side-effecting tool calls with all five layers populated (target close to 100 per cent).
- Reconstruction time: median time to rebuild a past action's full lineage in a drill.
- Unversioned input rate: share of runs referencing a prompt, tool or index with no immutable version.
- Delegation coverage: share of actions with a complete principal chain back to a human or scheduled job.
- Downstream correlation rate: share of tool calls whose call ID appears in the target system's own audit log.
- Unapproved model or tool events: count per month, with time to triage.
Framework mapping
| Framework | Reference | Relevance to agent provenance |
|---|---|---|
| NIST SP 800-53 Rev. 5 | AU-3 Content of Audit Records; AU-10 Non-repudiation; AU-9 Protection of Audit Information | Record content, binding actions to identities, integrity of lineage |
| NIST SP 800-53 Rev. 5 | SR-4 Provenance; CM-8 System Component Inventory; AU-16 Cross-organizational Audit Logging | Origin of models and tools; inventory of agents; tracing across providers |
| NIST CSF 2.0 | ID.AM-07, ID.AM-08, PR.PS-04, DE.AE-03 | Data and metadata inventories, life cycle, log generation, correlation |
| NIST AI 600-1 | GV-1.6-003, MP-2.2-001, MS-2.7-004, MS-2.8-003, GV-6.1-004 | Provenance in inventories, upstream dependencies, provenance metrics, tamper-resistant history, supplier contracts |
| MITRE ATLAS / ATT&CK | AML.T0051, AML.T0070, AML.T0080, T1698 | Attacks that provenance helps detect and scope |
| W3C | PROV-DM; Trace Context | Provenance vocabulary; cross-service correlation |
Common failure patterns
- Logging the alias, not the model: traces record the requested model name while the provider served a newer version, so behaviour changes cannot be tied to a model change.
- Prompts edited in place: a prompt manager or config file is overwritten without versions, so every past trace points at today's text.
- Tool output not treated as an input: teams record tool calls but not the content returned, which is exactly where indirect prompt injection arrives.
- Broken chain at the sub-agent: trace context is not propagated to a second agent or external tool server, and the delegated work appears ownerless.
- Full content in the trace store: prompts with personal data or secrets land in a broadly accessible observability tool. See How to Find Secrets in AI Agent Transcripts and Traces.
- Provenance kept only in a vendor console: the record disappears when the agent is deleted or the contract ends.
Practitioner checklist
- Every production agent has a registry ID used as gen_ai.agent.id and its own workload identity.
- Runs record the served model identifier, not only the requested alias.
- Prompts, system instructions and tool definitions have immutable versions and digests recorded per run.
- Retrieval and memory reads and writes carry source, record and index build IDs.
- traceparent is propagated to tool servers and sub-agents; tool call IDs reach downstream audit logs.
- Each action carries the full delegation chain and any human approval reference.
- Content is stored by reference with digests; the lineage skeleton is never sampled for side-effecting runs.
- Lineage records sit in append-only storage you control, with integrity checks.
- A quarterly reconstruction drill measures time to rebuild a past action's lineage.
Standards and references
- W3C: PROV-DM, The PROV Data Model
- OpenTelemetry: GenAI Semantic Conventions
- W3C: Trace Context
- NIST: AI 600-1, Generative Artificial Intelligence Profile
- NIST: SP 800-53 Rev. 5
- SLSA: Provenance specification v1.0
- CycloneDX: Machine Learning Bill of Materials (ML-BOM)
- MITRE ATLAS: AI Agent Context Poisoning
Related NHI Mgmt Group resources: AI Agent Audit Trails for Regulators Guide · Agent Observability vs Audit Logging · AI Agent Observability and Incident Response Guide · Agent Identity and Access Guide