cd /news/ai-agents/show-hn-open-sourced-code-mode-to-cu… · home › topics › ai-agents › article
[ARTICLE · art-177252] src=github.com ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Show HN: Open-Sourced Code Mode to Cut ~60% of My Rust Agent's Token Burn

A developer released Ghost Mode, an MIT-licensed open-source Rust tool that brings "code mode" batching to AI agents, letting a model write a short script against its tools instead of returning tool-call results one at a time. The developer, building an AI RPG engine called Spookery, said the tool is a drop-in for agents already making traditional tool calls and takes about 20 lines of setup to convert an agent to code mode. The release follows Anthropic's experimental code mode for Claude Code, which Anthropic claimed cut token use by 95% on some workloads, while independent studies cited by the developer put savings closer to 60-70%.

key takeaway

Ghost Mode lets an agent batch tool calls by writing a short script against its tools, a drop-in change of about 20 lines that the developer says can cut token burn by roughly 60-70% based on independent studies.

read2 min views8 publishedNov 27, 2026

For those who are tracking, Anthropic released an announcement last week about their experimental code mode for Claude Code, claiming some bonkers token savings when it comes to tool calls (95% on some workloads(1)). I haven't benchmarked it myself, but independent studies come in somewhere closer to 60~70% savings (2), but I digress. TLDR; I built an open-source version for the community. Context: I'm writing an AI RPG engine called Spookery, and I immediately wanted to try this technique for myself when I heard of it. Agent deployment is currently dominated by token costs, especially during tool calling (single prompt generating tens or hundreds of tool calls). Unfortunately, it looks like the only ones who are doing this seriously are big agentic products like Claude Code and Codex. So, I thought it'd be fun to try it myself and bring it to you all!

The idea of Code Mode is simple but powerful. Instead of passing back tool call results back to the LLM one at a time, let the LLM batch calls by letting it write a short script using your tools. Basically taking 30 trips to the grocery store for 30 items and turning it into one trip to the store with a list in-hand.

There's a few near-ish open-source options, but they used TypeScript backends, we're a little boilerplate heavy, and I wanted to have something a little faster and Rust friendly for my game engine. Pydantic's Monty seemed a good candidate--their self-reports are around 5x faster on execution and 100x faster on startup (3). I wouldn't take the numbers to the bank, but it's written on a Rust framework and the python backend is entirely built from Rust too.

Anyway, I had a couple of days off unexpectedly. So, I went temporarily insane and built a Rust tool to bring code mode to the greater community for free. In enough days to fit on one hand (and just as many hours of sleep), I came up with the implementation linked. I call it Ghost Mode. It's MIT licensed. It's a drop-in for your agent that already makes traditional tool calls. With ~20 lines of setup, you can convert your existing agent to a Code Mode agent.

I hope you get something out of this, and maybe I can save you some money. Considering how limiting token economics are right now, I think this could be a game changer for the industry. If there's interest, I can imagine we can build also add some great new features, language compatibility, and other great things. Thanks for reading :)

Sources:

(1) [https://www.marktechpost.com/2026/11/17/anthropic-claude-cod...](https://www.marktechpost.com/2026/11/17/anthropic-claude-code-code-mode-javascript-tool-calls/)
(2) [https://arxiv.org/abs/2611.19123](https://arxiv.org/abs/2611.19123)
(3) [https://pydantic.dev/docs/monty/get-started/](https://pydantic.dev/docs/monty/get-started/)

Comments URL: [https://news.ycombinator.com/item?id=50665796](https://news.ycombinator.com/item?id=50665796)

Points: 1

── more in #ai-agents 4 stories · sorted by recency
── more on @ghost mode 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/show-hn-open-sourced…] indexed:0 read:2min 2026-11-27 · —