What if Claude could query three datasets, filter the rows, and return a summary without reading every raw result into its context? That’s what programmatic tool calling lets you do in the Claude API.
Enable Code Execution and add allowed_callers: ["code_execution_20260120"] to your tool definition. Claude can then write Python that calls the tool as an async function, loops over inputs, branches on results, or runs independent calls in parallel with asyncio.gather.
Your app still handles the tool_use requests. The difference is where the results go: return tool_result with the same container ID to resume the running script. The intermediate results go back to Python; Claude sees the script’s final output. That can mean fewer model turns and less context spent on raw data.
Two details matter: keep the container ID while the script is waiting, and describe exactly what your tool returns so Claude can parse it. allowed_callers tells Claude how to use the tool; it isn’t a security boundary.
Official Claude API documentation:
https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling
#ClaudeAPI #ToolCalling #AIAgents
YouTube / ABVX
