Skip to main content
CodeAgent generates, executes, reviews, and refactors code, and only runs code when you name an explicit executor.

Quick Start

1

Run code with an explicit executor

2

Generate, review and refactor


Why an explicit executor?

Execution is granted by naming a runner, never by flipping a boolean. Without code.executor, execute() returns { success: false, error: 'No code executor is configured...' }. This is deliberate, so model-generated code cannot silently run in-process.

How It Works


CodeConfig


createSubprocessExecutor()

createSubprocessExecutor() is a ready-made out-of-process runner.
Default interpreter map:
  • Runs a detached child on non-Windows so the timeout kills the whole process group.
  • Truncates output live during streaming, not after close.
  • An unregistered language returns { success: false, error: "No interpreter is registered for '<lang>'. Known: ..." }.
Set PRAISONAI_PYTHON to override the interpreter used for python / python3.

Writing your own executor

Supply a CodeExecutor to target a container, microVM, e2b, or a remote sandbox service.
The CodeExecutor signature:
CodeExecutorContext carries sandbox, timeout, workingDirectory, environment, and maxOutputLength.
A child process is not a security sandbox — it shares the host filesystem, network and user. For untrusted code, supply your own executor targeting a container, microVM, or remote sandbox service.

Best Practices

Never rely on a boolean to enable execution. Pass createSubprocessExecutor() or your own runner so execution is a visible decision.
Set allowedLanguages to only the languages you expect. execute() rejects any other language before the executor runs.
Supply a container or microVM executor for model-generated or user-supplied code. The subprocess runner shares the host.
Keep maxOutputLength and timeout sensible. Output is capped as it streams and the timeout kills the whole process tree.

Sandbox

The generic Agent executeCode() sandbox (separate API)

Agent

Agent configuration and capabilities

Placement

Where agents run