Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 6 min read

How I Cut Multi-Agent Fixed Prefix Tokens by 94% (50k to 2.7k) Across 5 AI Coding Agents on Windows 11

Mizan is an open-source, zero-dependency, local-first multi-agent control plane and 4-tool stdio SQLite FTS5 MCP hub for Claude Code, Codex, Cursor, OpenCode, and Antigravity. Canonical repository (MIT License, CI Green

How I Cut Multi-Agent Fixed Prefix Tokens by 94% (50k to 2.7k) Across 5 AI Coding Agents on Windows 11

Mizan is an open-source, zero-dependency, local-first multi-agent control plane and 4-tool stdio SQLite FTS5 MCP hub for Claude Code, Codex, Cursor, OpenCode, and Antigravity.

Canonical repository (MIT License, CI Green, 8-page Wiki): https://github.com/csa7mdm/mizan

By Ahmed Mustafa, AI-Native Solutions Architect & R&D Lead.

When I first started working with AI tools, before agentic workflows were even standard, the question was simple: how do I get a model to actually execute real work?

Then agentic tools arrived. Models could edit files, run terminals, drive browsers, and connect to tools through MCPs. Once I began shipping real projects across five different coding agents on Windows 11, a different problem showed up. Agents can do real engineering work, but left unmanaged, they burn tokens fast, drift out of sync, and leave local ports exposed.

Instead of guessing where the tokens were going, I audited my own transcripts.

What the Audit Measured

I ran a read-only audit across 113 real Claude Code sessions on my Windows 11 machine (00-AUDIT-REPORT.md). The biggest leaks had nothing to do with complex code:

  • ~220k tokens average context re-read per API call.
  • 53 sessions crossed 150k tokens and were never compacted.
  • 13.4M characters of raw Bash output were dumped into context and carried forward every turn.
  • Across my 5-agent setup (Antigravity, Claude Code, Codex, OpenCode Free Tier, Cursor Entry Plan), skill folders had grown to 1,247 skills in ~/.agents/skills and 1,265 skills in ~/.codex/skills.

That startup clutter cost 50,644+ estimated fixed prefix tokens per turn before an agent read a single word of my request.

Before vs. After (Measured)

Metric Before Mizan After Mizan Verification Source
Active Skills in Scan Path 1,247 (~/.agents/skills) / 1,265 (~/.codex/skills) 6 to 11 core skills per agent 07-WEEKLY-OS-HEALTH.md
Est. Fixed Prefix Tokens / Turn 50,644+ tokens 278 to 2,986 tokens (~94% reduction) 07-WEEKLY-OS-HEALTH.md
Prefix Alerts (> 15,000 tok) Multiple agents over cap 0 / 5 agents 07-WEEKLY-OS-HEALTH.md
Weekly Skill ROI Audit Cost Manual guesswork 0 LLM tokens (scripts/weekly-health.py) bootstrap.ps1 + Task Scheduler
Local Dashboard Security Default localhost trust 403 DNS Rebinding / 403 CSRF / 401 Auth action-center/server.mjs
Hub MCP Transport & Deps HTTP/SSE or heavy npm stacks stdio only, 0 TCP ports, 0 npm deps hub-mcp/index.mjs

Mizan fixed prefix token reduction (~94%) across 5 AI coding agents on Windows 11

What Broke (and One Thing That Did Not Work)

Three real issues only showed up once I checked the actual files and timings:

  1. Disabling skills in config did not stop startup parsing. I had 1,017 skills turned off in Codex's config.toml using [[skills.config]] enabled = false (a 124 KB / 4,502-line config file). Codex still scanned and parsed those skill folders on startup. Moving unused skills completely outside the scan path was the only fix that actually worked.
  2. PowerShell 5.1 hook wrappers added latency on every tool call. Four Antigravity hooks were each spawning powershell.exe -NoProfile just to call a .cmd script, adding 150 to 400 ms per tool call. Calling the .cmd script directly dropped measured hook overhead from 3.5 s to 1.0 s.
  3. One rulebook does not fit every quota tier. Syncing the full rule set into Cursor Entry Plan burned its tight quota too fast. Mizan now syncs a strict <= 30-line thin rule for Cursor (278 prefix tokens) while keeping the full Single Source of Truth in ~/.claude/brain for the rest of the fleet.

Measured 5-Agent Prefix Budget

This table comes directly from Mizan's latest weekly health report (07-WEEKLY-OS-HEALTH.md):

Agent Quota State Active Skills Est. Prefix Tokens Status
Antigravity (agy) green 6 2,783 OK
Claude Code green 10 1,806 OK
Codex CLI / App green 11 2,986 OK
OpenCode (Free Tier) green 0 2,578 OK
Cursor (Entry Plan) yellow-conserve 0 278 OK

Mizan local-first 5-agent control plane architecture diagram

Architecture: Four Lean Pieces

  1. Single Source of Truth (~/.claude/brain): One canonical rule set and a capped 30-entry LESSONS.md synced across all 5 agents with per-agent identity headers.
  2. Zero-Token Weekly Kaizen Audit (scripts/weekly-health.py): A Windows Scheduled Task (BrainV2-WeeklyHealthAudit, Sundays 09:00) streams .jsonl transcripts line-by-line with 0 LLM tokens. Over 455 Claude sessions in 30 days, real Skill ROI surfaced clearly: learn (44x), browser-lean (38x), checkpoint (18x), my-voice (16x), quiet-run (6x), skill-catalog (2x), archify (1x), while zero-use skills (dotnet, powershell-windows, synced) are flagged as archival candidates. It also probes free-tier OpenCode models and local Ollama models (6 live).
  3. 4-Tool stdio Hub MCP Server (hub-mcp/index.mjs): Built on Node 24's built-in node:sqlite (FTS5 with BM25 ranking) with zero external npm dependencies and zero open TCP ports. Exposes strictly 4 tools: brain_search_lessons, brain_search_components, brain_get_ops_state, and brain_log_decision.
  4. Zero-AI Bootstrapper (bootstrap.ps1): A PowerShell 5.1-safe script that installs prerequisites via winget, syncs all 5 agent configs, registers the weekly audit task, and runs diagnostics on a fresh Windows 11 machine without spending a single token.

Mizan 30-day Skill ROI across 455 Claude sessions at 0 LLM tokens

Threat Model: Why Localhost Is Not Trusted

Local agent dashboards have shell and workspace authority. Mizan's zero-dependency Node 24 Action Center (action-center/server.mjs) binds to 127.0.0.1:4321 by default and enforces:

  • DNS Rebinding protection (403): Strict Host allowlist (127.0.0.1, localhost, ::1, Tailscale CGNAT 100.64.0.0/10, *.ts.net).
  • CSRF protection (403): Strict Origin allowlist plus X-Frame-Options: DENY and X-Content-Type-Options: nosniff.
  • Mandatory API auth (401): Every /api/* route requires a 48-char hex Bearer or x-brain-token verified with crypto.timingSafeEqual against a gitignored ops/.ac-token file.
  • Opt-in Mobile Control: Setting BRAIN_AC_TAILSCALE=1 enables remote mobile access over Tailscale WireGuard E2EE while keeping the exact same Host/Origin allowlist and timing-safe Bearer token enforced.

Mizan live dark-mode Action Center demo

The Limits

  • Windows 11 first: bootstrap.ps1 and the Task Scheduler setup target Windows 11 (PowerShell 5.1-safe). The Node 24 Action Center and hub-mcp run cross-platform, but full setup automation is Windows-tested.
  • Node 24 required: hub-mcp/index.mjs relies on Node 24's built-in node:sqlite module to stay zero-dependency. Older Node versions will not run it.
  • No container sandbox: Mizan orchestrates your local agents and allowlisted scripts with your local user permissions. If you work on untrusted codebases, run agents inside a container or VM.
  • Estimates vs. exact tokenizer counts: Prefix token budgets in weekly-health.py are deterministic byte-based estimates meant to catch bloat trends (threshold > 15,000 tokens), not billing-grade tokenizer counts.

Frequently Asked Questions (FAQ)

How do I manage Claude Code, Cursor, and Codex together without burning tokens?

Keep one canonical rule set synced to all agents, archive unused skills completely out of each tool's scan directory (do not just disable them in config), give quota-capped tools like Cursor a <= 30-line thin rule, and hand off to a fresh thread via HANDOFF.md around 120k to 150k context tokens.

How do I prevent DNS rebinding and CSRF on local MCP servers and agent dashboards?

For local MCP servers, use stdio transport so no TCP port is opened at all. For local HTTP dashboards, reject any Host or Origin outside an explicit localhost/Tailscale allowlist with 403, and require a local token verified with crypto.timingSafeEqual (401 on failure) on every /api/* endpoint.

Does Mizan require external npm packages or cloud services?

No. Both action-center/server.mjs and hub-mcp/index.mjs run on built-in Node 24 modules (node:http, node:crypto, node:sqlite, node:fs, node:readline) with zero external npm dependencies and zero cloud telemetry.

How does the Weekly Skill ROI Audit work without using LLM tokens?

scripts/weekly-health.py runs via Windows Task Scheduler every Sunday at 09:00, streaming local .jsonl session transcripts line-by-line in Python to count actual skill invocations against byte size, check active model health, and write 07-WEEKLY-OS-HEALTH.md at 0 LLM tokens.

Source code, CI checks (Gitleaks + Node 24 MCP selftest + Venture Triad smoke test), and the 8-page architecture wiki:
https://github.com/csa7mdm/mizan

If you run it on your own multi-agent setup, open an issue with what broke or what it missed. The misses are how the next fixes happen.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.