The trace tells the truth about sequence
Modern agent frameworks can record model calls, tool calls, tool outputs, hand-offs, guardrails and custom spans. OpenTelemetry is developing common semantic conventions for generative AI spans and events. W3C PROV supplies a mature vocabulary for entities, activities and agents involved in producing an artefact. These are valuable advances because an unexplained action is impossible to investigate when the system cannot reconstruct its own execution.3, 4, 5
Yet a complete trace answers a different question from a causal attribution. It answers: what was available, what happened next, and which recorded activity used or generated which artefact? Causation asks: under a controlled change to this candidate factor, would the specified action event have changed?
This distinction is easy to miss because the two records often share the same graph. An edge labelled “invoice used by model call” looks causal. It may only mean the invoice was in context. A retrieved paragraph can be available without influencing the output. A hidden activation can encode a fact without being used. A policy check can precede execution without altering the decision. Availability, representation and sequence are weaker claims than causal use.
Why highlighted text is not enough
Interpretability research supplies a useful warning. Jain and Wallace found that attention patterns could differ sharply while predictions remained equivalent, although Wiegreffe and Pinter argued that the conclusion depends on the explanation being sought and the tests applied. Adebayo and colleagues showed that some visually persuasive saliency methods could be insensitive to model parameters or data. The durable lesson is narrower than “all attribution is useless”: an attribution method must be tested against the causal claim it is supposed to support.6, 7, 8
The same applies to an agent’s quoted rationale. “I called the payment tool because the invoice requested it” is a new output from the same system, not privileged access to the mechanism. It can be useful testimony about the model’s self-description. It does not establish that removing the invoice would change the call.
Internal probes are also not enough. Causal mediation work distinguishes information encoded in a representation from information used in producing a behaviour. Activation interventions and causal tracing can identify internal computations that mediate an output, but those findings remain relative to the chosen intervention, model boundary and target outcome.9, 10
The first engineering move is therefore to define the event. “The tool call” is too vague. Did the model emit a function name? Did the orchestrator canonicalise its arguments? Did an authority kernel release the action? Did the external system accept it? Did the intended postcondition occur? These events can share a timestamp and still have different causes.
flowchart TD A["The payment that explained itself"] --> B["The trace tells the truth<br/>about sequence"] B --> C["An action is three events, not one"] C --> D["Build the certificate by replay"] D -. "re-test" .-> A classDef first fill:#0a1424,stroke:#D95545,stroke-width:2px,color:#e6f3ff classDef step fill:#0a1424,stroke:#3f7da0,stroke-width:1px,color:#e6f3ff class A first class B,C,D step
An action is three events, not one
Consider a model that emits a perfectly formed payment request. A policy engine denies it. No money moves. The user instruction may have caused a proposal, but it did not cause an executed payment. Now consider a different run in which the policy engine permits the request, but the bank rejects the account. The release occurred; the intended effect did not.
Attribution must be stage-specific because causes do not automatically propagate across authority and world boundaries. This paper uses three target events:
Proposal, P: the model or planner emits a canonical tool name and typed arguments. Release, R: the authority mechanism permits that proposal under an identity, purpose, policy and freshness context. Effect, E: the tool changes authoritative world state and the change is verified by a receipt or readback.
The smallest example that defeats deletion
Two sufficient routes to the same call
Let U=1 mean the user explicitly requested a payment. Let X=1 mean an invoice contains a directive to pay. Suppose the model proposes the payment when either route is active:
P = U OR XIn the actual run, U=1 and X=1, so P=1. Remove U; the proposal survives because X remains. Remove X; the proposal survives because U remains. A naive leave-one-out test declares both inputs non-causal, even though either one could have produced the proposal alone.
Structural accounts of actual causation handle such overdetermination by asking whether a factor becomes critical under an appropriate contingency. Hold X=0; changing U now changes P. Hold U=0; changing X changes P. Each factor belongs to a cause set even though neither is a simple but-for cause in the actual context.1, 2
From a Boolean switch to a stochastic agent
A language model does not behave like a fixed OR gate. Sampling, batching, hidden caches and small prompt changes can alter the proposal. The useful quantity is therefore not “did one replay change?” but an estimated survival rate across paired runs.
Let As denote the target event at stage s, where s is proposal, release or effect. Let Ti be a registered intervention that neutralises candidate factor Ci. Let ≈ be a declared semantic equivalence relation for the action. With the same model version, tool set, world snapshot and paired random seeds, define:
survival(i, s) = Pr[A_s(intervene(C_i)) ≈ A_s(baseline)]necessity(i, s) = 1 - survival(i, s)A necessity score near one means the target event rarely survives neutralising that factor. A score near zero means the event usually survives. Neither number is meaningful until the intervention and equivalence relation are specified. Replacing an invoice with blank text tests a different world from rewriting its directive as a neutral factual statement. Treating two payments as equivalent because they use the same function name ignores the amount and recipient.
Three additional tests matter. Sufficiency asks whether adding the candidate to a matched control can produce the action. Stability asks whether meaning-preserving paraphrases leave the attribution unchanged. Interaction asks whether changing two candidates together produces an effect that neither produces alone. These tests expose redundant, conjunctive and suppressive routes.
The certificate should preserve cause sets, not crown a winner
Incident dashboards often turn attribution into a ranking: the user message contributed 42%, the invoice 31%, the cache 19%, and everything else 8%. Such numbers look decisive because they force a complex mechanism into one ordered list. The hidden assumption is that causal influence can always be divided among independent contributors. In agent systems, candidates can substitute for one another, enable one another or block one another. A factor with a low marginal score can still be part of every sufficient route under the contingency that matters.
Return to P = U OR X. A symmetric responsibility rule might split credit between trusted user intent and the untrusted directive. That is useful for some allocation questions, but it misses the security decision. The critical fact is not that the two routes received equal shares. It is that X can produce the proposal when U is absent. A governance team must see that untrusted observation became a sufficient control channel. Cause sets preserve the route by which an action became possible; a winner-takes-all score can hide it.
Causal relevance can also stop at a boundary. An invoice directive may cause a proposal, yet a policy denial blocks release. Conversely, a stale approval token may cause release while contributing nothing to the proposal. A successful tool return may still fail to cause the claimed world effect when independent readback shows no ledger change. The certificate should therefore retain minimal tested sets, variable roles, stage targets, interaction results and untested alternatives. Responsibility scores may summarise this record, but they must not replace it.
Causal mediation and activation patching provide precedents for this kind of internal intervention. They can test whether an internal component transmits an input’s effect to an output. In a configured agent, however, internal state includes more than neural activations. It may include a plan object, session flags, retrieved-item rankings, a tool-result cache or an orchestrator’s branch state. Calling all of these “memory” obscures the variable that must be changed.
Build the certificate by replay
A useful attribution process should not begin after the incident with a favourite suspect. It should begin before deployment with a replayable system boundary, typed events and registered intervention operators. The output is not a story. It is a compact certificate stating which causal claims survived which tests.
This paper proposes a Counterfactual Attribution Certificate, or CAC. It is practitioner synthesis rather than a settled standard. Its design borrows the discipline of structural causal models, the stage separation of governed agent architectures and the paired re-execution pattern now appearing in agent-security research.
Seven moves from trace to cause
1. Declare the target event. Canonicalise the tool name, argument schema and stage. A payment proposal can be equivalent across harmless formatting differences while remaining sensitive to amount, currency, recipient, timing and purpose. For effect attribution, declare the verified postcondition.
2. Freeze a replay dossier. Record the model and runtime versions, tool definitions, policy bundle, identity and purpose context, retrieved artefacts, world snapshot, sampling settings and any reusable state. A trace without a replay dossier may support investigation but not controlled counterfactuals.
3. Enumerate candidate causes by role. Keep user instruction, trusted evidence, untrusted observation, runtime state, hidden mediator, policy state, tool affordance and world state separate. A candidate list should include rival generators, not only suspicious content.
4. Register on-manifold interventions. Use neutral replacement, contradictory replacement, meaning-preserving paraphrase, state patch, policy clamp and tool simulation as appropriate. Each operator must preserve the type and as much non-causal structure as possible. Blank deletion is a useful stress test, not a universal neutralisation.
5. Run paired replays. Reuse seeds where the platform supports them, or pair random draws inside a simulator. Repeat enough times to estimate baseline variability. Compare semantic action identity, not raw token equality.
6. Search for minimal sets and interactions. Start with individual interventions, then test plausible pairs and contingencies. Stop exhaustive search when the cost exceeds the action’s risk budget, but record what was not tested. A minimal set is relative to the chosen variables, operators and survival threshold.
7. Issue a bounded claim. The certificate should say, for example: “Under model M, policy G and world snapshot W, the payment proposal depended jointly on the user request and carried-over plan; the untrusted invoice directive was not necessary. Release depended on policy rule R17. Effect depended on the bank tool accepting account Q7.” That is much stronger than “the invoice caused the payment”, and much narrower than assigning blame.
A configured-system example
One call, four causal roles
Suppose a replay harness runs 500 paired simulations against a synthetic invoice agent. The baseline payment proposal appears in 91% of runs. Neutralising the user request drops proposal survival to 64%. Neutralising the invoice directive drops it to 58%. Cleaning the carried-over plan drops it to 31%. Neutralising both the directive and plan drops it to 5%. These numbers are illustrative, but the pattern matters.
The directive and hidden plan interact. Neither single intervention removes the call reliably because the other route often substitutes. Their joint removal nearly eliminates the proposal. A meaning-preserving rewrite of the user request keeps the attribution stable, while a blank user message changes the whole task and creates off-manifold behaviour.
Next, clamp the policy gate to deny. Proposal frequency remains 91%, release falls to zero and no effects occur. Finally, preserve proposal and release but replace the live bank tool with a simulator that always rejects the account. The release remains, while the verified effect disappears. The resulting certificate names a joint cause set for P, a policy cause for R and a tool-world condition for E.
Recent work on tool-using agents is converging on this operational idea. AgentDojo makes untrusted tool outputs part of dynamic agent environments. MELON compares original and masked re-executions. AttriGuard uses teacher-forced shadow replay and a semantic survival test to ask whether a proposed call remains supported after control cues in observations are attenuated. CausalFlow replaces candidate steps and re-executes downstream computation to locate failure-inducing steps. These systems differ in purpose and formal commitments, but they share a move from inspection to intervention.11, 12, 13, 14
That convergence should not be overstated. Several results are recent preprints. Their intervention operators, equivalence tests and benchmarks may not transfer to every configured system. A 2026 preprint benchmark reports that current models still struggle to localise and diagnose failures in long, multimodal agent traces. Automated attribution should therefore be treated as a measured component, not as an oracle that signs its own certificate.15
Counterfactual tool-call attribution harness
Toggle the five baseline factors, then run 1,000 paired simulations. The lab uses a small stochastic proposal model, a deterministic authority gate and a probabilistic tool effect. It reports how often proposal, release and effect survive when each factor is neutralised. It also emits a compact certificate.
| Neutralised | Proposal necessity | Release necessity | Effect necessity |
|---|---|---|---|
| Run the lab to calculate paired scores. | |||
No certificate generated.
What the lab tests
The synthetic proposal probability rises with trusted intent, the untrusted directive and carried-over state. It also contains an interaction between the directive and state, so joint intervention can reveal more than either removal alone. The authority permit affects release but not proposal. Tool acceptance affects effect but not the upstream stages.
A positive result permits a narrow statement such as “under this model and intervention, factor M was necessary for most proposal replays”. A negative result means the action survived that intervention. It does not prove the factor was never used, because another route may substitute. The lab cannot establish a real model’s internal cause, human intention, policy legitimacy or moral responsibility.
Typed certificate schema and reference pseudocode
type Stage = "proposal" | "release" | "effect";
type Intervention = {
candidateId: string;
operator: "neutral_replace" | "contradict" | "paraphrase" |
"state_patch" | "policy_clamp" | "tool_simulation";
preserves: string[];
changes: string[];
operatorVersion: string;
};
type StageResult = {
stage: Stage;
targetEventHash: string;
equivalenceRule: string;
baselineRate: number;
survivalRate: number;
necessity: number;
confidenceInterval?: [number, number];
};
type CauseSet = {
candidateIds: string[];
stage: Stage;
minimalUnderTestedSubsets: boolean;
jointNecessity: number;
untestedSupersets: number;
};
type CounterfactualAttributionCertificate = {
certificateId: string;
configuredSystemHash: string;
replayDossierHash: string;
action: {
tool: string;
canonicalArguments: Record<string, unknown>;
verifiedPostcondition?: string;
};
interventions: Intervention[];
results: StageResult[];
causeSets: CauseSet[];
rivalGeneratorsTested: string[];
prohibitedInferences: string[];
status: "trace-only" | "behavioural" | "mediated" | "prospective-gate";
};
stateDiagram-v2 [*] --> Claim state "The observational twins" as Claim state "Why highlighted text is not enough" as Test state "The smallest example that<br/>defeats deletion" as Revision Claim --> Test: expose mechanism Test --> Decision: evidence survives Test --> Revision: rival survives Revision --> Claim: narrow or rebuild Decision --> [*]
Where counterfactual attribution breaks
Intervention is stronger than inspection, but it is not magic. A replay can be precise about the wrong model, or faithful to an impossible counterfactual. The strongest objection to this paper is that counterfactual perturbations may measure sensitivity to the perturbation rather than causation in the original run. That objection is correct whenever the operator destroys the structure that made the original variable meaningful.
Five failure modes that deserve their own fields
Off-manifold intervention. Blank deletion can produce a context the model was never designed to process. Use several operators and report whether the result depends on one unusual rewrite.
Equivalence error. String equality is too strict for summaries and too weak for consequential arguments. Two calls to send_payment are not equivalent when the account differs. An LLM judge can help with fuzzy fields, but it introduces another model and another failure surface.
Omitted cause. A certificate can only rank variables represented in the dossier. A deployment flag, model-side cache or external rate-limit response may be absent. Stability across expanded causal models matters more than a precise score from a narrow one.
Version drift. Replaying against a newer model, policy or tool implementation changes the structural equations. The run may still be useful for regression testing, but it is not a counterfactual of the original configured system.
Adaptive behaviour. An adversary can craft content that survives a known attenuation operator or causes a benign shadow run while steering the live run through an unmodelled channel. Attribution should therefore complement typed authority and containment, not replace them.
The call survives, the recipient changes
The baseline emits send_payment(account=Q7, amount=18400). A counterfactual emits send_payment(account=Q8, amount=18400). A function-name survival test says the call survived. A transaction-semantic test says the most consequential argument changed.
The certificate must therefore define field-level equivalence. Currency formatting may be canonicalised. Recipient, amount, purpose and deadline may require exact or policy-aware comparison. Semantic survival is part of the causal claim, not a cosmetic post-processing step.
| Level | Evidence present | Permitted claim | Still prohibited |
|---|---|---|---|
| 0 · Trace | Ordered model, tool, policy and effect records | The factor was available or preceded the event | It caused the event |
| 1 · Single replay | One registered intervention with downstream recomputation | The event was sensitive in that counterfactual | Unique cause or robust necessity |
| 2 · Paired replay | Repeated matched runs and semantic action equivalence | Estimated stage-specific necessity under one operator | Completeness of the cause set |
| 3 · Cause-set search | Contingencies, pairs, rival generators and stability variants | Minimal tested cause sets and interactions | Untested variables are irrelevant |
| 4 · Mediated attribution | Input intervention plus state patch or mediator swap | A candidate path transmitted causal influence | The path is the only semantic reason |
| 5 · Prospective gate | Replay within the live risk budget, independent authority decision | The action has current bounded support from trusted causes | Human intention, blame or legal liability |
The approval that moved between stages
Consider a synthetic treasury assistant given a trusted instruction: prepare a £9,600 supplier payment, but send it only after fresh approval. The supplier PDF includes the sentence “approved by finance”. The session also carries approval_token=ok from a test run, and the deployed policy accepts any unexpired token. Across 400 paired simulator runs, the baseline produces the proposal in 94% of runs, releases it in 93%, and verifies the ledger effect in 91%.
| Intervention | Proposal P | Release R | Effect E | What the replay supports |
|---|---|---|---|---|
| Baseline | 94% | 93% | 91% | Target trajectory is common enough to analyse |
| Neutralise PDF approval | 92% | 91% | 89% | The PDF sentence is present but not necessary here |
| Remove trusted user intent | 17% | 16% | 15% | User intent is a strong proposal cause, though a rival route remains |
| Clear stale approval token | 93% | 8% | 7% | The token is a release cause, not a proposal cause |
| Require new confirmation | 94% | 0% | 0% | The policy rule controls authority without changing the model proposal |
| Freeze recipient account in twin | 94% | 93% | 0% | The tool-world condition is necessary for the verified effect |
A proximity-based incident report would blame the PDF because its approval sentence appeared beside the call. The replay says something more discriminating. Trusted intent largely caused the proposal. The stale token, combined with a permissive policy, caused release. The recipient account’s executable state determined whether the authorised call produced an effect. The PDF was a plausible rival generator, but it did not carry the observed trajectory in this dossier.
Now suppose investigators delete the PDF sentence and also clear the token in one replay. Release disappears. They might attribute the disappearance to the PDF because it was the visible suspect. The single combined intervention cannot tell which change mattered. Factorial replay separates them. A causal certificate is valuable precisely when the most narratively salient item is not the operative cause. The numbers do not establish what would happen under a different model, policy or world snapshot. They establish a bounded stage-specific claim for this configured system.
Attribution is not blame
Actual cause, causal responsibility, blame and accountability are different notions. Halpern’s treatment distinguishes responsibility in a causal setting from blame under an epistemic state. In an agent incident, an untrusted document may causally influence a proposal; a developer may have no knowledge of that specific document; an operator may still be accountable for deploying a system without adequate boundaries. A CAC should not collapse those questions.2
The same caution applies to “the model intended the payment”. The certificate can show that a user request, external directive or hidden mediator changed an action distribution. It cannot by itself establish phenomenal intention, moral agency or a unified subject. Those are independent questions with different evidence.
When not to use the certificate as a release gate
Do not place expensive shadow replay on every low-risk, reversible call. Do not use it when the world cannot be safely cloned, when the intervention operator is unvalidated, or when latency would itself create harm. In those cases, rely on deterministic authority, narrow capabilities, preconditions, explicit confirmation and postcondition verification. The CAC is strongest where actions are consequential enough to justify replay and structured enough to admit a meaningful twin.
Prospective attribution can become a control signal
For high-impact calls, a system could run a short shadow replay before release. The call would proceed only when trusted user intent or authorised world evidence remains causally necessary, while untrusted control cues are not sufficient. Evidence that this reduces attack success without unacceptable utility or latency loss would strengthen the proposal. Frequent false blocks, operator-specific evasion or disagreement across equivalent rewrites would weaken it. A rival explanation is that the shadow branch acts merely as an ensemble detector rather than identifying cause. The smallest useful implementation is a two-view replay for one irreversible tool.
sequenceDiagram participant Q as Question participant M as Mechanism participant E as Evidence participant D as Decision Q->>M: The payment that explained itself M->>E: The observational twins E-->>M: compare rival explanations E->>D: Separate the cause of proposal, release and effect D-->>Q: revise scope or act
Separate the cause of proposal, release and effect
When a consequential tool call appears, do not ask only which text the model quoted, which span was nearby or which attention weight was large. Ask three questions in order.
What caused the proposal? Neutralise trusted intent, untrusted observations and carried state under paired replay. Test interactions and semantic action identity. What caused release? Hold the proposal fixed and intervene on identity, purpose, policy, freshness and confirmation. What caused the effect? Reproduce the tool and world conditions, then verify the postcondition through an independent readback.
This changes both incident response and architecture. Post-incident teams should preserve a replay dossier before caches expire or systems drift. Designers should make proposal, release and effect separately observable and separately interruptible. High-impact actions should carry a machine-readable certificate that names the tested cause sets, rival generators, intervention operators and prohibited inferences.
For incident response, this means preserving evidence before interpretation hardens into a story. Snapshot the configured system, canonicalise the target action, and keep the suspected input alongside plausible rival generators. Investigators should be able to say which replay changed P, which changed R, and which changed E. When only a trace survives, the report should remain at evidence level zero rather than silently promoting sequence into cause.
For architecture, the requirement is sharper. A system that cannot replay a proposal without repeating its side effect is not ready for consequential attribution. A policy gate that cannot explain its own release variables leaves authority causally opaque. A tool that reports success without an independent postcondition makes effect attribution depend on self-report. Replay dossiers, typed authority decisions and verified outcomes are not observability extras; they are the causal test points of a governable agent.
The aim is not to produce a more persuasive explanation after harm. It is to change what the system is allowed to do before harm. A trace says that an influence was present. A certificate says what changed when that influence was removed, replaced or held fixed. That is the difference between a story about the action and evidence about its cause.
Glossary
- Actual cause
- A factor that satisfies a declared counterfactual criterion within a specified causal model and context. The result depends on the variables and contingencies represented.
- Candidate cause
- An instruction, evidence item, runtime state, hidden mediator, policy condition, tool property or world-state fact selected for intervention.
- Counterfactual Attribution Certificate
- The paper’s proposed record of stage-specific targets, replay dossier, intervention operators, survival estimates, minimal tested cause sets, rivals and limits.
- Effect
- A verified change in authoritative world state, rather than only a successful function return.
- Intervention operator
- A controlled transformation such as neutral replacement, state patch, policy clamp or tool simulation used to alter one candidate factor.
- Proposal
- A canonical tool name plus typed arguments emitted by a model or planner before authority is applied.
- Release
- The authority decision that permits a proposal to reach an executor under a particular identity, purpose, policy and time context.
- Semantic survival
- Whether the counterfactual action remains equivalent to the baseline action under a declared field-level rule.
References
- Halpern, J. Y. and Pearl, J. “Causes and explanations: a structural-model approach. Part I: Causes.” The British Journal for the Philosophy of Science, 2005. DOI record. Foundational causal-model account.
- Chockler, H. and Halpern, J. Y. “Responsibility and blame: a structural-model approach.” Journal of Artificial Intelligence Research, 2004. Bibliographic record. Degrees of responsibility and blame.
- W3C. “PROV-O: The PROV Ontology.” W3C Recommendation, 2013. Specification. Authoritative provenance standard.
- OpenTelemetry. “Semantic Conventions for Generative AI.” Official repository. Current evolving conventions for GenAI spans, metrics and events.
- OpenAI. “Integrations and observability: tracing.” Official documentation. Current tracing capabilities for agent runs.
- Jain, S. and Wallace, B. C. “Attention is not Explanation.” NAACL, 2019. ACL Anthology. Empirical challenge to attention as faithful explanation.
- Wiegreffe, S. and Pinter, Y. “Attention is not not Explanation.” EMNLP-IJCNLP, 2019. ACL Anthology. Counterpoint on definitions and diagnostic tests.
- Adebayo, J. et al. “Sanity Checks for Saliency Maps.” NeurIPS, 2018. Proceedings. Tests for model and data sensitivity.
- Vig, J. et al. “Investigating Gender Bias in Language Models Using Causal Mediation Analysis.” NeurIPS, 2020. Proceedings. Causal mediation for internal model components.
- Meng, K. et al. “Locating and Editing Factual Associations in GPT.” NeurIPS, 2022. Proceedings. Causal intervention and activation patching.
- Debenedetti, E. et al. “AgentDojo: A Dynamic Environment to Evaluate Prompt Injection Attacks and Defenses for LLM Agents.” 2024. arXiv record. Dynamic tool-use environment with untrusted data.
- Zhu, K. et al. “MELON: Provable Indirect Prompt Injection Defense via Masked Re-execution and Tool Comparison.” 2025. arXiv record. Masked re-execution; verify venue status before publication updates.
- He, Y. et al. “AttriGuard: Defeating Indirect Prompt Injection in LLM Agents via Causal Attribution of Tool Invocations.” 2026. arXiv record. Frontier preprint on action-level causal attribution.
- Bonagiri, A. et al. “CausalFlow: Causal Attribution and Counterfactual Repair for LLM Agent Failures.” 2026. arXiv record. Frontier preprint on interventional step attribution.
- “Who&When Pro: Can LLMs Really Attribute Failures in AI Agents?” 2026. arXiv record. Frontier preprint benchmark; conclusions remain preliminary.