Memory for long-running agents

We index your agents' history, giving them infinite context and search across every session.

by PolyChat

Now in Claude Code: Announcing
Claude Code Infinite

How It Works

MemTree borrows the central idea of deep learning: understanding comes from a hierarchy of abstractions. MemTree does the same with your agent's history.

While your agent works, MemTree summarizes each new batch of messages in the background and files it under a topic. Each topic gets its own summary, and the whole session gets one at the top. When a session outgrows the context window, the agent works from these summaries plus your most recent messages, so the session can keep going indefinitely. When it needs a detail, it opens a branch and follows it down to the original messages.

Compressed as late as possible. On Opus 5 and up, Claude Code Infinite sends the vast majority of the 1M-token window word for word, exactly as Claude Code would. Only near the limit does it compress, to about half the window to minimize the number of compressions: recent messages stay word for word, and older ones become a searchable memory with the originals one tool call away.

Your memory is yours. Export any MemTree as JSON, summaries and original messages included. No lock-in.

What the video shows: a Claude Code session's messages fill its context window until they reach the context limit, and a "context window full" notice appears. Running /compact squeezes the conversation down in stages; details pop out and are thrown into a trash can, the last one a key that held an important detail, and the caption reads "/compact throws away what matters". Then "MemTree remembers": the same conversation comes back, and MemTree folds the older messages into a tree of summaries (Feature 1, its tasks and steps), the key filed under "Step 2 summary", while recent messages stay as they are. The user asks "step 2?"; the agent shows "Looking in MemTree…", a memtree_query("Step 2") call goes to MemTree, and the result "Feature 1 › Task 2 › Step 2" with the key comes straight back into the conversation as a tool result. The agent answers "Ah," with the key. End card: MemTree, memory for long-running agents, now in Claude Code as Claude Code Infinite, memtree.dev.

See a real one: the full MemTree of building agi.memtree.dev, an AI-safety simulator, across about 1,600 messages. Start at the one-line summary and drill down to any message.

Quickstart

Claude Code Infinite

Install:

npm install -g claude-code-infinite

Run it from your project folder:

ccc

Needs Claude Code in your terminal, signed in with Claude Pro or Max.

Don't have Claude Code yet?

macOS / Linux

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell

irm https://claude.ai/install.ps1 | iex

Then run claude once to sign in. The desktop app isn't enough: ccc needs the claude command in your terminal.

Recommended: Read the full docs here
Claude Code Infinite

In Settings > Providers

  • Set Base URL to
    https://polychat.co/api
  • Paste in your PolyChat API key
  • Choose a memtree- model
Optional Settings

In Settings > Providers

  • Set the Context Window Size to your model's limit, i.e. 200000 for memtree-sonnet-4-thinking-low

In Settings > Context

  • At the bottom, uncheck "Automatically trigger intelligent context condensing" - as we do this automatically
Kilo Code - MemTree Integration
Get your PolyChat API key
import openai

client = openai.OpenAI(
    base_url="https://polychat.co/api",
    api_key="YOUR_POLYCHAT_API_KEY"
)

response = client.chat.completions.create(
    model="memtree-sonnet-4",
    messages=[{"role": "user", "content": "Hello!"}],
)

print(response.choices[0].message.content)
âš¡ BLIND-GRADED BENCHMARK

Long-running task performance

On our long-session coding benchmark, MemTree beat Claude Code's /compact by 20 points

Benchmark score

On ~800k-token Claude Code session

Score
100% 80% 60% 40% 20% 0%
~420ktokens after MemTree
69%
MemTree
~13ktokens after /compact
49%
/compact
📊 Claude Opus 5.5 · graded blind

MemTree also matched full-context Claude Code on this test (69 vs 69). See how the benchmark works

How the benchmark works
Same score as full context with a third of the tokens

We resume a ~800k-token Claude Code session, give it a task, and grade the result blind against a fixed answer key. Each setup handles the long history its own way.

MemTree69%
full history up to ~800k, then compacted to ~420k

Sent every message word for word, as Claude Code would, until near the limit. Then older messages became their MemTree summaries, recent ones stayed word for word, and every detail stays searchable.

/compact49%
~13k tokens

Summarizes the whole history into a short note before starting, and the detail is gone.

Full context69%
grows to ~950k tokens

Keeps every message until Claude Code's auto-compaction fires mid-task.

Same score69%, matching full-context Claude Code
â…“ the tokens39M vs 113M input tokens per run
16 vs 38 minless than half the time
Past the context window
MemTree keeps the work, /compact loses it

A 1M+-token history of real Claude Code work, too big for any 1M window. The task: redo the lost code-review fixes exactly as the session agreed. The findings exist only in the conversation. MemTree gets three tools to dig into it: search (exact words or meaning), read_node (a summary and the branches under it) and read_lines (the original messages, word for word). Graded blind against the real fixes.

MemTree70%
8 of 8 findings addressed: 3 fully, 5 partly

Compressed the 1M+ tokens to ~200k on its first turn, keeping the most recent messages word for word; the code reviews were 550k+ tokens back. It searched its MemTree for them, opened the matching branch, and read the original review messages word for word, about 400 lines of findings and decisions, then implemented them. Nothing had to be saved in advance: every message stays reachable.

/compact23%
0 of 8 findings addressed

Its summary dropped the findings, so it had nothing to fix. It made no changes and asked for them.

69.9 vs 23.0blind score, mean of 6 rounds
8 of 8findings recovered from memory, every round
No full contextthe history doesn't fit in a 1M window

6 rounds, one task, Claude Opus 5.5. MemTree fixed 3 findings fully and 5 partly in every round. Blinding is weak: /compact made no changes, so a grader can tell the two apart.

Powering Context Memory on
tokens processed11B+
in production sinceAug 2025
API users5,000+
longest session, tokens9.6M
success rate, 30 days99.99%
median API latency~250 ms
About

Who builds MemTree

Craig Quiter was an early pioneer of deep learning for self-driving cars, creating Deepdrive, an open-source simulator for training and testing driving AI. He was formerly technical staff at OpenAI, worked on perception at Uber ATG, and was an ML engineer at Cruise. MemTree applies deep learning's core idea, hierarchies of abstraction, to agent memory.

OpenAIUber ATGCruiseDeepdrive

Get in Touch

Ready to explore infinite context for your AI workflows?

Made with ♥ in San Francisco, CA