XRAPH/Research/Whitepaper

Distilling Agent Episodes into Provenance-Bearing Graphs

A construction for compressing an agent episode into typed claims that retain the observations they rest on, written as graph edges a later contradiction can locate and revise. Bounds revision cost by the transitive support closure and is explicit about where the independence assumption fails.

Type
Whitepaper
Year
2026
Status
Draft
Length
8 min read
Focus area
Agent Knowledge Distillation & Graphing

#Abstract

An agent that completes a task holds a transcript, and a transcript has no operation that returns the fact that two of them disagree. This paper describes a construction in which an episode is compressed into typed claims that retain the observations supporting them, written as graph edges over content-addressed nodes, so that later contradiction becomes a traversal. Revision cost is bounded by the transitive support closure. The confidence composition rule assumes independence, and the paper is explicit that this assumption fails in a common case.

#A worked example

An agent is asked, in one session, to determine which pump feeds a particular separator. It reads a piping diagram, follows a line, and concludes that P-101A feeds it. The session ends. The conclusion is correct given what was available.

Three weeks later, in an unrelated session, the same agent reads a maintenance record stating that P-101A was isolated and the feed rerouted through P-104 eighteen months ago. Nothing in the second session references the first. The agent has no operation available to it that means "the thing I concluded earlier is now wrong", because the earlier conclusion is a sentence in a transcript that is not in this context window and would not be actionable if it were.

What happens next depends entirely on retrieval. If the first transcript is retrieved, a model may or may not notice the contradiction, since noticing requires holding both statements and comparing them. If it is not retrieved, the agent answers from whichever source it saw most recently, and both answers persist in the store as equally valid text.

The defect is not that the agent was wrong. It was right, then the world changed. The defect is that there is no operation on a pile of transcripts that returns the fact that two of them disagree.

Every design decision below follows from wanting that operation to exist.

#Why transcripts are the wrong long-term store

Three properties, all structural rather than incidental.

  • They do not compose. Two episodes concerning one entity produce two internally coherent transcripts with nothing linking the entity across them.
  • They have no contradiction surface. Disagreement is visible only once both are read into a context window by a model that may or may not notice, and attention to material in long inputs is known to be position dependent .
  • They price recall by length. Retrieval cost grows with history rather than relevance.

Retrieval augmentation addresses the third by fetching selectively and does not address the first two, because the retrieved unit is still text.

#The distillation step

At episode close, each conclusion is emitted as a claim carrying the observations it rests on and a confidence.

c  =  s,  p,  o,  Π(c),  κ(c),Π(c)Oec \;=\; \langle s,\; p,\; o,\; \Pi(c),\; \kappa(c) \rangle, \qquad \Pi(c) \subseteq O_{e}
(1)
A claim, with the support set that makes it revisable

Π(c) is the support set from episode e, and κ(c) the confidence. A claim with an empty support set is malformed rather than weak and is rejected by the distiller. That single rule removes a substantial proportion of low-quality output before it reaches the graph, because a model asked to summarise will readily produce statements it cannot ground .

#Identity

Revision requires that two episodes mentioning one entity produce edges on one node. Node identity is derived as a hash of tenant, kind and normalised external identifier rather than allocated , so convergence is structural rather than achieved by a matching pass. Multi-source identity and its failure modes are treated separately.

#Confidence across episodes

κ(c)  =  1i=1n(1κi(c))\kappa(c) \;=\; 1 - \prod_{i=1}^{n}\left(1 - \kappa_i(c)\right)
(2)
Composition over support sets assumed independent

Agreement between independent observations should count for more than either alone, which this expresses. Two episodes each arriving at a claim with confidence 0.8 compose to 0.96, which is the intended behaviour when the episodes genuinely looked at different things.

#The independence problem

The independence assumption is the weakest step in the construction, and it deserves its own treatment rather than a line in the limitations, because the way it fails is systematic rather than occasional.

Return to the worked example. Suppose three separate episodes each conclude that P-101A feeds the separator, each with confidence 0.8. Composed under the rule above, the claim reaches 0.992. Now suppose all three episodes reached that conclusion by reading the same piping diagram, which is eighteen months out of date. The three observations are not three pieces of evidence. They are one piece of evidence counted three times, and the composition rule has converted a single stale document into near certainty.

This is not a rare configuration. It is the expected one, because agents operating over a fixed corpus will repeatedly consult the most accessible document, and accessibility correlates with nothing about correctness. The rule is therefore most confidently wrong exactly where a document is both widely read and outdated.

Treating source documents as first-class nodes makes the shared provenance detectable: the three support sets intersect, and the intersection is visible by traversal. Detection is genuinely useful and it is not a solution. Knowing that three observations share a source does not say what confidence they should compose to, and the honest answers range from treating them as one observation, which is too harsh when the episodes also consulted other material, to a discount factor with no principled basis.

The current implementation detects and reports shared provenance and does not adjust confidence for it, which means the displayed number is known to be wrong in a known direction. That is defensible only because the direction is stated. No calibration is offered, and calibration is the piece of work that would make the confidence values load-bearing rather than indicative.

#Revision as traversal

R(o)  =  {cC  :  oΠ(c)}    CR(o) \;=\; \bigl|\{\, c \in C \;:\; o \in \Pi^{*}(c) \,\}\bigr| \;\ll\; |C|
(3)
Cost of revising a retracted observation

The transitive support closure Π* bounds the work. When an observation is retracted, the claims requiring revision are exactly those whose closure contains it, and they are found by walking support edges backwards from the retracted observation.

