Programmatic tool calling
Definition
A model using tools by writing a short program that makes several calls and filters the results, instead of one call per turn.
In more detail
With ordinary tool calling, every call is a round trip: the model asks, your code runs the tool, and the whole result goes back into the context before the next step. With programmatic tool calling the model writes code that loops over files, calls tools in parallel and keeps intermediate results in variables, so a search that returns 500 matches can be cut to the five that matter before the model reads anything.
Anthropic's API offers it under this name: tools marked with allowed_callers can be called from code running in its code execution container. Claude Code's experimental Code Mode applies the same idea locally, running JavaScript through a REPL tool. Because the code decides which calls happen at run time, permission rules and hooks need to check each tool call, not only the code.
Related terms
Agent loop
The repeating cycle of model call, tool call, observation and next decision that drives an agent until the task is done or a limit is hit.
Context window
The maximum number of tokens a model can consider in one request, covering both the input you send and the output it writes.
Sandbox
An isolated environment that limits what an agent or its code can read, write or reach on the network, so any mistakes stay contained.
Tool calling
A model emitting a structured request to call a defined function, which your code runs and whose result is then fed back to the model.
Read more about Programmatic tool calling
- Code Mode: when an agent writes code to call its tools
Claude Code's experimental Code Mode has Claude write JavaScript that calls its tools. How it works and what it changes for permissions, hooks and sandboxing.
- Tool calling
Letting a model request function calls, running them, and feeding results back.
- Claude Code hooks cheat sheet
PreToolUse and PostToolUse events, matcher patterns, stdin JSON payload fields, exit codes and safe config examples.