Skip to content
Effloow
← Back to Articles
AI DEVELOPMENT ARTICLES ·2026-07-15 ·BY EFFLOOW EDITORIAL ·8 MIN READ

GPT-5.6 Programmatic Tool Calling: When It Cuts the Token Bill

We ran GPT-5.6's programmatic tool calling on a real API. On one task it cut tokens 92%. On another it cost 2.2x more. Here's the rule that decides which.
gpt-5-6 programmatic-tool-calling token-cost ai-finops agent-tools openai
SHARE
Illustration for GPT-5.6 Programmatic Tool Calling: When It Cuts the Token Bill
Illustration: AI-assisted. Editorial policy

Picture an assistant that answers a plain business question: "How much did we refund last week?" To answer, it calls a tool that pulls your order records, keeps the refunded ones, and adds up the amounts. The answer is a single number. But to get there, most AI assistants haul the whole pile of records back through the model, line by line, so the model can do the filtering and the arithmetic in its head.

You pay for that pile. Every record that passes through the model's reading window is billed, whether or not it shapes the final answer. One lookup is a rounding error. An agent doing this hundreds of times a day, across support tickets, billing checks, and CRM reads, turns it into a real line on the invoice.

OpenAI's newest model family, GPT-5.6, ships a feature aimed at exactly that waste. It's called programmatic tool calling. The pitch is simple: instead of reading every tool result itself, the model writes a small program that runs your tools, filters the data, and does the math off to the side, then hands the model only the finished answer.

Does it actually save money? We ran it on the live API to find out. Sometimes it saves a lot. Sometimes it costs more. The interesting part is the rule that decides which, and it comes down to one thing you can check before you commit.

What GPT-5.6 changed

On 2026-07-09 OpenAI released GPT-5.6 as three tiers you pick by cost and horsepower: Sol (the top model), Terra (the balanced one), and Luna (the cheap, high-volume one). The plain name gpt-5.6 routes to Sol. All three are available through OpenAI's API.

The feature we're testing, programmatic tool calling, works like this in everyday terms. Normally the model asks your app for a tool result, you send it back, and the model reads it. With programmatic tool calling, the model instead writes a short piece of JavaScript that runs in a locked-down sandbox (no internet, no files, nothing saved between runs). That code calls your tools, sifts the results right there, and returns only the final number to the model. The bulky middle step never enters the part you pay for.

There's a second new trick worth naming so you can tell them apart: multi-agent orchestration, a beta feature that spins up several helper agents in parallel and merges their work into one answer. That's a different lever (more parallel effort for a stronger result), and we did not measure it here. This article is only about the token economics of programmatic tool calling.

What we built and ran

We wrote a small test that gives GPT-5.6 the same job twice: once with classic tool calling (the model reads every result) and once with programmatic tool calling (the model writes code that does the reading). Then we counted the real tokens the API reported for each. Everything is synthetic and deterministic. No customer data, no secrets, and a fixed correct answer so we can confirm the model got it right.

We used Luna, the cheapest tier, and ran two versions of the job that differ in one way only: how big each tool result is.

  • Small results. A tool returns a single number. The model calls it for eight items and adds them up. Each result is a few tokens.
  • Big results. A tool returns 40 order rows per call (customer, region, amount, a refunded flag, and so on). The model calls it for eight days, keeps the refunded rows, and totals them. That's 320 rows in play. In classic mode all 320 get dragged through the model; in programmatic mode they stay in the sandbox.

Both jobs have a fixed right answer (204 for the small one, 52,584 for the big one), so we can check correctness, not just cost.

What actually happened

Both approaches got both answers right. The cost is where they split apart, and they split in opposite directions depending on how big the tool results were.

When tool results were tiny, programmatic tool calling cost more, not less.

Small tool results Classic tool calling Programmatic tool calling Change
Total tokens (what you pay) 645 1,392 about 2.2x more (+116%)
Model output tokens 155 91 41% fewer
Answer 204 204 both correct

Writing the little program isn't free. The model spends tokens composing the JavaScript, and for a job this small that overhead swamps any saving. Programmatic tool calling used more than double the tokens (1,392 versus 645) to reach the same answer.

When tool results were big, programmatic tool calling was dramatically cheaper.

Big tool results (320 rows) Classic tool calling Programmatic tool calling Change
Total tokens (what you pay) 19,491 1,496 about 92% fewer (13x fewer)
Model output tokens 252 126 50% fewer
Answer 52,584 52,584 both correct

Here the classic approach paid to shuttle all 320 order rows through the model: 19,491 tokens. The programmatic approach kept those rows in the sandbox, filtered and summed them there, and returned only the total: 1,496 tokens. That's roughly a 92% cut (about 13 times fewer tokens) for the identical, correct answer.

So the feature is not a free discount you flip on everywhere. The deciding factor is how much data your tools hand back. Big, messy tool outputs that only need a small slice of the answer? Programmatic tool calling pays off, and it can pay off enormously. Tiny outputs, or a couple of quick calls? The overhead of writing the program can make it more expensive.

One detail is easy to misread. In both jobs the programmatic runs took more back-and-forth trips to our app, nine versus two. Our tools live in our own code, so the sandbox has to pause and ask our app to run each call. The savings don't come from cutting those trips. They come from keeping the results of those trips out of the model's reading window. Move your tools to OpenAI's side (hosted or MCP tools) and even those pauses go away.

