# Factory Made Agents Write Code to Call Tools. It Cut Costs 15%

> Factory made programmatic tool calling the default in Droid 1.0, so agents write code to call tools. What the 15% cost cut means for your own agents.

- Canonical: https://zeroraised.com/blog/factory-droid-programmatic-tool-calling
- Published: 2026-11-02T09:26:40Z
- Author: ZeroRaised Team (https://zeroraised.com/blog/authors/zeroraised)
- Publisher: ZeroRaised (https://zeroraised.com/)
- Section: Growth
- Tags: artificial-intelligence, developer-tools, saas, bootstrapping

Factory made a quiet but consequential change in Droid 1.0: the agent now writes JavaScript that calls tools, instead of asking the model for one tool at a time. Factory calls this programmatic tool calling and made it the default in Droid 1.0 ([Factory](https://factory.com/news/frontier-harness)). The reported result is a 15% cut in Droid's cost on Claude Opus 5.5, with the savings concentrated in the scripts that do the most tool work.

**TL;DR**

- Factory made programmatic tool calling the default in Droid 1.0.
- The agent writes a program that invokes tools and runs it end to end in one invocation.
- Factory reports Script mode cuts Droid's cost by 15% on Claude Opus 5.5.
- Savings cluster in the 12.5% of Scripts that make six or more tool calls.

**Disclosure:** ZeroRaised publishes this analysis and is a launch site for bootstrapped products. Facts come from the linked source as checked on 2 Nov 2026; ZeroRaised has no commercial relationship with the companies named.

**Programmatic tool calling** is an agent pattern where the model writes a program that invokes the tools, then runs that program end to end in one invocation, instead of making one model round trip per tool call.

## What is an agent harness?

Factory defines the harness as more than the model. "An agent harness is everything around the model: the prompts, the tools, how tool results come back, and the loop that runs it all" ([Factory](https://factory.com/news/frontier-harness)).

Most setups use a straightforward loop: the model requests a tool, your code runs it, the result goes back, and the model decides the next step. That is easy to debug, and expensive for dozens of small steps.

## What did Factory actually change?

Programmatic tool calling flips the loop. The agent writes a program that invokes the tools, then runs it end to end in one invocation ([Factory](https://factory.com/news/frontier-harness)). Factory made it the default in Droid 1.0 for three reasons: cleaner context, because raw tool outputs stay in the program as variables; fewer model requests; and more reliability, because checks and loops run deterministically in code.

The mechanism is a Script tool. The model writes JavaScript that runs in a sandbox with no file, network or system access of its own. One model request can trigger hundreds of tool calls. Printed output is capped, full results are logged, and independent calls run concurrently ([Factory](https://factory.com/news/frontier-harness)).

Factory credits CodeAct, a 2024 paper by Wang and others, with showing that acting through code beats JSON and text tool calls across 17 models. Cloudflare and Anthropic shipped it in late 2025, and Codex took it to coding agents this year ([Factory](https://factory.com/news/frontier-harness)).

## Why are fewer model round trips cheaper?

A timing example: fixing a failing unit test with GPT-6.1 Sol at high reasoning took 10 model calls and 15 tool calls in 56.8 seconds with direct calls. The Script version used 5 model calls and the same 15 tool calls in 41.6 seconds, and time inside model calls fell from 42.3 seconds to 28.0 seconds ([Factory](https://factory.com/news/frontier-harness)).

The tool calls did not get cheaper. The saving came from not asking the model to decide, one call at a time, what the code could decide in a loop. Our read: model requests are where agent cost and latency pile up, because each extra request sends the growing context again.

## What do the Linear and CI runs show?

Two examples. In a Linear cleanup, the agent moved 151 issues using 312 tool calls. Direct calls were estimated at 36 requests and around 3.1 million input tokens, assuming 10 calls per request. The Script took 2 requests and around 61,000 tokens ([Factory](https://factory.com/news/frontier-harness)).

A CI sweep of 550 tool calls across 5,384 jobs needed 2 requests instead of an estimated 59 to 187, and under 0.1% of tool results reached the model's context ([Factory](https://factory.com/news/frontier-harness)).

Factory labels the direct-call figures as its own estimates, so treat the ratios as illustrative. For hundreds of similar calls, keeping raw results in a program and returning a summary is cheaper than pasting every result into the prompt.

## Why is context the real bill?

Programmatic tool calling is mostly a context management technique. Raw tool output is verbose and mostly irrelevant to the next decision. If every result enters the model's context, you pay for it on every later request and dilute the signal.

Factory also describes the quieter harness work. A typical production request reads 98% of its input from cache, and 98.6% of requests are append-only, with newly discovered tools appended at the end so the cache prefix survives. The base prompt was cut 37%, from 20,887 to 13,055 input tokens, by sending 2 tool definitions up front instead of 11 and loading rarely used tools on demand ([Factory](https://factory.com/news/frontier-harness)). The lesson is unglamorous: the cheapest token is the one you never send.

Factory bounds autonomy too: three identical tool calls trigger a nudge and six stop the loop, and compaction summaries are now 16,000 tokens, up from 8,000 ([Factory](https://factory.com/news/frontier-harness)).

## What are the risks and limits?

Do not read the 15% figure as a universal discount. Factory says the saving concentrates in the 12.5% of Scripts that make six or more tool calls ([Factory](https://factory.com/news/frontier-harness)). For one or two calls per task, the machinery adds little gain.

The sandbox is a security boundary, not a convenience. Running model-written code with no file, network or system access of its own is the safe default, and it means the code cannot do anything the tools cannot do. Keep the tool surface small and audited.

Benchmark claims need the same care. Factory says Droid outperforms native harnesses "up to 20% more efficiently", and that on Terminal-Bench 4 with GPT-6.1 Sol it scored 3.5 points higher than Codex at 12% lower cost ([Factory](https://factory.com/news/frontier-harness)). Those are Factory's own results, run 23 to 28 Oct 2026, and should be read as vendor claims.

## What this means for bootstrapped founders

1. **Count model requests per task, not tokens per call.** The request count is the lever you can usually move.
2. **Look for repeated tool loops.** If the agent calls the same tool with different arguments in a pattern, that pattern belongs in code.
3. **Keep raw results out of context.** Return a summary and log the full output for debugging.
4. **Measure cost per completed task.** A faster loop that fails more often is not cheaper.
5. **Assume vendor benchmarks are directional.** Test the pattern on your own workload before rewriting the harness, and keep a human on irreversible actions.

The [guide to choosing an LLM API](https://zeroraised.com/blog/how-to-choose-an-llm-api) covers the pricing side, and the [guide to reducing LLM costs](https://zeroraised.com/blog/how-to-reduce-llm-costs) covers the rest. The [agent versus workflow comparison](https://zeroraised.com/blog/ai-agent-vs-ai-workflow) helps you decide whether you need an agent loop at all. For the mechanism, see [what function calling is](https://zeroraised.com/blog/what-is-function-calling).

## Where ZeroRaised fits

ZeroRaised is a launch and discovery site for products built without institutional venture capital or accelerator equity. If you build agent tooling, [submit it here](https://zeroraised.com/submit) and describe the workload where it pays off. The [newsletter](https://zeroraised.com/newsletter) carries new analysis like this, and the [pricing page](https://zeroraised.com/pricing) explains the listing options. We make no promise of traffic or results.

## Sources

- [Factory: Droid 1.0, building a frontier harness](https://factory.com/news/frontier-harness)

## Frequently asked questions

### What is programmatic tool calling?

It is an agent pattern where the model writes a program that calls tools, then runs that program end to end in one invocation. Tool results stay in the program as variables, so only the output the model needs comes back into its context.

### Did Factory really cut costs by 15%?

Factory reports that Script mode cuts Droid's cost by 15% on Claude Opus 5.5. The saving is not spread evenly: Factory says it concentrates in the 12.5% of Scripts that make six or more tool calls.

### Does writing code make agents more reliable?

Factory gives reliability as one reason for the change, because checks and loops run deterministically in code rather than through repeated model decisions. That is a design argument, not a guarantee, and the agent still needs limits.

### Is this the same as a normal tool call?

No. A normal tool call is one model request, one tool execution and one result sent back. Programmatic tool calling batches many tool calls inside a single model request and returns a compact result, which reduces how often the model has to be invoked.

### Should a small team build this pattern?

Only if your agents make many tool calls per task. The overhead of a sandbox, logging and limits is real, and the savings are small when a task needs one or two calls. Measure cost per task before and after.


