Pattern

Code-as-Action (CodeAct / Code Mode)

Let the agent write and run a short program that calls tools, instead of emitting one structured tool call per turn, so loops, filtering and intermediate results stay in a sandbox and out of the model's context.

Classification Looping (each step is a program run in a sandbox)

Full entry

The complete treatment — problem, how it works, when to use it, sources, and examples — lives in the volume below.

Browse the full pattern index or the catalog.

Search the catalog