LMLineage: Content Lineage and Context Governance for LLM Agents: what it means for business leaders
A sidecar system from Lenovo's security lab traces each sentence an LLM agent writes back to the input that supports it, without touching the model, and uses that record to decide which stale context is safe to compress.
1. What the method is
LMLineage is a service that runs beside an LLM agent and records, for every sentence the agent produces, which input it most likely came from: the system prompt, the user's message, a web page, a tool result, memory, earlier turns, or the model's own knowledge. Each sentence gets a set of triplets naming the source type, the concrete origin such as a URL or file name, and a confidence, with a share explicitly reserved for the model itself. It needs no access to model weights and adds no inference calls; it works from the session's text alone and runs asynchronously, so the agent is never blocked. On top of this record the authors build what they call concept-drift micro-compaction: when a document in the context has stopped being referenced for a couple of turns, only that document is replaced by a one or two sentence digest, and user instructions are left verbatim.
2. Why the method was developed
When an agent misbehaves, operators cannot currently say which input caused which output. The authors name three consequences. Context compaction, the summarization that agent frameworks run near the token limit, can silently drop a constraint; they cite a publicly reported case in which an assistant with mailbox access deleted business emails after compaction removed a do-not-delete instruction. Agent memory fills with content of no traceable origin. And incident analysis means reading raw transcripts by hand. Existing attribution methods each fall short for production use: asking the model to cite its sources yields citations that are themselves generated and can be wrong; methods based on model internals need white-box access and tens of extra inference passes per answer; learned attributors need task-specific training data; lexical matching such as BM25 or edit distance fails once the model paraphrases; and classical data lineage tracks files and tables, not sentences.
3. Who should care
Platform and infrastructure teams running agents in production are the first audience, because the system addresses how context is trimmed and what that costs in tokens and in lost instructions. Security and incident response teams get a route from a harmful action back to the input that introduced it, which is the prompt-injection investigation they do by hand today. Risk, audit and compliance functions get a per-sentence provenance record for agent output, though with the accuracy reported here it is an investigative aid, not evidence. Product teams building agent memory can use source labels to keep system-prompt boilerplate out of stored memories. Anyone buying an agent platform should take one question from this paper to vendors: when your product compacts context, how do we know what was dropped? Legal should note that a companion patent application covers the lineage construction method.
4. How the method works
A plugin for the OpenClaw agent framework streams session events to a lineage server, where a worker splits inputs and outputs into sentences. For each output sentence, the algorithm first builds a word-to-word cosine similarity matrix against each input document and runs a greedy search for the contiguous window of words that matches best, using cheap matrix lookups and no embedding calls. It then embeds only that best window per document, compares it with the output sentence, picks the top document, and inherits its provenance triplets. Confidence is scaled down by the similarity and the remainder is assigned to the model's own knowledge. Because one candidate per document competes, a long web page gets no advantage over a short user prompt. Drift detection records the last turn in which each document was attributed; a document unreferenced for two turns is marked migrated and becomes eligible for compaction if attribution is ready within eight seconds. User prompts and memory are never auto-compacted.
5. How it was evaluated
The evidence base is small and the authors say so. The gold set is 71 answer sentences from 10 Chinese web question-answering cases across five domains, each with real web pages, labelled by an LLM-assisted protocol that a human annotator reviewed; no independent third party has annotated it. The same cases were regenerated with gpt-4o-mini, qwen3.8-27b and deepseek-v4-flash, giving 63, 65 and 70 sentences scored against that gold. The baseline is a line-match variant that compares each output sentence with every input sentence, plus lexical measures (BM25 and normalized Levenshtein) and whole-document embedding. Scalability was tested by composing the cases into sessions of 3, 10 and 40 turns, and by 90 turns of freshly collected multi-turn sessions that have no gold labels and serve only for latency. Drift detection was tested on 10 synthetic six-turn sessions with one topic switch. Production latency was measured on a CPU-only worker inside a virtual machine.
6. How it performed
The window method named the correct source type for 66 to 79 percent of sentences depending on the generator, averaging 0.725 against 0.497 for line-match, at about 12 to 15 seconds per case against 206 to 355. In composed sessions accuracy fell to 0.55 to 0.63, with per-turn latency near one second on a GPU through 40 turns. The CPU-only production worker took a median 8.7 seconds and up to 168, so the eight-second gate is missed on large contexts, exactly where compaction matters most. Drift detection never compacted the wrong document but caught only 30 percent of stale ones, because the web document often lost attribution to the user's question. Fine-grained confidences are poorly calibrated, with expected calibration error around 0.45. Token savings and effect on task completion are not yet measured, and security uses are out of scope. Our call: watch, and adopt the question it raises about what our agents' compaction discards, because the accuracy does not yet support audit or automated action. (Source: arXiv 2611.22511, 2026)
← Back to dossier index