When to reach for it
- Calculations, data transformations, or complex tool calls must be precisely executable.
- The result should be reproducible.
- Multi-step logic composes more cleanly as one program than as a chain of separate tool calls.
/pattern/codeact/
The agent uses executable code rather than pure text as its primary medium for action and reasoning — it writes code, runs it in a sandbox, observes the typed result, and iterates, so a computation is executed rather than approximated in prose.
When to reach for it
When it backfires
The tradeoff
Maximum precision and reproducibility oppose a high sandbox, security, and runtime overhead.
Think, emit code, execute in a sandbox, observe the typed result — and back to think. Code is the action.
The emitted code reads sensitive files or opens outbound connections despite the sandbox.
Fix · Use a hardened sandbox with strict seccomp policies, no network, and a read-only filesystem.
A failed tool call returns stderr, but the agent interprets it as a valid observation and proceeds with corrupted state.
Fix · Always check exit codes. Treat non-zero exits as errors and route to an error-handling node.
Search patterns, frameworks, and pages.