cd /news/ai-agents/your-agent-isn-t-running-out-of-cont… · home › topics › ai-agents › article
[ARTICLE · art-157241] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Your agent isn't running out of context because of one big file

A developer built Context Diet, an open-source MCP server and CLI that deterministically shrinks the content AI agents send by deduplicating, extracting and extractively summarizing text while keeping every output line verbatim and accounting for each dropped line in a manifest. On a sample session log packed to a 400-token budget with the query "test failure," the tool cut 169 lines and 7,917 bytes (about 1,942 estimated tokens) down to 23 lines and 1,587 bytes (about 392 estimated tokens), with the manifest reconciling 23 kept, 54 deduped, 4 extracted away and 88 summarized away. The MIT-licensed tool runs locally with no model calls or network access and is distributed via GitHub, with an npm package planned.

by read3 min views1 publishedOct 25, 2026

Your agent isn't running out of context because of one big file. It is

running out because of accumulation: tool outputs, test logs, build logs,

repeated turns, and the same content pasted again in a slightly different

form. I kept watching sessions die on the tenth retry of the same failing

test — not because any single output was huge, but because nobody ever

threw anything away.

So I built Context Diet: an MCP server (plus a CLI) that shrinks the

content an agent actually sends, deterministically, with receipts. Every

output line is copied verbatim from the input. Every dropped line is

counted and categorized in a manifest. No model, no download, no data

leaves the machine.

Five tools, one promise — nothing invented:

diet_count — lines, bytes, and estimated tokens of a text.diet_dedupe — removes exact duplicate lines and repeated blocks.diet_extract — relevance-ranked excerpts for a query, with context around each hit.diet_summarize — an extractive summary to a token budget. It keeps headings, error and failure lines, and the first and last lines of each section. It never rewrites a word.diet_pack — the full pipeline: dedupe, then extract if you give it a query, then summarize to a budget, plus a manifest for every line. The manifest is the point. A summary that silently rewrites your log is

a liability; a summary that says "kept 23 lines, dropped 54 as

duplicates, 4 in extraction, 88 in summarization" is something you can

diff and trust.

On a real session log (verbose test runs, a README excerpt, a build

output — examples/session.log in the repo), packed to a 400-token

budget with the query test failure:

Lines Bytes Est. tokens
Before 169 7,917 1,942
After 23 1,587 392

Token counts are estimates (a documented chars/4 rule); lines and

bytes are exact. The manifest adds up: 169 = 23 kept + 54 deduped + 4

extracted away + 88 summarized away. Verbatim: true.

From source (the npm package arrives with the first npm publish):

git clone https://github.com/techdevfun/context-diet
cd context-diet
npm install && npm run build
node dist/cli.js pack --input examples/session.log --budget 400 --query "test failure"

As an MCP server over stdio, point your client at

node /path/to/context-diet/dist/server.js. The repo has a demo GIF

recorded from a real terminal session, CI on Node 20 and 22, and a test

suite that runs the server through a real MCP client.

This is a crowded corner, and the honest version is that each rival is

better at something:

Plainly: LLMLingua compresses harder than our typical 2–5x on logs.

mcp-token-optimizer understands code structure and restores formatting;

we treat code as text. Entroly covers whole codebases with a dashboard;

we are one focused pipeline. Vendor tool search fixes tool-schema bloat

at percentages we will never match, because that is not our layer. We

do not have those things in v1, and we do not claim them.

What we have instead is the one thing none of them offer: a

deterministic, auditable diet for session content, where every cut is

accounted for and nothing is invented.

LLM summarization (opt-in), model-based compression, AST-aware code

minification, cross-session cache, dashboard, auto-apply to agent

configs, JUnit/XML parsing, SARIF output, secret redaction.

Repo: https://github.com/techdevfun/context-diet — MIT licensed,

no account, no network, no model calls. If your sessions also die by

accumulation, try it on your own ugliest log and check the manifest.

── more in #ai-agents 4 stories · sorted by recency
── more on @context diet 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/your-agent-isn-t-run…] indexed:0 read:3min 2026-10-25 · —