code-execution agents
A code-execution agent solves problems by writing code, running it in a sandbox, reading the output or error, and iterating. Where a model reasoning in prose might fumble arithmetic or lose track of state, this agent offloads the precise work to an interpreter that computes exactly and reports back the truth. It is the difference between estimating a sum in your head and typing it into a calculator that cannot be argued with.
Mechanically the model emits a code block as a tool call; a sandboxed runtime executes it and returns stdout, return values, errors, and side effects, which are appended to the context. The agent can then debug: read a stack trace, patch the code, and re-run until tests pass. This grounding makes results verifiable — you can run assertions or unit tests against the agent's own output — and underlies approaches like program-aided language models, where reasoning is expressed as a program rather than free text.
Execution turns a generator into something checkable, which is the main reliability win, but running model-written code is a serious security surface: it can read data, hit the network, or consume resources. Real deployments require strong sandboxing, resource and network limits, and timeouts, and even then a passing run only proves the code did what was tested, not that it solves the intended task.
Passing tests proves the code does what the tests check, not that it solves the task; and executing model-written code always demands sandboxing.