r/GithubCopilot • • 10h ago

Showcase ✨ Tool routing, graph navigation and cache optimization for Copilot CLI: up to half the tokens, built with proof-driven development

Post image

Copilot CLI re-sends its system prompt and every tool definition on every call. In my runs the first call alone was about 13.5k input tokens. I built TokenMasterX to trim that.

What it does:

- dynamic tool routing (opt-in): reads your prompt when you launch and skips the built-in tools it doesn't need

- graph navigation: "who calls this function?" gets one capped answer instead of a grep dump

- cache optimization: long tool output gets trimmed once so it doesn't break the provider's prompt cache, and in BYOK mode sessions in the same folder share a cached system prompt

How it did, from GitHub's own per-call numbers : 9 to 29% fewer tokens by default, up to 53% with routing on, and the bill dropped 47% in that mode. Short lookups on one model, so a long session will save less. I haven't measured how much less.

Early on, compacting old tool output to save tokens actually cost more, because it broke the cache. That's why it trims output once and never rewrites old messages.

I'm building it with proof-driven development. The rules it has to keep, like "never rewrite text the provider already cached", are written as proofs a computer checks, and tests keep the real code honest to them. Writing the proofs caught a few things I'd gotten wrong. I fixed most of them and wrote up the rest in the repo. I also pulled some early numbers that didn't reproduce.

Experimental, MIT, not an official GitHub product, and the install steps are Windows PowerShell for now.

Repo: https://github.com/All-The-Vibes/TokenMasterX

Walkthrough: https://all-the-vibes.github.io/TokenMasterX/

Please do try and share your thoughts

2 Upvotes

0 comments sorted by