Write JavaScript, TypeScript, or Python code that Agents can execute during a run. Use custom tools for validation, transforms, and business logic that don’t need an external API.
calculate_discount)Runtype runs your code in an isolated environment. Choose the one that matches your needs:
Cloudflare Worker runs in-process inside Runtype’s edge workers. It is the fastest option and requires no setup.
Daytona is useful when you need Python, TypeScript, or a containerized environment with configurable outbound access. To use Daytona, add your API key in Settings → Integrations. If Daytona is not configured, tool execution fails and the Agent receives a null result.
QuickJS is still available for backwards compatibility but is not recommended for new tools.
Your code receives input via an injected parameters object. The shape is determined by the parameter schema you define.
In Python, write the result to stdout as JSON. Runtype captures the output and parses it.
Return values. In JavaScript, the returned object is passed directly to the Agent. In Python, the last line of stdout must be valid JSON.
Exceptions. Unhandled exceptions fail the tool and return an error to the Agent. Use structured error returns (see below) if you want the Agent to recover.
Secrets and network. Cloudflare Worker tools have no network access and cannot read managed secrets. Daytona tools inherit network and secret policy from your container configuration.
Cloudflare Worker / QuickJS:
Array, Object, Math, Date, JSON)async/await, arrow functions, destructuring, template literalshelpers namespace (see below)console.log output is captured in tool execution logsHelper functions are accessed as helpers.<name>():
Daytona:
pip packages (Python) or npm packages (JS/TS) — availability depends on your Daytona configurationfetch and outbound network calls — allowed or blocked based on your Daytona sandbox policyClick + Add Parameter and configure each field:
Example:
Set timeout and memory per tool:
Runtype runs a static AST check before saving any custom tool.
Errors (block save):
eval() — error code USE_OF_EVALnew Function() — error code USE_OF_FUNCTION_CTORWarnings (surfaced in the dashboard, do not block save):
while (true) loops without a break or await — warning code INFINITE_LOOPimport() expressions — warning code DYNAMIC_IMPORTreturn statement in JavaScript/TypeScript (Cloudflare Worker and QuickJS only) — warning code RETURN_UNDEFINEDThe check runs again on every update.
Return structured errors so the Agent can recover:
Use the Test panel on the tool page:
console.log calls.calculate_shipping_cost is better than process.{ success: false, error: "..." } instead of throwing.Parameters: email (string, required)
Parameters: isoDate (string, required), format (string, default: "iso")
Parameters: numbers (array of numbers, required)