Skip to main content
Write, run, and debug code with a single Agent equipped with execution and analysis tools.
Code development agent with execution, analysis, and shell tools.
This page uses a plain Agent with code tools — ideal as a task-focused recipe. For the dedicated CodeAgent class with sandboxed generate/execute/review/refactor methods, see the Code Agent page.

Quick Start

1

Simple Usage

Attach code tools and ask for a script.
2

With Configuration

Enable reflection so the agent self-checks its output before returning.

How It Works


Simple

Agents: 1 — Single agent with code tools handles writing and executing code.

Workflow

  1. Receive code request
  2. Generate code
  3. Execute and test
  4. Return working solution

Setup

Run — Python

Run — CLI

Run — agents.yaml

Serve API


Advanced Workflow (All Features)

Agents: 1 — Single agent with memory, persistence, structured output, and session resumability.

Workflow

  1. Initialize session for code project tracking
  2. Configure SQLite persistence for code history
  3. Generate and execute code with structured output
  4. Store code in memory for iterative development
  5. Resume session for code modifications

Setup

Run — Python

Run — CLI

Run — agents.yaml

Serve API


Monitor / Verify

Cleanup

Features Demonstrated

Best Practices

Attach execute_code so the agent runs its own output and catches errors before returning. Code that only looks right often fails on the first run.
Set reflection=True so the agent reviews and corrects its solution. This trades a few extra tokens for markedly higher first-try success on non-trivial code.
When you need process isolation, timeouts, and language restrictions, use the dedicated CodeAgent class instead of a plain Agent with tools.
If you switch to CodeAgent, keep sandbox=True in production. Executing model-generated code without isolation is a security risk.
The dedicated CodeAgent class with sandboxed execution.
Analyze data files with a data-focused agent.