Sure thing! I like the shopping analogy usually, but I’ll illustrate the batch savings in more concrete terms maybe?
Especially for dependent calls, the savings are more obvious than the shopping analogy suggests.
So in code, this is roughly the difference between:
# old:
loop x4:
next_tool = ask_llm(context)
result = call_tool(next_tool)
context.append(result)
# do something with the result
And
# new (no loop!)
script_to_run = ask_llm(my_tools_list)
result = run_sandbox(script_to_run)
# do something with the result
In the new version we’ve mostly eliminated the need for the loop, and you’ll notice we only needed to call ask_llm() once! The LLM is batching multiple dependent tool calls into a little script that you run in a secure sandbox so you don’t have to go to the oracle of Delphi every time you need to call a tool.
In practice it allows the LLM to “think” in workflows instead of in terms of individual function calls. Not only does it save LLM calls, but it saves context because the LLM doesn’t often need to know every intermediate result.
Another example is from the README. In code mode, the LLM generates this script. It’s one call to the LLM and never leaves your pc. In contrast, normal tool calling would turn each of these calls into a call to the LLM.
# 4-step process
pr = get_pull_request(number=42)
runs = list_runs(commit=pr["head_sha"])
failed = [run for run in runs if run["conclusion"] == "failure"]
[{"check": run["name"], "log": get_log(run_id=run["id"])[-500:]} for run in failed]
Thats mostly correct, but there’s two distinctions between what they’re doing and what I built here where the savings come from.
1) this is a tool for people writing and building harnesses. Codex has their own implementation likely, but that doesn’t mean anybody building a SaaS or other agent application has access to that tech easily (until now).
2) what they’re doing is often not “code mode.” Yes, Claude code and codex can write scripts, but they can’t execute MCP or other (remote) tool calls directly from those scripts. They can write a script that replaces strings and uses on-system library and so forth. They (well big harnesses like Claude code are starting to do this experimentally) can’t write a script that pauses mid-execution, asks the machine to make an MCP or other call on its behalf (without installing a library or other tool), and comes back to execution after. The scripts you see codex and Claude code make are unable to reach out to MCP servers and mostly can’t do anything that “vanilla” python can’t. If you’re cloudflare and have 10,000 mcp servers you have to talk to, the python scripts that codex generates aren’t saving you many calls at all.
what does "write code against its tools" mean in practice?
Especially for dependent calls, the savings are more obvious than the shopping analogy suggests.
So in code, this is roughly the difference between:
And In the new version we’ve mostly eliminated the need for the loop, and you’ll notice we only needed to call ask_llm() once! The LLM is batching multiple dependent tool calls into a little script that you run in a secure sandbox so you don’t have to go to the oracle of Delphi every time you need to call a tool.In practice it allows the LLM to “think” in workflows instead of in terms of individual function calls. Not only does it save LLM calls, but it saves context because the LLM doesn’t often need to know every intermediate result.
Another example is from the README. In code mode, the LLM generates this script. It’s one call to the LLM and never leaves your pc. In contrast, normal tool calling would turn each of these calls into a call to the LLM.
1) this is a tool for people writing and building harnesses. Codex has their own implementation likely, but that doesn’t mean anybody building a SaaS or other agent application has access to that tech easily (until now).
2) what they’re doing is often not “code mode.” Yes, Claude code and codex can write scripts, but they can’t execute MCP or other (remote) tool calls directly from those scripts. They can write a script that replaces strings and uses on-system library and so forth. They (well big harnesses like Claude code are starting to do this experimentally) can’t write a script that pauses mid-execution, asks the machine to make an MCP or other call on its behalf (without installing a library or other tool), and comes back to execution after. The scripts you see codex and Claude code make are unable to reach out to MCP servers and mostly can’t do anything that “vanilla” python can’t. If you’re cloudflare and have 10,000 mcp servers you have to talk to, the python scripts that codex generates aren’t saving you many calls at all.