by antoineMoPa · 1w ago · 0 comments
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:
# old:
loop x4:
next_tool = ask_llm()
result = call_tool(next_tool)
send_to_llm(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]