cd /news/large-language-models/code-mode-can-help-smaller-llm-model… · home topics large-language-models article
[ARTICLE · art-73155] src=instavm.io ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Code mode can help smaller LLM models

Code mode, which prompts LLMs to generate executable code instead of structured tool-call signatures, can help smaller models perform tool calling more reliably without additional training, according to a developer analysis. Anthropic uses the approach to reduce token spend, and Cloudflare introduced the concept when models struggled with tool-call formatting. The method requires ephemeral sandbox execution for safety, with providers like the author's spinning up in under 200ms.

read2 min views1 publishedJul 25, 2026
Code mode can help smaller LLM models
Image: source

It's been clear that LLMs alone are not as powerful as "LLMs with tools".

How does LLM call tools? #

It can generate a signature of the tool call, somewhat like a function call search_web("query")

or bash("ls -l") etc. This usually calls a function written to either call the google API, exa, or execute a bash command locally.

This is kind of fine as long as tool calls are properly formatted — some slightly less powerful models often make mistakes in generating those signatures. The training was so tedious that lot of models were released without the "tool calling" ability.

We had to include training data involving special tokens, for example - |tool_call|

.

How to fix it? #

We learned that the same less powerful models are still very good at generating code, since they are already trained on them. If we ask the LLM to generate say a python/typescript code which eventually calls the search API, bash etc then that has higher chances of success - especially when multiple tool calls are involved.

One Issue #

Now we will need to execute code all the time, with this comes the risk of executing malformed code (still happens with lower probibility) — to execute each code we spin-up an ephemeral linux machine & execute the code there.

There is not much overhead as most of the ephemeral sandbox providers spin-up under 200ms (including us) & you can just assume it will not be a noticeable delay.

How is it used so far? #

Anthropic uses it to reduce token spends by a lot. See Programmatic Tool Calling. The code mode concept was probably introduced by Cloudfare first when models weren't as good in writing tool calls. Today, both arguments make sense - double benefit.

How does it relate to smaller models #

Microsoft recently said to use specially trained models for specific tasks — now they haven't said anything about code mode but my hunch is that code mode will certainly help if you don't want additional training to make the model learn tool calling. Along with helping you reduce the token count like always.

── more in #large-language-models 4 stories · sorted by recency
── more on @anthropic 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/code-mode-can-help-s…] indexed:0 read:2min 2026-07-25 ·