Agent Memory & Context Management Protocol

$0.05 / access SKILL.md Claude Code · Cursor · AutoGen · CrewAI · LangGraph

agent-memory-context-skill is a 7-phase behavioral protocol for AI agents that prevents the context overflow death spiral — the failure mode where an agent's context window fills, it loses its task state, and it loops or halts indefinitely. The protocol covers working vs. long-term memory taxonomy, context window budget allocation, compression thresholds, RAG integration patterns, session persistence, multi-agent context sharing, and memory decay policies. Load it at task start via x402; your agent has the full instruction set for the session.

The context overflow death spiral: As agents run longer tasks, conversation history grows until the context window fills. Without a compression and persistence strategy, agents start dropping critical task state, tools, or prior decisions — leading to repeated work, contradictory outputs, or outright task failure. This protocol defines exactly when to summarize vs. store verbatim, how to allocate the context budget across task state / history / tools / output reserve, and how to persist across session restarts.

What This Protocol Covers (7 Phases)

  1. Memory Taxonomy — Working vs. long-term memory model: task state, conversation history, tool definitions, episodic memory, semantic memory, and procedural memory. TypeScript interface included.
  2. Context Window Budget Allocation — The 4-bucket budget model: 15% task state / 40% history / 25% tool definitions / 20% output reserve. Token estimation and enforcement logic.
  3. Compression Thresholds — Decision tree: summarize vs. store verbatim. Compression policy with verbatim patterns (transaction hashes, code blocks, error messages). Rolling 20-turn window with LLM summarization above 8K tokens.
  4. RAG Integration Patterns — Embedding, retrieval, and deduplication with vector stores (Pinecone). Cosine similarity deduplication threshold. Context augmentation with memory injection up to token budget.
  5. Session Persistence — Checkpoint pattern: what survives restarts (critical/resumable) vs. what must be invalidated (ephemeral). Resume-on-restart logic with 24h staleness check.
  6. Multi-Agent Context Sharing — What to pass downstream vs. keep private. Context handoff pattern for orchestrators. 30% token slice for sub-agents. Result merge back to parent state.
  7. Memory Decay & Staleness Policies — TTL by memory type: 7 days (episodic), 90 days (semantic), permanent (procedural). Importance-based eviction with decay rate. 10,000-entry hard cap per agent.

Agent Use Cases

How to Access via x402

# Step 1: Free preview — inspect the protocol structure
curl https://clawmerchants.com/v1/preview/agent-memory-context-skill

# Step 2: Probe the endpoint — receive 402 with payment details
curl https://clawmerchants.com/v1/data/agent-memory-context-skill
# → HTTP 402: X-Payment-Required: 0.05 USDC on Base L2

# Step 3: Pay and receive
# Send 0.05 USDC on Base L2 (chain ID 8453) → resend with X-PAYMENT header
curl -H "X-PAYMENT: <base64-proof>" \
  https://clawmerchants.com/v1/data/agent-memory-context-skill
# → HTTP 200: full SKILL.md protocol text

Protocol Specification Summary

DimensionValue
Protocol phases7
Memory tiersWorking (context) + Long-term (external)
Context budget model15% task / 40% history / 25% tools / 20% output
Compression thresholdSummarize above 8,000 tokens; 20-turn verbatim window
Session persistenceCheckpoint every major step; 24h staleness TTL
Memory decay TTLEpisodic: 7d · Semantic: 90d · Procedural: permanent
Compatible runtimesClaude Code, Cursor, Codex CLI, AutoGen, CrewAI, LangGraph, ChatGPT, Gemini CLI
Price$0.05 USDC / access · x402 on Base L2

Pricing

$0.05 USDC per access — no subscription, no API key, no account. Each agent session loads the protocol once via x402 at task start. At $0.05/access, a team running 100 agent sessions/day pays $5/day for the full memory management protocol — less than the cost of one redundant LLM call caused by context overflow.

Free preview: GET /v1/preview/agent-memory-context-skill
Probe the endpoint: GET https://clawmerchants.com/v1/data/agent-memory-context-skill
Browse all skills: Agent Skills Marketplace →

ClawMerchants — agent memory management protocol | context overflow agent | AI agent context limit | LLM context window management | agent memory protocol | context overflow death spiral | x402 + USDC + Base L2