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
- 01
Sandbox first
E2B or equivalent. No host prod creds. Network allowlist.
- 02
Expose libraries, not god-tools
A small set of functions and data frames. Cap runtime and memory.
- 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 exec — A shell or code-act tool on the host with production credentials.
- Computer-use as the first tool — A browser or desktop agent used where an API, a workflow, or a grep would do.
- Mega-tool — One function whose argument is a JSON blob of 'whatever'. An untyped shell with extra steps.
Load with this
Load next
- Sandbox and injectionThe agent has a shell, a browser, documents, or plugins. The model is a confused deputy.
- Design the ACIYou are adding or reviewing tools. The ACI is the prompt you cannot see.
- The agent loopYou need a loop you can pause, inspect, eval, and resume. Frameworks wrap this; they must not own it.
Trigger tests
Should fire
- “The agent should write pandas to filter this CSV”
- “Use smolagents code-act”
Should not
- “Edit the TypeScript repo”