Skip to main content

workbench

workbench.run_python

Run Python in the workbench sandbox

Effects: external_api

Run Python in an isolated sandbox to process LARGE or paginated tool results without pulling every row into the conversation. Inside the code, call your connected integration tools with call_tool('ext<id>_<name>', {..}), or this agent's own platform tools by their dotted id (e.g. call_tool('db.query', {'sql': 'SELECT ...'})) — a platform tool must be in the agent's allowed_tools, and calling one requires an agent context. RETURN SHAPE: call_tool ALWAYS returns a dict with a boolean r['success']. The payload key DIFFERS by tool kind: integration (ext*) results are under r['body'] (e.g. r['body']['results']), platform tools are under r['data'] (e.g. r['data']['rows'] for db.query). Reading the wrong key returns nothing even though the call SUCCEEDED — so when in doubt print(r) once and inspect before extracting. On FAILURE r['success'] is False and r['error'] explains. Aggregate/filter/paginate in the sandbox, then assign ONLY the small summary you want back to a variable named result. FIRST discover exact tool slugs with integrations_search_tools, THEN write code that calls them. pandas/numpy available.

Arguments

ArgumentTypeRequiredDescription
agent_idintegernoWhich agent's tool policy the sandbox runs under — this scopes which ext* integrations call_tool may reach (enabled + denied_tools for that agent). Only needed when calling this tool OUTSIDE a normal agent run (e.g. directly from an external MCP client); during an agent run the running agent is used and this is ignored. Without it, call_tool can reach no integrations.
codestringyesPython source to execute. call_tool(slug, {..}) returns a dict: for integrations ('ext<id>_<name>') the HTTP payload is under r['body'] (e.g. r['body']['results']); for platform tools (dotted ids like 'db.query') it is under r['data'] (e.g. r['data']['rows']). Failure is {'success': False, 'error': ...}. Assign the small summary to result. pandas/numpy available.