English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Everything is Context: An Agentic File System Abstraction for Context Engineering

Forum topic · ✨步子哥 · 2025-12-11

Summary

This post presents an architecture that treats all agent context—memory, tools, external knowledge, and human input—as files, inspired by the Unix 'everything is a file' philosophy. It argues that modern GenAI challenges have shifted from model fine-tuning to context engineering: capturing, structuring, and governing the full lifecycle of context. Current practices (prompt engineering, RAG, tool integration) remain fragmented, producing ephemeral, untraceable context artifacts prone to context rot and knowledge drift. The proposed Agentic File System (AFS) provides unified mounting, structured metadata, fine-grained access control, versioning, and audit logging, enabling modularity, separation of concerns, traceability, and composability. On top of it, a verifiable context engineering pipeline is built from three components: a Context Constructor that selects and compresses context under a token budget and emits a JSON manifest; a Context Loader that assembles context in static or streaming mode while tracking token usage; and a Context Evaluator that verifies model outputs against source context, computes a consistency confidence score, triggers human review below a threshold, and persists validated knowledge to long-term memory with full provenance. The architecture is implemented in the open-source AIGNE framework and demonstrated with two examples: a memory-equipped agent and an MCP-based GitHub assistant mounted at /modules/github-mcp.

Everything is Context: An Agentic File System Abstraction for Context Engineering

This is an English translation of a Chinese forum post discussing a context-engineering architecture for generative AI systems.

Introduction: From Model Fine-Tuning to Context Engineering

Generative AI is reshaping software system design, with foundation models acting as pre-trained subsystems. The challenge today is no longer fine-tuning models but context engineering: how systems capture, structure, and govern external knowledge, memory, tools, and human input to enable trustworthy reasoning.

Current practices—prompt engineering, RAG, and tool integration—remain fragmented, producing context artifacts that are ephemeral and untraceable, limiting auditability and accountability.

To address this, the post proposes a file system abstraction for context engineering, inspired by the Unix philosophy "everything is a file." The abstraction provides persistent, governable infrastructure for managing heterogeneous context artifacts through unified mounting, metadata, and access control. It is implemented in the open-source AIGNE framework, forming a verifiable context engineering pipeline consisting of a Context Constructor, Loader, and Evaluator that assemble, deliver, and verify context under token constraints. As GenAI becomes an active collaborator in decision support, humans play key roles as curators, verifiers, and co-reasoners. The architecture is demonstrated with two examples: a memory-equipped agent and an MCP-based GitHub assistant.

Background: The Rise of Context Engineering

Unlike prompt engineering, which focuses on individual instructions, context engineering addresses the entire information lifecycle—selection, retrieval, filtering, structuring, compression, evaluation, and refreshment—to keep GenAI systems coherent, efficient, and verifiable over time.

Industry frameworks such as LangChain already treat context engineering as a structured process with four stages: writing context to shared memory, selecting relevant elements, compressing to fit model constraints, and isolating the final subset for reasoning. Similar pipelines appear in frameworks like AutoGen. However, these solutions are ad hoc and implementation-driven, lacking a unified architectural foundation for traceability, governance, or systematic handling of evolving context—leading to challenges like context rot and knowledge drift.

