Code mode yields a 99.2% cost reduction in our systems

tarasyarema 61 points 67 comments July 23, 2026
www.agent-swarm.dev · View on Hacker News

Discussion Highlights (18 comments)

tarasyarema

Hi there! We've been building https://github.com/desplega-ai/agent-swarm in the open for a while, and one of the things we wanted to do since the start is find how powerful it can be to push for a code mode like env for the swarm. We tried it and we managed to reduce up +90% of token costs by using swarm scripts (the code mode variant we implemented) for some of our schedules. This is game changer, as we are able to 1. Run those schedules faster 2. Cheaper 3. More reliably Been thinking a lot now on how we should prompt and change the default templates to force the agents to build on top of this. If it can be re-used or it's a recurring thing -> scripts. Thoughts? Have you seen this type of improvements in your setups? Cheers,

somnium_sn

I am still a bit surprised that this is not more widely used. Normal inference + tool calls is effectively composition via serialized natural language, whereas Code Mode / Programmatic Tool Calling is using purpose built languages (aka programming languages) for composition and concurrency. It somewhat feels obvious to me that the latter is way more token and latency efficient.

shireboy

A maxim I’ve arrived at working w llm every day is “put deterministic things in code, non deterministic in llm”. I do wish the harnesses would be more helpful in this regard. For example I’ve seen tons of scheduled jobs that people wrote in Claude/copilot/etc that could easily have been scripts. They aren’t scripts because the author doesn’t know how to script and they stop at the point the llm does what they want. It isn’t hard to then tell the llm “make a script to do all of the tool calls this prompt needs and then pass the result back to the llm for this non-deterministic part”.

fg137

The article is so painful to read.

vessenes

This quarter’s clankerisms: “Honest” and “vibes”. The tech here is cool; good reminder to push for more scripts in general from the agentic tools.

AmazingTurtle

codex CLI is already leveraging this internally. instead of performing raw MCP calls its internally using a js REPL to do that. elicitation is then propagated for approvals independently / it's interpreted as regular tool calls for operators etc. so if i were to tell an agent to move the contents of a confluence doc into a file, it would do so without even reading the confluence page - in theory.

grzracz

I am once again asking for people to ask Claude to reformat their article text to ASD-STE100 so that I don't have to read slop

firasd

The problem is that when the LLM writes ad-hoc code how can you trust it? For example in my Liveclip MCP server I'm working on (not released yet) I have table manipulation type tools So for example a couple days ago Claude made a combined ranking score for my Youtube Shorts analytics -- it did all these tool calls in the same turn First it normalized the % values into numbers { "destination_col": "G", "key": "cinemasleepstories_temp_2026071702", "pattern": "%", "replacement": "", "source": { "col": "E", "row_start": 1, "row_end": 6 } } Then it made the composite score { "dest_col_start": "H", "dest_row_end": 6, "dest_row_start": 1, "expr": "round((likes+1) (followers+1) stayed, 1)", "source_key": "cinemasleepstories_temp_2026071702", "sources": [ { "col": "C", "name": "likes", "row_offset": 0 }, { "col": "D", "name": "followers", "row_offset": 0 }, { "col": "G", "name": "stayed", "row_offset": 0 } ] } And then it set the new headers { "headers": { "G": "Stayed (numeric)", "H": "Composite Score" }, "key": "cinemasleepstories_temp_2026071702" } If Claude just said "let me write some pandas against this CSV" the workflow would be a lot more iffy and generally uncomfortable/ephemeral

ramon156

LLM-assisted websites yield a 99.2% trust reduction in me

vanyaland

you lose the per-call approvals though. one script hitting ten tools is harder to gate than ten separate calls

Planktonne

I could be misreading this, but looking at the numbers, it seems that--despite the claim "we didn't estimate this"--basically everything in this is an estimate. It's a little hard to tell though, because the generated prose seems to occasionally contradict or repeat itself.

Krishnaswaroop

Token savings are great, but I wonder whether the biggest long-term benefit is latency reduction rather then API cost,Faster feedback loops can easily outweigh a few cents saved per request

lherron

Cool but isn’t everyone already doing this? Surprised this is what I saw at top of HN this morning.

jonathanlydall

We ultimately switched to this approach with great success for our own product. We stumbled on its success a little by chance. We have a visual designer and for LLMs to interact with it we originally built a tool per manipulation operation type (e.g. add, edit, delete item - for various item types). We actually already had a JavaScript API with corresponding .d.ts file for scripting inside our product and one of our clients asked that we also expose this as an MCP tool. I figured sure, should be quite quick and easy, and with Claude Code's help I managed to do it in a single afternoon. We then found that the LLMs way preferred reaching for this tool, managing with it to get their tasks done with fewer mistakes along the way and in much smaller time frames. After seeing this and doing some more validation (I've also read that Cloudflare article), we ditched the other tools completely and made a cheat sheet for the LLMs on how to use our API. Because our API returns decent error messages including stack traces, even if the script fails the LLMs have no trouble making another script to fix their mistake and carrying on from where the error occurred. In hindsight it really was hardly surprising as LLMs are already aiming to be as good as possible at coding and with JS being so popular I imagine it's particularly good at it.

gmerc

Could have been a one paragraph prompt and csv. Had to be a few pages worth of sloppy slop.

peterbell_nyc

Yeah, this has been my biggest contention with the models everywhere paradigm. I will definitely use a supervisor pattern and advisor pattern for simpler models when I just want to throw something together interactively with Fable and a few sub-agents. But for anything I am doing repeatedly, I built a deterministic orchestrator to run the steps and I have a hard rule that the skills that run from my repo can only ever be a thin shims calling to my central system so that rather than having agents enrich a person or call an API or do research they fire off predefined multi-step deterministic plays that just might have models for classification generation summarization and/or review. In addition to the reliability and cost benefits you also then get shared capacity broker capabilities so if you're only able to enrich so many people or only capable of doing so many CI runs if that's all done deterministically you can have some intelligent orchestration in your main server to manage that limited capacity across all your agents that are trying to use it at the same time.

sourcecodeplz

Codex did this for me by itself when i asked it for some daily automations. it just wrote scripts.. scripts are coming back

josefritzishere

I think ECREE applies. "Extraordinary claims require extraordinary evidence" Nothing is 99% effective. This reads like a marketing piece.

Semantic search powered by Rivestack pgvector
14,736 stories · 137,719 chunks indexed