Skip to main content

Overview

Code executors wrap your agent’s code and intercept API calls. They allow your AI agent to write normal code targeting production APIs (like https://slack.com/api/*) while actually hitting isolated test environments.

Flow

1

Agent Writes Code

2

Code executor Proxy

  1. Wraps code with interception logic
  2. Detects API URL patterns
  3. Rewrites URLs to route into the isolated environment
3

Environment

Real API responses from your sandboxed environment

URL Transformation Rules

The executor transforms URLs based on these patterns:

Available Executors

Python

Intercepts requests and urllib

TypeScript

Intercepts fetch API

Bash

Intercepts curl commands

How Interception Works

Python Executor

The Python executor wraps code with a custom URL opener:

TypeScript Executor

The TypeScript executor overrides global fetch:

Bash Executor

The Bash executor uses sed to transform curl URLs:

Security Considerations

Code executors run arbitrary code. In production, consider:
  • Running executors in sandboxed containers
  • Implementing timeouts
  • Restricting network access
  • Validating code before execution

Next Steps

Python Executor

Detailed Python executor guide

TypeScript Executor

Detailed TypeScript executor guide