Skip to main content
The Code backend gives the LLM one meta-tool: execute_code(code, timeout). The LLM writes an async Python script that calls your tools directly. One turn can do the work of many.

Setup

How It Works

The LLM writes the entire workflow in one shot. Concierge runs it in a sandboxed environment.

What the LLM Writes

The LLM has access to two injected modules:

Why It’s 98% Less Context

Compare the token cost:
The savings come from: (1) only 1 tool definition sent instead of 50, (2) one turn instead of multiple, (3) no tool schemas resent on each turn.

Sandbox Security

The code runs in a restricted environment: Default timeout is 30 seconds. Configurable per call.
The sandbox only exposes your registered tools via the tools module. The agent cannot access anything outside what you’ve explicitly defined.

When to Use

Use Code when the LLM needs to do complex logic:conditionals, loops, sorting, filtering, or chaining many tools together.
Good fit:
  • Complex workflows with conditionals (if cheapest.price < 500: ...)
  • Batch operations (loop over items)
  • Maximum cost efficiency
  • Chaining 3+ tools in sequence
Bad fit:
  • LLMs that struggle with code generation (smaller models)
  • Simple one-tool calls (Plain is simpler)
  • When you need human-readable execution logs (Plan is more auditable)