Code execution
Code execution is the running of a program by a computer and the return of its result, output or errors.
Code execution turns source code or a compiled program into actions on a machine. An interpreter or a runtime reads the code and carries out each instruction, or the processor runs compiled machine code directly. During execution, the program can read files, use the network, start other processes and print output. When it ends, it returns an exit status that tells whether it succeeded.
Executing code is how a computer does useful work, but it is also where risk lies. A program can do anything that its permissions and environment allow, including deleting files or sending data over the network. Systems that run code from unknown sources therefore limit the environment first. They run the code with fewer permissions, inside a container or a virtual machine, and with limits on time and resources.
Code execution is central to AI agents. A model writes code to analyze data, test a fix or control a tool, and the system runs it and returns the result to the model. Because the code comes from a model and no person reviews it first, it is treated as untrusted code. Sandboxes give each agent an isolated machine where it can execute code safely, at scale, and keep the results.