Share Compressed Context Across Multi-Agent Workflows
Pass compressed context between agents without replaying full outputs. SharedContext compresses and retrieves agent handoff data with ~80% token savings.
Use this file to discover all available pages before exploring further.
When agents hand off to each other, context is typically replayed in full — every research finding, every tool output, every intermediate result sent again to the next model. SharedContext solves this by compressing what moves between agents using Headroom’s full pipeline, typically saving ~80% of tokens on agent handoffs while keeping the original available on demand.
from headroom import SharedContextctx = SharedContext()# Agent A stores large outputctx.put("research", big_research_output, agent="researcher")# Agent B gets compressed version (~80% smaller)summary = ctx.get("research")# Agent B needs full details on something specificfull = ctx.get("research", full=True)
Store content under a key. Compresses automatically using Headroom’s full pipeline — SmartCrusher for JSON, CodeCompressor for code, Kompress for text.
Ephemeral, in-process. Designed for a single workflow run — one orchestrator handing work between agents. Entries live in memory (with a TTL), so they vanish when the process exits. No persistence across sessions.
Cross-Agent Memory
Persistent, cross-session. Designed for long-lived facts (preferences, project conventions) that should be recalled in every future session, regardless of which agent runs. Uses Memory() and is stored durably on disk.
Use SharedContext when you need to pass large intermediate outputs between agents in a single workflow. Use persistent memory when you need to remember something across many future sessions.
Under the hood, put() calls headroom.compress() — the same pipeline used by the proxy and MCP server — and stores the original in memory. get() returns the compressed version; get(full=True) returns the original.The compression pipeline routes each entry to the best compressor automatically:
Content type
Compressor
Typical savings
JSON arrays / objects
SmartCrusher
70–95%
Code (Python, JS, Go…)
CodeCompressor (AST-aware)
40–70%
Prose / logs / text
Kompress-v2-base
30–60%
The result is the same token budget as if you had summarized manually — with no extra LLM call.
SharedContext uses the same compression pipeline as the proxy but runs in-process with no network overhead. Originals are held in memory (bounded by max_entries and ttl) and are never written to disk.