ZICQ
中 Log in / Sign up
Newsroom Paper Frontier Research #Long-Horizon Agents #Context Engineering #Knowledge Graphs #Memory Compaction

Self-Context: Graph-Based Context Management for Long-Horizon Agents

Avatar of Mr.Xu

By Mr.Xu Compiled & Reviewed by Editorial

Published:

中文阅读 (Chinese) English Version
Co-reading Select any sentence in the article to highlight, annotate, or copy a quote card. Join discussion ↓

Summary:The Self-Context authors propose a plug-and-play framework that sits between an LLM and its native agent harness. It separates context management into an editable working graph for exploration attempts and findings, plus a reversible history layer that folds interaction traces into summary notes and unfolds them back when detailed evidence is needed. The method targets a limitation of long-horizon agents: increasing the context window does not eliminate context pollution, while one-way compacti


Core idea: Move working memory out of the message tail

Self-Context is positioned as a plug-and-play layer between an LLM and its native agent harness rather than as a new foundation model. A larger context window increases capacity, but it does not solve relevance decay, stale observations, or context pollution. When tool calls, browser actions, and intermediate reasoning are continuously appended, the model eventually receives a long but weakly structured event stream.

The framework separates that history into two states: an editable working graph that preserves the structure of exploration, and a reversible history layer that can restore raw interactions when detailed evidence is required. The objective is not merely to shorten prompts, but to let the model decide what belongs in structured working memory, what can temporarily leave the active context, and when the original interaction should be retrieved again.

Architecture: Coordination between graph state and reversible history

1. Graph management

The graph management component records exploration attempts and their findings in an editable working graph. Its main benefit is not simply adding another retrieval source, but decoupling durable findings from a conversation history that only grows. Even when earlier interactions are compacted, relationships, dependencies, and unresolved questions can remain available as independent state.

The supplied abstract does not disclose the node types, edge relations, update protocol, or conflict-resolution policy. A production implementation therefore needs explicit semantics for nodes and edges, evidence provenance, versions, timestamps, confidence states, and contradictory conclusions. Without those controls, an agent may preserve an obsolete observation as if it were a structured fact.

2. History management through fold and unfold

The history layer exposes two operations. fold replaces the raw interaction history in the active context with summary notes, reducing noise and token consumption. unfold restores the original history when the agent needs to inspect evidence or reconstruct an earlier decision. Unlike one-way summarization, this design aims to preserve a path back to the original trace.

If unfold is genuinely supported, the raw trajectory usually remains in external storage rather than being physically erased. The framework therefore reduces how much history each model call must process, not necessarily total storage. It also cannot automatically repair a faulty summary: restoring the original transcript corrects what the model sees at that moment, but it does not validate every conclusion previously derived from the flawed summary.

A conceptual execution flow is: after an exploration step, the agent writes stable findings into the graph; when history becomes redundant or approaches the context budget, the harness executes fold; later decisions retrieve a relevant subgraph and invoke unfold only when evidence conflicts, exact step reproduction is required, or confidence in a summary is low. The actual triggers and retrieval policy still require verification against the full paper and implementation.

Engineering trade-offs: context savings are not free

Compute and storage

In standard full-attention prefill, the dominant attention term grows approximately quadratically with sequence length, or O(n²d). KV-cache residency is approximately O(n·L·H_kv·d_h·b). Folding can reduce the active sequence length n, lowering attention work, KV-cache pressure, and request cost. Raw logs, graph storage, and graph-operation calls still incur additional cost.

A working graph can also grow without bound. Without merging, expiration, and deduplication, retrieval may inject a large set of stale edges and turn structured memory into another form of context pollution. Production systems should cap the number of nodes and edges returned per turn and prioritize the local neighborhood most relevant to the current subgoal.

Consistency and reliability

The graph and transcript are two state sources: one emphasizes structured conclusions, while the other preserves process evidence. Without version binding, a model may act on stale graph nodes or mistake assumptions in a summary for raw observations. Each graph node should reference an event ID and evidence range, and the system should verify that restored history matches the node version.

Model-generated graph updates are also untrusted input. Prompt injection embedded in web pages or tool results could induce malicious graph instructions. Graph writes therefore require schema validation, provenance labels, permission boundaries, and audit logs rather than direct concatenation back into the prompt.

Orchestration overhead and model dependence

Graph operations add tool calls, protocol parsing, and potential latency. Repeated edits may introduce conflicts. Because the framework sits between the model and the harness, its benefits depend on the model reliably executing graph queries, writes, folds, and restores. Invalid edges or incorrect summaries would amplify rather than correct an agent's existing errors.

Reported results and evaluation limits

The paper abstract claims that Self-Context improves both task performance and interaction efficiency across three agent tasks. Mechanistically, the reported benefit comes from retaining critical findings for later decisions while maintaining exploration coherence. However, the supplied material does not identify the tasks, models, agent harnesses, context budgets, baselines, metric definitions, absolute scores, confidence intervals, run-to-run variance, or whether interaction efficiency means tokens, turns, latency, or monetary cost.

It is therefore not yet possible to conclude that Self-Context consistently outperforms full-history prompting, sliding summaries, retrieval-based memory, or external knowledge graphs. A rigorous reproduction should hold the base model, tool permissions, total token budget, and success criteria fixed, then report active-context size, total storage, end-to-end latency, API cost, summary error rate, and decision improvement after unfold. Reporting final task scores without graph-write and retrieval overhead would understate the framework's real cost.

Deployment guidance for developers

  1. Separate facts from process: Keep an immutable raw event log and treat the editable graph as a model-facing working view rather than the sole source of truth. Every node should carry an event ID, timestamp, originating tool, and version.
  2. Use a constrained graph schema: Define a small set of stable node and edge types, such as goals, findings, evidence, constraints, dependencies, and conflicts. Reject writes without provenance and include state and confidence fields so obsolete conclusions can expire.
  3. Retrieve locally instead of injecting the whole graph: Combine semantic relevance, graph distance, the active subgoal, and recency to select a bounded subgraph. Trigger unfold through evidence links when contradictions appear rather than restoring full history routinely.
  4. Make folding a controlled budget policy: Decide whether to fold using token occupancy, semantic redundancy, and subgoal state, while retaining raw records, summary versions, and rollback paths. High-risk actions should not rely solely on compressed summaries.
  5. Establish security and audit boundaries: Validate graph-write instructions against a schema, enforce access controls, and distinguish web content, tool output, and model inference in the logs to reduce persistent prompt-injection risks.
  6. Run a controlled A/B test: Compare native history, fixed-window summarization, retrieval memory, and Self-Context under the same model and tool permissions. Track task success, evidence-recovery quality, token use, wall-clock latency, cost, and variance across repeated runs.

The central contribution of Self-Context is to turn long-horizon agent context from a passively appended message log into an operational combination of graph state and reversible history. It is particularly relevant to agents that must explore for a long time, repeatedly gather evidence, and revisit earlier decisions. The supplied evidence is not yet sufficient to treat it as a validated universal memory architecture, but it is a technically coherent framework worth reproducing.


Source: Hugging Face Daily Papers (2026-12-01)

— END —

Tags: #Long-Horizon Agents #Context Engineering #Knowledge Graphs #Memory Compaction

Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.

What's your take on this story?
Explore & Submit Works

Community Comments

Loading live comments and annotations…