Code-Action Strategy
code-action is the sixth reasoning strategy. Instead of calling tools one at a time in a ReAct loop, the LLM writes a single code block that orchestrates multiple tools as ordinary async function calls. The block runs in an isolated Worker-thread sandbox.
When to use
Section titled “When to use”- Tasks requiring multi-step numeric computation
- Any task where tool call order is deterministic and parallelizable
- When token efficiency matters more than step-by-step observability
Enable
Section titled “Enable”const agent = await ReactiveAgents.create() .withReasoning({ defaultStrategy: "code-action" }) .build();How it works
Section titled “How it works”- Plan — LLM receives TypeScript function signatures for each registered tool and writes a single async IIFE.
- Execute — The IIFE runs in a Node.js Worker thread. Tool calls are routed back to the host via
postMessageround-trips. - Observe — Tool call log and final return value are formatted as an observation message.
- Reflect — Verifier checks the result; if it fails, the LLM regenerates code with feedback.
Span hierarchy
Section titled “Span hierarchy”agent:my-agent ← AGENT span code-action:plan ← LLM span (code generation) code-action:execute ← TOOL span (sandbox run)Stability
Section titled “Stability”@experimental — v0.11.1