Skip to content

Token economy

basemind saves tokens by answering with file paths, line numbers, and signatures — not whole files. A question about your code costs a small fraction of the tokens it takes to read the source.

When you ask “where is the User class defined?”, basemind returns:

src/models/user.ts:42

Reading the entire user.ts file would cost 200–2000 tokens, depending on size. The answer costs just a few tokens.

When you ask “what calls processFile?”, basemind returns 10 call sites with their paths and line numbers — enough for an agent to decide whether to open each one. Re-reading the whole calling files would explode your context.

The same discipline applies to every tool: code outline gives you a file’s structure (signatures, imports) before you open it, so you read only the span you need. code references returns pointers, not source. git recent shows what happened (commits + file list), not diffs.

See How it works to understand how basemind builds the map that makes this possible.

The saved-token figure in admin telemetry and the statusline is an estimate, not a measurement of your session. For each call, basemind counts the response tokens and multiplies them by a fixed per-mode factor modelling what a grep plus file reads would have cost:

Mode Factor
code symbols 25x
code outline, code references, code implementations 1.2x
memory documents 2.5x
web scrape / crawl / map 3x
git symbol_history 4x
git churn 3x
code callers, dependents, find, files, grep, graph modes, other git and admin modes 1x (no saving claimed)

The factors are calibrated from medians measured by basemind admin eval (see Evaluation); a mode where basemind did not beat its baseline claims 1x. Treat the total as an order of magnitude.

The plugin nudges agents toward the cheap path by default:

  • Get a file’s outline before opening it — then read only the part you need.
  • Search for a definition instead of grepping for it — code symbols vs grep.
  • Look up who calls a function instead of grepping for call sites — code references vs grep.
  • Refresh the index after edits — admin rescan instead of restarting the server.
  • Don’t re-read a file basemind already mapped — use the outline instead.

The plugin ships three hooks that enforce token discipline at the moment a tool is used. The guard is on by default; the other two are opt-in:

Terminal window
BASEMIND_GUARD=nudge # default: allow the call, add a one-time advisory
BASEMIND_GUARD=redirect # deny the call and point at the basemind mode
BASEMIND_GUARD=off # disable

When an agent reaches for a built-in Grep or Glob search, the guard points it at the matching basemind mode (code grep for patterns, code symbols for names, code references for call sites). In the default nudge mode the call goes through with an advisory, shown once per session per tool; redirect denies it. The guard needs jq and quietly does nothing without it.

Terminal window
BASEMIND_COMPRESS_OUTPUT=1

Off by default; 1, on, true or yes turns it on. When a Bash command returns long output (a build log, a directory listing), the compressor replaces it with a shorter summary chosen by the command family. It leaves the output alone when it detects a credential or would save under 10 %. The backend is the basemind compress-output command, which reads stdin.

Terminal window
BASEMIND_DELTA_READS=1

Off by default; 1, on, true or yes turns it on. When an agent re-reads a file it already read earlier in the session, the hook shows just the changed lines (basemind delta) instead of resending the whole file, and only when the diff is meaningfully smaller.

basemind shrinks code by keeping the shape and dropping the bodies — function signatures and imports stay, implementations go — because a signature is useless without its shape:

// Original (2,400 tokens)
pub fn process_file(path: &str) -> Result<Vec<Symbol>> {
let file = std::fs::read_to_string(path)?;
let mut tokens = vec![];
let mut depth = 0;
// 100 lines of parsing logic...
Ok(tokens)
}
// Compressed (240 tokens)
pub fn process_file(path: &str) -> Result<Vec<Symbol>>;

For prose, compression does a light cleanup: extra whitespace, filler paragraphs, repeated content. It reports honest before/after token counts, and the code version is exact — nothing is lost, just set aside.

code expand brings any one symbol’s full body back when an agent actually needs it: compress to an outline, then expand only what you read.