Skip to content

Skill · pattern · code-act

Code-act

Let the model write a program that composes tools in a sandbox (smolagents + E2B), instead of one JSON tool call per hop. Use when composition (loops, filters, pandas) beats hop-by-hop function calling — never unsandboxed.

GET /api/canon/skills/code-act?format=md

Hugging Face smolagents: code is the ACI. The sandbox is the product. This is not eval() on the host.

When

The agent would otherwise make 40 tiny tool calls to filter a table.

Do

  1. 01

    Sandbox first

    E2B or equivalent. No host prod creds. Network allowlist.

  2. 02

    Expose libraries, not god-tools

    A small set of functions and data frames. Cap runtime and memory.

  3. 03

    Observe compactly

    stdout/stderr truncated with a hint. Plots and files as paths.

Don't

  • eval(model_code) on the API box.
  • Use code-act where apply_patch + tests would do (coding agents).

Hard rules

  • Code-act is a pattern, not a reason to skip the harness for repo edits.
  • Budgets on CPU, wall clock, and imports.

Refuse

  • Unsandboxed execA shell or code-act tool on the host with production credentials.
  • Computer-use as the first toolA browser or desktop agent used where an API, a workflow, or a grep would do.
  • Mega-toolOne function whose argument is a JSON blob of 'whatever'. An untyped shell with extra steps.

Load with this

Load next

Trigger tests

Should fire

  • The agent should write pandas to filter this CSV
  • Use smolagents code-act

Should not

  • Edit the TypeScript repo