1func (g *Graph) Retract(ctx context.Context, o ObsID) ([]ClaimID, error) {
2 affected, seen := []ClaimID{}, map[ClaimID]bool{}
3 queue := g.claimsSupportedBy(o) // direct dependents, one index lookup
4
5 for len(queue) > 0 {
6 c := queue[0]
7 queue = queue[1:]
8 if seen[c] {
9 continue // support graphs are DAGs but not trees
10 }
11 seen[c] = true
12 affected = append(affected, c)
13 queue = append(queue, g.claimsSupportedBy(c)...)
14 }
15 return affected, nil
16}

The traversal terminates because support edges point from a claim to what it rests on and cycles are rejected at write time. Its cost is proportional to the affected subgraph rather than to the store, which is the property that makes retraction a routine operation rather than an exceptional one.

Without retained provenance the only sound response to a retraction is full re-derivation, which is infeasible, so transcript-based memory falls back to the unsound response, which is to do nothing. The contradicting statement is simply added and both persist.

#Relation to existing agent memory

The generative agents architecture maintains a memory stream retrieved by recency, importance and relevance, with periodic reflection producing higher-level statements . The construction here is close in shape and differs in one respect that matters: reflections are stored as graph edges with retained provenance rather than as text, which is what makes them revisable. A reflection in the memory stream that turns out to be wrong can be retrieved and contradicted; it cannot be traced to what produced it.

Systems that manage context as a memory hierarchy, paging between a working set and external storage, address a different bottleneck . Their concern is fitting relevant material into a bounded window, and their unit remains text. Both concerns are real and largely orthogonal: a hierarchy decides what to load, and the construction here decides what a loaded item means and what depends on it.

Self-critique loops in which an agent reflects on failures and carries verbal lessons forward improve performance within a task . The lessons are episodic and are not accumulated into a store other agents or later sessions query, so the contradiction problem does not arise for them and is not solved by them.

Graph-structured retrieval has separately been shown to support query-focused summarisation over corpora where flat retrieval performs poorly , and retrieval augmentation addresses the cost of recall without changing the unit retrieved . The representational arguments for graphs over text apply here for the same reasons they apply there .

#The evaluation that has not been run

No measurement is reported showing that an agent using this construction answers better than one using a transcript store with retrieval. Since that is the claim the whole paper implies, the experiment deserves to be specified rather than merely wished for.

The task would be a sequence of episodes over a domain where ground truth changes, with contradictions introduced deliberately at known points. The measure is not answer quality in aggregate, which would be dominated by cases where nothing changed, but performance on a held-out set of questions whose correct answer differs before and after a contradiction. Three conditions: transcript store with dense retrieval, transcript store with graph-structured retrieval, and the claim graph described here.

Two quantities matter. The first is the proportion of post-contradiction questions answered from the superseded fact, which is the error the construction is meant to eliminate. The second is the proportion of pre-contradiction facts incorrectly revised, since a system that aggressively retracts will score well on the first measure by being wrong in the other direction.

The reason this has not been run is that constructing the corpus is the expensive part: contradictions must be genuine, dated and verifiable, and synthesising them tends to produce contradictions that are easier to detect than real ones. That is an explanation rather than an excuse, and until the experiment exists the argument here is structural.

#Limitations

Independence, as above. This is the defect a reviewer will find first, it is systematic rather than occasional, and it is acknowledged rather than resolved.

Selection. Which conclusions become claims is decided by a model. A conclusion never emitted is silently lost with no signal at the time, which is a worse failure than an emitted claim that turns out wrong, because the wrong claim is at least visible and revisable. Emitting low-confidence claims liberally and pruning later trades a silent-loss problem for a graph-pollution problem, and no evidence is offered on which is preferable. My own guess, worth what a guess is worth, is that liberal emission wins because pollution is measurable and silent loss is not.

Calibration across models. Confidence values from models of differing verbosity and differing tendency to hedge are not on a common scale, and the composition rule assumes they are. A store accumulating claims from several models over time is composing numbers that mean different things.

Retraction is not deletion. The traversal identifies affected claims. What to do with them is a policy the construction does not settle: lowering confidence, marking them disputed and retaining both, or removing them are all defensible, and the current implementation marks rather than removes, which grows the store monotonically and has no pruning story.

No end-to-end evaluation, as set out above. Until that experiment is run, the case for this construction is that it makes an operation possible which is otherwise unavailable, not that agents using it demonstrably perform better.

References

  1. [1]Nelson F. Liu et al., Lost in the Middle: How Language Models Use Long Contexts, Transactions of the Association for Computational Linguistics, vol. 12, pp. 157-173, 2024doi:10.1162/tacl_a_00638
  2. [2]Patrick Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, Advances in Neural Information Processing Systems (NeurIPS), 2020
  3. [3]Ziwei Ji et al., Survey of Hallucination in Natural Language Generation, ACM Computing Surveys, vol. 55, no. 12, 2023doi:10.1145/3571730
  4. [4]Ralph C. Merkle, A Digital Signature Based on a Conventional Encryption Function, Advances in Cryptology (CRYPTO 87), Springer, 1988doi:10.1007/3-540-48184-2_32
  5. [5]Joon Sung Park et al., Generative Agents: Interactive Simulacra of Human Behavior, ACM Symposium on User Interface Software and Technology (UIST), 2023doi:10.1145/3586183.3606763
  6. [6]Charles Packer et al., MemGPT: Towards LLMs as Operating Systems, arXiv:2310.08560, 2023https://arxiv.org/abs/2310.08560
  7. [7]Noah Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning, Advances in Neural Information Processing Systems (NeurIPS), 2023
  8. [8]Darren Edge et al., From Local to Global: A Graph RAG Approach to Query-Focused Summarization, arXiv:2404.16130, 2024
  9. [9]Aidan Hogan et al., Knowledge Graphs, ACM Computing Surveys, vol. 54, no. 4, 2021doi:10.1145/3447772