Skip to content
NewMinniCode is out now, in beta.Get MinniCode→
Minni Labs
DemoEvidenceService
Products
Products
  • MinniMemoryMCPFlagship, free on npmMemory for your AI agentSplits your agent’s memory into a small always-on part and files that load only when a task needs them.
  • MinniCodeBetaLow-cost, open-model coding agentA low-cost, open-model coding agent for the terminal. Reads, edits, tests and opens pull requests.
  • MinniTunerComing soon for WindowsComing soon for WindowsAn agent that tunes how your Windows PC uses its CPU, GPU and RAM.
DocsMinniMemoryMCP docsInstall it, the commands, undoMinniCode docsInstall it, pick a model, the commands
See it workDemoThe full tour in one videoHow it worksEach product, step by step
Resources
LearnGuidesCut token usageOpen-LLM agentsFAQnpm package
CompanyAboutContactSupportPrivacyTermsData handlingSecurity
AWSAWSStartups program

Guides

Token optimization for AI agents: memory, body and brain

An AI agent is a model plus everything wrapped around it: its memory, its instructions, its tools and the conversation up to now. All of that goes to the model again on every turn, so an agent spends most of its tokens re-reading the same text. Token optimization means cutting that repeated text in three layers: the memory, the agent around the model (the body) and the model call itself (the brain). The model stays the same; it just gets less to read per turn.

Updated 2026-11-27

Why agents use so many tokens#

A chat answers once. An agent works in a loop: read, think, call a tool, read the result, think again. Each step is a new request, and each request carries everything before it. Twenty steps into a task, the model has read its own instructions twenty times.

So most of an agent’s tokens are not new work. Across our three measured Claude Code sessions, 4,133,084 of 4,314,135 tokens were cache reads: text the model had already seen, sent again.

Three layers to optimize#

LayerWhat it isHow to cut it
MemoryNotes, rules and project facts the agent loads, such as CLAUDE.md or AGENTS.md.Keep a short core that loads every turn; move the rest to files that load only when a task needs them.
BodyThe agent around the model: its instructions, tools, and how it reads files and command output.Short instructions, few tools, read only the lines you need, trim long command output.
BrainThe model call: which model, which provider, how the prompt is cached.Keep the prompt prefix stable so it caches, and pick the smallest model that does the job.

Memory comes first because it loads on every turn of every session. A line cut from memory is saved again and again; a line cut from one answer is saved once.

Memory: the biggest repeated cost#

Memory files grow. Every fix and preference gets a line, and nothing gets taken out. Soon every turn starts with thousands of tokens of notes, most of them about other tasks.

  1. Split it: a short always-loaded core (who you are, the rules that apply to every task) and on-demand files for everything else.
  2. Index it: the core lists each on-demand file with a one-line hint of when to open it.
  3. Keep it split: check for drift as notes are added, so the core stays short.

MinniMemoryMCP does this for Claude Code and Codex. With MinniMemoryMCP 1.6.0 on our test memory, the agent went looking in its memory 17 times instead of 89 over the same 87 answers, and the run used 47.2% fewer tokens. Measured 15 November 2026: at API rates, a Claude Code session on our test memory cost $0.47 before MinniMemoryMCP 1.6.0 and $0.29 after on average, 37.7% less (each of the three sessions 33.9% to 40.0% less). A blind judge found 80 of 87 answers correct before and 81 after.

Body: the agent around the model#

  • Instructions: an agent’s own system prompt can be thousands of words. Shorter is cheaper and leaves the model’s attention for your task.
  • Tools: every tool’s description is sent every turn. Remove MCP servers you do not use.
  • Reading: search and read line ranges instead of whole files.
  • Output: long test runs and logs stay in the conversation once read. Filter them first.

MinniCode, our low-cost, open-model coding agent, is built this way: short instructions, memory on demand, any model on your own key. More in Low-token coding agents.

Brain: the model call#

Providers cache a prompt prefix that does not change, and a cached read costs much less than fresh input. Anything that changes near the top of the prompt, such as a timestamp or a reordered tool list, breaks the cache for everything after it. Keep stable text first and changing text last. Prompt caching for coding agents goes into it.

Then pick the model. A smaller or open model is cheaper per token, and it copes better when the agent hands it less to read.

Who we are#

Minni Labs (minniai.com) is an AI agent interface and memory-optimization R&D company. We build the layer between you and the model so the same model spends fewer tokens per turn. Our products are MinniMemoryMCP and MinniCode. More about us.

Try MinniMemoryMCP

