r/LLMDevs • u/legend-of-alan • 5h ago
Tools Sharing my free, drop-in Code Mode to cut ~60% of Your Rust Agent’s Token Cost
guthub.com‼️MODERATORS‼️ Really sorry--I misspelled 'github' in the post url (can a mod please change this?!). Real url is https://github.com/legend-of-alan/ghostmode
Hey all, I'm trying to share this across a few places and hopefully my free tool saves you some money if you're building an AI agent or harness in Rust!
TLDR; Code Mode is a feature that Anthropic announced a few days ago that can save >60% of token costs for agent tool calls. Since token cost dominates agentic software, I built a Rust tool called Ghost Mode to open source this technique (and also because it's fun to build stuff!). You can find it at the link above! It's a drop-in for your existing MCP servers/clients with minimal boilerplate.
Details;
So I don’t know if you saw the news from Anthropic, but they released this feature called ‘Code Mode’ for Claude Code. Basically it ‘batches’ LLM tool calls into scripts instead of constantly asking the LLM for the next tool. They claimed 95% token savings (Haven't benchmarked it myself yet, but independent research claim more like a 60% savings, depending on workload). Up to now, this seems mostly used by bigger coding agent products like Claude Code and Codex.
I immediately became obsessed, because I wanted it to run AI-powered RPG games & private servers on an engine I’m building. So I took a look around, and there’s not much in Rust. There’s a few libraries like with TypeScript and other backends, but they’re like 5x slower (execution) to 100x slower (startup) compared to the (admittedly self-reported) claims of modern options like Pydantic’s Monty (Python backend written on Rust).
So I went temporarily insane, didn’t sleep, and built/released my own in the days I had off… I call it Ghost Mode. It’s MIT-licensed, because I wanted to share it with others. To use it, just run:
“cargo add ghostmode”
Give it a try if you’re looking to save tokens in your new Rust agents (or if you just want to flatter me by testing it). If anybody tries it and likes it, I think we can build a really powerful Code Mode implementation together (extend it for other languages, add new features, etc.).
I hope you get something useful out of it.
And if you get nothing out of this, just keep an eye for code mode in your code harnesses soon!