Related academic work includes the LLM-as-OS paradigm:

  • AIOS operates multi-agent systems with OS-like primitives (scheduling, resource allocation, memory management).
  • MemGPT introduces memory hierarchies coordinating short-term context windows with long-term external storage.
  • Model Context Protocol (MCP) is an open standard for securely connecting AI assistants to data sources via a client–host–server architecture and JSON-RPC stateful sessions. However, MCP focuses on data access, not the organization, governance, or verification of context within the model.
  • The file system abstraction fills this gap: a persistent, governable, unified infrastructure for context engineering.

    The File System Abstraction: Persistent Context Infrastructure

    The core contribution treats all heterogeneous context sources (memory, tools, external knowledge, human contributions) as files in a unified namespace. Benefits include:

  • Abstraction & unified interface — vector memories, tool definitions, and knowledge entries are all accessed via file paths and standard operations (read, search, write, execute); integrating a new source is as simple as mounting a new file system.
  • Modularity & encapsulation — each context source is an independent namespace integrated via mount points, enabling independent evolution.
  • Separation of concerns — context management (access control, metadata, audit logs) is separated from model reasoning.
  • Traceability & verifiability — all operations on context files are logged; version control and snapshots allow rollback and verification.
  • Composability & evolvability — one agent's memory can be mounted as a subdirectory of another agent's context; new sources can be added without architectural changes.
  • Concretely, this manifests as an Agentic File System (AFS) offering core file operations. Every context file carries structured metadata (creation time, owner, permissions, source ID, version), access control is enforced per-path, and every operation generates a log entry for full traceability. Context becomes an explicit, manageable entity rather than a hidden, ephemeral variable.

    The Context Engineering Pipeline

    Built atop the AFS, the pipeline systematically assembles, delivers, and verifies context under token-window constraints:

    Context Constructor

    Queries mounted namespaces (e.g., /context), scores candidate files by relevance (semantic similarity, recency), applies access-control and governance constraints, ranks candidates, and includes files under a token budget (\(T_{\max}\)), summarizing or truncating when needed. It outputs a manifest (typically JSON) listing selected files, their order, and selection rationale (e.g., relevance scores)—a key auditability artifact.

    Context Loader

    Physically reads and assembles the selected context into the model's prompt buffer, supporting static mode (one-shot loading, for single-turn tasks) and streaming mode (incremental loading, for multi-turn conversations and large context queues). It continuously monitors token usage, replacing or appending segments as needed, and logs every injection or update with session ID, timestamp, and source path.

    Context Evaluator

    After inference, the evaluator extracts atomic claims from the model's output and compares them against the source context referenced in the manifest. By computing the intersection of output facts and source facts, it derives a consistency confidence score. If confidence falls below a threshold \(\theta\), human review is triggered. Approved outputs have validated new knowledge persisted to long-term memory (e.g., /context/memory/...) with full provenance, and verification results are appended to a transaction log for auditing.

    Together: the Constructor ensures *the right context*, the Loader ensures *context is used correctly*, and the Evaluator ensures *the context was correctly used*—a closed, verifiable loop.

    Implementation: The AIGNE Framework and Examples

    The architecture is implemented in AIGNE, an open-source, composable, TypeScript-first framework for building agent logic. AIGNE provides a multi-model adapter (AIGNE Hub) exposing many foundation models behind a unified API. Its AFS module mounts external sources—vector databases, knowledge graphs, MCP servers—into a unified namespace, and the Constructor/Loader/Evaluator pipeline is embedded into agent execution with full logging.

    Example 1: Memory-Equipped Agent

    Memory is stored under /context/memory/{agentID}/ (user preferences, conversation summaries). The Constructor retrieves relevant history, the Loader assembles the prompt, the model responds, and the Evaluator checks consistency and writes new useful information (e.g., new preferences) back to memory—enabling coherent, personalized multi-turn behavior.

    Example 2: MCP-Based GitHub Assistant

    An MCP server exposing GitHub data (code files, issues, pull requests) is mounted at /modules/github-mcp, letting the agent query GitHub as if it were a file system. The Constructor retrieves relevant code snippets or issue information, the model generates answers, and the Evaluator verifies them against GitHub data, persisting useful conclusions (e.g., issue summaries) to memory.

    These examples demonstrate the architecture's operability and adaptability for building agents with persistent memory and external data access in a verifiable, maintainable way.

    Conclusion and Future Directions

    By treating context as files, the architecture provides a persistent, governable infrastructure that addresses fragmented, untraceable context management and lays a foundation for accountable, human-centered AI collaboration. Future directions include:

  • Deeper context governance policies (fine-grained access control, privacy, compliance auditing).
  • More efficient context retrieval and compression algorithms under token constraints.
  • Unified management of multimodal context (text, images, code).
  • Designing intuitive interfaces for human-in-the-loop context curation and verification.
The file system abstraction and pipeline offer a solid, extensible starting point for building trustworthy, controllable GenAI systems.

Tags

#context-engineering#agentic-ai#file-system#llm#mcp#rag#ai-agents#aigne

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/176415117