Code mode yields a 99.2% cost reduction in our systems

agent-swarm.dev
July 23, 2026
10 min read
🔥🔥🔥🔥🔥
45/100
Summary
Using a sandbox and a generated API for code execution reduces the cost of a task from 150,000 tokens to 2,000 tokens, achieving a 98.7% reduction in resource usage. This method prioritizes script execution over multiple tool calls, significantly decreasing both time and expense.
Key Takeaways
- Using a script for automation tasks resulted in a 99.2% reduction in the amount of data reaching the agent's context compared to making 26 individual tool calls.
- The cost of executing the script was approximately $0.02, while the estimated cost of using raw sequential calls was around $2.44.
- The wall-clock time for the script execution was measured at 13.12 seconds, compared to an estimated 2 to 6.5 minutes for the raw sequential calls.
- The script processed 26 calls internally and returned a single summary object, significantly improving efficiency in data handling.
Coverage & discussions
Hacker News · agent-swarm.dev
Community discussions
Community Sentiment
Positives
- Code Mode is a game changer for efficiency — moving from standard inference to programmatic tool calling is a no-brainer for cutting latency and costs.
- Seeing a 99.2% cost reduction is huge! That’s a massive win for anyone looking to optimize their AI systems.
- The idea of using purpose-built languages for composition feels so right; it’s about time we leverage programming languages instead of just LLMs for everything.
Concerns
- There's skepticism about the claims made in the article — many feel the cost reduction numbers seem more like estimates than solid data.
- Using LLMs to write scripts raises trust issues; how can we rely on generated code that might not perform as expected?
- Some commenters think this isn't revolutionary at all; it's just common sense to let LLMs write scripts rather than treating them as magic.



