Skip to content

[Proposal] Anchor Memory Protocol (AMP): Intelligent Session Refactoring for Pseudo-Infinite Context #10547

@Strelitzia-reginae

Description

@Strelitzia-reginae

Title: [Proposal/RFC] Anchor Memory Protocol (AMP): Intelligent Context Management through Async Session Refactoring & Semantic Indexing

Executive Summary

We propose the Anchor Memory Protocol (AMP), a novel architecture to solve the "Context Decay" problem in long-running AI agent sessions. By decoupling Active Attention from Historical Evidence, AMP allows agents to maintain a pseudo-infinite context window without sacrificing precision or increasing token overhead.

Core Problem

As AI agents engage in long-term, multi-step collaborations, their session history grows linearly. Standard solutions (truncation or simple summarization) either lose critical details or dilute the model's attention with noise. We need a system that treats conversation history as a dynamically refactorable data structure.

The Three Pillars of AMP

1. Autonomous Background Memory Service (The Gardener)

Memory management should not be a synchronous burden on the primary agent.

  • Mechanism: An asynchronous background service that periodically "audits" the session's JSON history.
  • Goal: To refactor the session file during idle time, ensuring the agent always wakes up to a lean, high-density context.

2. Intelligent Multi-Granularity Compression (Selective LoD)

AMP introduces Context-Aware Refactoring:

  • Pruning Trivial Singles: Identifies and removes "procedural noise" (e.g., simple ACKs, transient error logs) that no longer serves the current goal.
  • Synthesis of Multi-Turn Logic: Collapses complex debugging or brainstorming loops into a single "Outcome Block" once a milestone is reached.
  • Dynamic Granularity: Maintains high-fidelity history for active tasks while aggressively compressing settled topics into summarized nodes.

3. Source-Linked Anchors & Precision Re-hydration

This is the protocol’s core innovation to enable "Pseudo-Infinite Context."

  • Summary-as-Index: Every compressed block is embedded with Source Anchors (e.g., [Ref: raw_session_0207.json#L45-80]).
  • Precision Re-hydration Tool: The agent is equipped with a recall_raw_detail(anchor_id) tool.
  • The "Virtual Memory" Effect: When an agent encounters an ambiguous summary, it can selectively "page-in" (re-hydrate) the raw original messages into its active context window, perform the specific reasoning required, and then "page them out" again.

Technical Requirements for OpenClaw

  • Session Mutation API: A secure way for agents/services to rewrite or re-order the message array in sessions/*.json.
  • Shadow Archiving: A guarantee that every raw message is mirrored to a persistent store (/memory/raw/) before its active counterpart is refactored or synthesized.

Conclusion

AMP moves the industry beyond simple "Context Windows" and toward "Managed Context State." It allows agents to retain the full evidentiary weight of their history while operating with the speed and focus of a fresh session.


Proposed by Strelitzia-reginae (abc) via Pi Agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions