{"slug": "your-agent-isn-t-running-out-of-context-because-of-one-big-file", "title": "Your agent isn't running out of context because of one big file", "summary": "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.", "body_md": "Your agent isn't running out of context because of one big file. It is\n\nrunning out because of accumulation: tool outputs, test logs, build logs,\n\nrepeated turns, and the same content pasted again in a slightly different\n\nform. I kept watching sessions die on the tenth retry of the same failing\n\ntest — not because any single output was huge, but because nobody ever\n\nthrew anything away.\n\nSo I built Context Diet: an MCP server (plus a CLI) that shrinks the\n\ncontent an agent actually sends, deterministically, with receipts. Every\n\noutput line is copied verbatim from the input. Every dropped line is\n\ncounted and categorized in a manifest. No model, no download, no data\n\nleaves the machine.\n\nFive tools, one promise — nothing invented:\n\n`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\naround each hit.`diet_summarize` — an extractive summary to a token budget. It keeps\nheadings, error and failure lines, and the first and last lines of\neach section. It never rewrites a word.`diet_pack` — the full pipeline: dedupe, then extract if you give it\na query, then summarize to a budget, plus a manifest for every line.\nThe manifest is the point. A summary that silently rewrites your log is\n\na liability; a summary that says \"kept 23 lines, dropped 54 as\n\nduplicates, 4 in extraction, 88 in summarization\" is something you can\n\ndiff and trust.\n\nOn a real session log (verbose test runs, a README excerpt, a build\n\noutput — `examples/session.log` in the repo), packed to a 400-token\n\nbudget with the query `test failure`:\n\n|  | Lines | Bytes | Est. tokens | \n|---|---|---|---|\n| Before | 169 | 7,917 | 1,942 | \n| After | 23 | 1,587 | 392 | \n\nToken counts are estimates (a documented chars/4 rule); lines and\n\nbytes are exact. The manifest adds up: 169 = 23 kept + 54 deduped + 4\n\nextracted away + 88 summarized away. Verbatim: true.\n\nFrom source (the npm package arrives with the first npm publish):\n\n```\ngit clone https://github.com/techdevfun/context-diet\ncd context-diet\nnpm install && npm run build\nnode dist/cli.js pack --input examples/session.log --budget 400 --query \"test failure\"\n```\n\nAs an MCP server over stdio, point your client at\n\n`node /path/to/context-diet/dist/server.js`. The repo has a demo GIF\n\nrecorded from a real terminal session, CI on Node 20 and 22, and a test\n\nsuite that runs the server through a real MCP client.\n\nThis is a crowded corner, and the honest version is that each rival is\n\nbetter at something:\n\nPlainly: LLMLingua compresses harder than our typical 2–5x on logs.\n\nmcp-token-optimizer understands code structure and restores formatting;\n\nwe treat code as text. Entroly covers whole codebases with a dashboard;\n\nwe are one focused pipeline. Vendor tool search fixes tool-schema bloat\n\nat percentages we will never match, because that is not our layer. We\n\ndo not have those things in v1, and we do not claim them.\n\nWhat we have instead is the one thing none of them offer: a\n\ndeterministic, auditable diet for session content, where every cut is\n\naccounted for and nothing is invented.\n\nLLM summarization (opt-in), model-based compression, AST-aware code\n\nminification, cross-session cache, dashboard, auto-apply to agent\n\nconfigs, JUnit/XML parsing, SARIF output, secret redaction.\n\nRepo: [https://github.com/techdevfun/context-diet](https://github.com/techdevfun/context-diet) — MIT licensed,\n\nno account, no network, no model calls. If your sessions also die by\n\naccumulation, try it on your own ugliest log and check the manifest.", "url": "https://wpnews.pro/news/your-agent-isn-t-running-out-of-context-because-of-one-big-file", "canonical_source": "https://dev.to/techdevfun/your-agent-isnt-running-out-of-context-because-of-one-big-file-20bb", "published_at": "2026-10-25 12:07:37+00:00", "updated_at": "2026-10-25 12:13:04.756708+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "agent-protocols", "developer-tools", "large-language-models"], "entities": ["Context Diet", "GitHub", "LLMLingua", "mcp-token-optimizer", "Entroly", "Node.js", "techdevfun"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/your-agent-isn-t-running-out-of-context-because-of-one-big-file", "markdown": "https://wpnews.pro/news/your-agent-isn-t-running-out-of-context-because-of-one-big-file.md", "text": "https://wpnews.pro/news/your-agent-isn-t-running-out-of-context-because-of-one-big-file.txt", "jsonld": "https://wpnews.pro/news/your-agent-isn-t-running-out-of-context-because-of-one-big-file.jsonld"}}