Skip to content

docs / the tools / run_code

run_code

Optional. Lets the agent chain several calls in one short script.

When to use it

When a task needs many calls and only the final answer matters, for example "total last month's invoices by customer".

How it runs

The script runs in a sandbox. Every call inside it goes through the same rules and checks as execute_tool. Only the script output returns to the agent.

script.js
const inv = await tools.stripe.list_invoices({ created: 'last_month' })
return sumBy(inv, 'customer', 'amount_paid')

Availability

Indie and Team. Turn it on per toolset.