handler(input) function in a secure Firecracker sandbox and returns markdown plus structured data. Display name “Python Code”. Off by default — enable it in the agent’s Tools panel.
This is not how you render HTML in the task feed.
When to use it (vs app_tool vs custom_interface vs generate_file)
handler(input) must return
{'markdown': str, 'data': any}. That markdown is what the feed shows — not HTML. There is no flag to “render as HTML”. If the user wants a scorecard or interactive widget in the feed, use app_tool (interactive) or custom_interface (display-only).
Authentication and enablement
No OAuth. Runs in the platform sandbox (HTTP calls capped, time/memory limited). Off by default.Inputs
python_code(required for the base tool; injected from bindings on a configured tool): ahandler(input)function.input(required): extra parameters for the handler. Never pass"input": {}if the instructions mention parameters. Task variables (VAR_1,VAR_2, …) are auto-injected — read them asinput['VAR_1']; do not put them ininputyourself.
None / True / False, not JSON null / true / false.
Output
Structured result withoutput (the handler return), prints (stdout), and optional artifacts from save_artifact(name, content). The feed renders output.markdown.
Limits and side effects
- Sandbox: bounded CPU, memory, and outbound HTTP.
save_artifactuploads files the user can download; call it once per file.- Configured-tool code is stored in bindings and not shown as a per-run input on later runs.
Expected errors
- Empty
inputwhen parameters were required — the handler then has nothing to work with. - Handler does not return
{'markdown', 'data'}— treat as a contract violation and fix the return. - Sandbox timeout / HTTP budget exceeded.