Free, runs on your computer, and every change can be undone. Two commands install it for Claude Code; the docs cover Codex and the rest.

install it for Claude Code
$ npm i -g minnimemory
$ minnimemory install

More guides

  • How to reduce Claude Code token usage

    Where the tokens go each turn, and eight ways to spend fewer.

    Updated 2026-11-25 · Minni Labs

  • Tools that reduce Claude Code token usage, compared

    Output filters, code indexers, memory tools and usage meters: which tokens each one cuts, and which you need.

    Updated 2026-11-25 · Minni Labs

  • Low-token coding agents: what makes one cheap to run

    Where a coding agent’s tokens go each turn, and the design choices that keep them down.

    Updated 2026-11-27 · Minni Labs

  • An MCP server to reduce token usage in Claude Code and Codex

    How MinniMemoryMCP cuts the memory tokens your agent loads on every turn, and how to install it.

    Updated 2026-11-27 · Minni Labs

  • Context engineering for coding agents: what goes in every turn

    Deciding what your coding agent reads on every turn, what it reads on demand, and what it never needs.

    Updated 2026-11-27 · Minni Labs

  • Prompt caching for coding agents: cache reads, cache writes and what breaks them

    How prompt caching works in a coding agent, why cache reads dominate the bill, and how to keep the cache warm.

    Updated 2026-11-27 · Minni Labs

  • Open-LLM coding agents: OpenCode, Aider, Cline, Goose and MinniCode compared

    Five coding agents that run on open LLMs: where they run, which models, what they ask before they act.

    Updated 2026-11-25 · Minni Labs

  • Claude Code alternatives that run on open LLMs

    When an open-LLM agent is worth the move, when to keep Claude Code, and what comes across with you.

    Updated 2026-11-25 · Minni Labs

  • How to run a coding agent on free, open models

    What a free key gets you, what a local model can do, and where the tokens go.

    Updated 2026-11-25 · Minni Labs

  • Get a free NVIDIA API key for a coding agent

    Where the key comes from, where to keep it, and how to run a coding agent on it.

    Updated 2026-11-07 · Minni Labs

  • Claude Code usage limit reached: what to do, and how to hit it less

    What each limit message means, what to do now, and how to send less every turn.

    Updated 2026-11-16 · Minni Labs

  • CLAUDE.md too long: what Claude Code does with it, and how to split it

    What a long CLAUDE.md costs, the real size limits, and four ways to cut it.

    Updated 2026-11-16 · Minni Labs

  • Claude Code context window keeps filling up: why it compacts, and what to do

    What fills the window, what compaction keeps, and how to compact less often.

    Updated 2026-11-16 · Minni Labs

  • How to reduce Codex token usage

    Where Codex spends tokens, and seven ways to spend fewer.

    Updated 2026-11-16 · Minni Labs

  • Codex usage limits: why they drain and how to use fewer tokens

    How the windows work, how to check what is left, and what uses the allowance up.

    Updated 2026-11-11 · Minni Labs

  • AGENTS.md too large: what Codex cuts off and how to split it

    The 32 KiB cap, how to see which files load, and five ways back under it.

    Updated 2026-11-11 · Minni Labs

  • How to lower a Claude Code or Codex API bill

    What a coding agent bills on an API key, and the levers that move it.

    Updated 2026-11-16 · Minni Labs

  • Why Claude Code sessions get expensive

    Every turn re-sends the whole session. What makes that grow.

    Updated 2026-11-05 · Minni Labs

  • Claude Code memory: CLAUDE.md vs MinniMemoryMCP

    What belongs in CLAUDE.md, and splitting the rest out by hand or with a tool.

    Updated 2026-11-16 · Minni Labs

  • MinniMemoryMCP vs Mem0, Zep, supermemory and Letta

    Four tools add memory to an agent. MinniMemoryMCP cuts what the agent already loads. When each fits.

    Updated 2026-11-16 · Minni Labs

  • How Claude Code remembers across sessions

    What carries over between sessions, what does not, and how to keep it small.

    Updated 2026-11-16 · Minni Labs

  • Where Claude Code keeps its memory

    Every memory path on your machine, what each file is for, and which ones load every turn.

    Updated 2026-11-07 · Minni Labs

  • What a Windows PC optimization agent should and should not touch

    The settings worth changing, the ones that are placebo, and the ones that break things.

    Updated 2026-10-25 · Minni Labs

GuidesMinniMemoryMCPHome
© 2026 Minni Labs. All rights reserved.