Can this survive your workflow?

Here's how to translate the result into your own service. Ask one question: when your agent calls a tool, does it get back a lot of data it mostly throws away?

  • Order and refund processing. An agent pulls a batch of orders and totals a subset (refunds, chargebacks, a region). Classic calling pays for every row. This is the big-win case, like our 92% cut.
  • Support ticket triage. If a tool returns full ticket histories and the agent needs one status or one count, the history is the expensive pile that never needs to reach the model.
  • CRM and billing reads. Pulling a customer's full record to answer a yes/no or a single figure is the same shape: big input, small answer.
  • Internal reporting and reconciliation. Summing, counting, or matching across many rows is exactly what a sandbox program does cheaply.

And the cases where it won't help, so you don't over-adopt it:

  • A couple of small lookups. Two or three calls that each return a short value. The program-writing overhead can cost more than it saves, as our small-results run showed.
  • The model needs to read everything anyway. If the task genuinely requires reasoning over the full tool output (summarizing every ticket, not counting them), keeping the data out of context defeats the point.

The honest takeaway for a budget owner: programmatic tool calling is a targeted tool for data-heavy agent steps, not a global setting. On the right step it can cut the model bill by an order of magnitude. On the wrong step it quietly adds cost. The way to know is to measure your own tool outputs, which is exactly the kind of bounded check we run.

If you're weighing this for a live service and want an inspectable, claim-bound proof on your own workload before you commit engineering time, that's what Effloow's Proof Studio produces. For scoping a build, see our services. We publish the method and the raw numbers every time, the same way we did here.

Limitations, in plain words

This is a bounded lab check, not a benchmark. We ran two synthetic tasks, once each per mode, on one model tier (Luna). Real numbers will move with the size of your tool outputs, how the model chooses to write its program, the reasoning effort you set, and whether your tools run on your side or OpenAI's. We did not measure price in dollars, speed, or the separate multi-agent beta. What we can stand behind: on these two deterministic tasks, on the live GPT-5.6 API, the direction and rough size of the effect were clear and reproducible with the script below.

What Effloow added

The primary sources tell you the feature exists and how to wire it up. They don't tell you when it's worth it. Our original contribution is the measured decision rule: a two-scenario, same-task comparison on the real GPT-5.6 API showing the effect flips sign with tool-output size (about 92% cheaper on big outputs, about 2.2x more expensive on tiny ones), with both answers verified correct. The full run, the exact counts, and the reproduction command are in our public lab note. This pairs with our earlier Claude programmatic tool calling token proof for a cross-model view, and sits alongside our OpenAI prompt-cache retention cost proof and OpenAI Agents SDK tool-failure recovery proof as part of a growing set of evidence-led agent-cost write-ups.

For your engineers

Model and runtime: gpt-5.6-luna via the OpenAI Responses API (POST /v1/responses). GPT-5.6 exposes gpt-5.6-sol, gpt-5.6-terra, and gpt-5.6-luna; the gpt-5.6 alias routes to Sol.

Enabling programmatic tool calling:

  • Add the hosted tool {"type": "programmatic_tool_calling"} to the tools array.
  • On each function the program may call, set allowed_callers: ["programmatic"] (values are ["direct"], ["programmatic"], or both) and provide an output_schema.
  • Handle the new output items: a program item (generated JavaScript code, a call_id, and a fingerprint), program-issued function_call items whose caller field references the program's call_id, and a program_output item with the matching call_id, a result JSON string, and a status. Preserve every call_id and the caller linkage when you return function_call_output items.
  • Sandbox constraints per OpenAI's guide: V8 runtime with top-level await, but no Node.js, no package install, no network, no general filesystem, no subprocess, no console, and no persistent state between program runs. Programs reach the outside world only through the tools you enable.

Measured results on this run (real API usage counters):

  • Tiny outputs: classic 2 model round-trips, 645 total tokens, 155 output tokens; programmatic 9 round-trips, 1,392 total tokens, 91 output tokens. Answer 204 in both.
  • Bulky outputs (320 rows): classic 2 round-trips, 19,491 total tokens, 252 output tokens; programmatic 9 round-trips, 1,496 total tokens, 126 output tokens. Answer 52,584 in both.

Why programmatic showed more round-trips: our tools are client-side, so the hosted program pauses for our app to execute each get_* call. Savings come from keeping tool outputs out of model context, not from reducing app round-trips; hosted or MCP tools would remove the pauses.

Reproduce: run python3 scripts/gpt56-ptc-token-proof.py. It drives both scenarios in both modes, checks the budget guard before each call (scripts/proof_budget.py, ledger in data/state/openai-token-usage.json), records real per-turn usage, and writes the artifact to data/lab-runs/gpt-5-6-programmatic-tool-calling-multiagent-token-proof-2026.openai.json. Full notes and the raw counters are in the public lab note.

Primary sources: OpenAI Programmatic Tool Calling guide, OpenAI model-guidance (latest-model) doc, OpenAI's GPT-5.6 Sol announcement, and the OpenAI Responses multi-agent guide.

Get the next one
in your inbox.

One short weekly dispatch with new guides, tools, and what we tested. No spam, unsubscribe anytime.

Get weekly AI tool reviews & automation tips

Join our newsletter. No spam, unsubscribe anytime.

More in Articles

Tools you can use