跪拜 Guibai
← All articles
Artificial Intelligence

LLMs Don't Execute Code: The Runtime Does

By 东风破_ ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Confusing the model with the executor leads to overestimating what LLMs can do and underestimating the engineering needed to make them reliable. A clear mental model — LLM decides, runtime executes — prevents brittle agent designs and makes debugging tool-call failures straightforward.

Summary

Large language models cannot open browsers, query databases, or run code. Their job in a tool-calling pipeline is to read a function's description, decide whether to invoke it, and generate the correct parameters. The actual execution happens in the runtime — Node, Python, or whatever backend is hosting the real function. Once the runtime returns a result, that data is fed back into the model's context so it can produce a natural-language answer. The model never touches the outside world; it only produces structured JSON that says "call this function with these arguments."

A complete Tool Use cycle is a chain: user message, model decision, runtime execution, result injection, and final model response. This is fundamentally different from a hardcoded API call because the model participates in the routing logic — it chooses which tool to use and how to fill parameters based on natural language input. The quality of that routing depends entirely on how clearly the tool's name, description, parameter types, and required fields are defined. Vague descriptions produce unstable calls.

The practical takeaway is a clean separation of concerns. The LLM handles intent and language; the runtime handles side effects and validation; the tool definition is the contract between them. When you see an AI agent "doing things," you're watching a deterministic program execute functions that a model merely requested.

Takeaways
An LLM never executes a function; it only outputs a structured request specifying which tool to call and with what arguments.
The runtime (Node, Python, etc.) parses that request and runs the actual function — querying a database, calling an API, or reading a file.
After execution, the tool's return value must be injected back into the conversation context with a matching tool_call_id so the model can generate a final answer.
Tool Use is a chain: user input → model decision → runtime execution → result injection → model response.
Unlike a hardcoded API call, the model participates in routing by choosing which tool fits the user's natural-language intent.
Stable tool calling depends on clear function names, specific descriptions, accurate parameter types, and explicit required fields.
High-risk operations should require explicit confirmation rather than letting the model trigger them directly.
Conclusions

The phrase 'tool_choice: auto' is widely misunderstood — it means the model may decide to call a tool, not that the model will execute one.

Tool calling is essentially a translation layer that converts natural-language intent into a structured function-call request, then converts deterministic results back into natural language.

The engineering quality of the tool description is the single biggest lever for call reliability; a poorly described function is indistinguishable from a missing one to the model.

Concepts & terms
Tool Use / Function Calling
A pattern where an LLM outputs a structured request (name and arguments) for a function, which the host runtime then executes. The model never runs code itself.
tool_choice: 'auto'
An API parameter that lets the model decide whether a tool call is needed for a given prompt, rather than forcing or suppressing tool use.
tool_call_id
An identifier that links a tool's execution result back to the specific tool-call request the model made, essential when multiple tools are invoked in one turn.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