Skip to content

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.

  • 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
const agent = await ReactiveAgents.create()
.withReasoning({ defaultStrategy: "code-action" })
.build();
  1. Plan — LLM receives TypeScript function signatures for each registered tool and writes a single async IIFE.
  2. Execute — The IIFE runs in a Node.js Worker thread. Tool calls are routed back to the host via postMessage round-trips.
  3. Observe — Tool call log and final return value are formatted as an observation message.
  4. Reflect — Verifier checks the result; if it fails, the LLM regenerates code with feedback.
agent:my-agent ← AGENT span
code-action:plan ← LLM span (code generation)
code-action:execute ← TOOL span (sandbox run)

@experimental — v0.11.1