← Back to glossary
+Suggest a term
Concept·Agents & Automation·Added today

CodeAct

Also known as: code act, code-act pattern

A pattern where an agent writes a short program to call multiple tools in one shot, rather than choosing tools one at a time. Instead of many round-trips between the model and its tools, a single script runs them all and returns one consolidated result.

In a typical agentic loop, an agent picks a tool, waits for the result, picks the next tool, waits again, and so on. Every step is a separate model call, which adds up fast in both latency and token cost. CodeAct collapses that chain. The model writes a small Python script that calls your tools via a helper function, the script runs once in a sandboxed environment (an isolated container where code executes safely without touching the host system), and the agent gets back everything it needs in a single response.

The pattern was popularized by research and then shipped as a first-class feature in Microsoft's Agent Framework at Build 2026, where each script execution runs inside a Hyperlight micro-VM, a lightweight virtual machine that gives strong isolation with almost no overhead. The practical effect is that tasks requiring five or six tool calls can resolve in roughly the time of one.

For builders, CodeAct is most useful when your agent needs to do real computation alongside tool calls, not just string them together. If your workflow already runs in milliseconds, the overhead of generating a program may not be worth it. But for agents that chain web lookups, file reads, and API calls in one task, collapsing the loop into a single script can meaningfully cut wall-clock time and inference cost.

This definition is AI-generated and refreshed weekly. It may contain inaccuracies. Use your own judgment, especially for production decisions.
Related terms
Agentic loopTool calling patternSandboxingAgent framework