protologue

Programmatic Tool Calling

Also called code mode.

Programmatic tool calling is a tool-use pattern in which the model writes code that calls tools as functions inside a sandboxed execution environment, so that several tool calls and the processing of their results happen in code rather than through a separate model turn for each call.

Description

Intermediate tool results stay in the execution environment and only the code's final output returns to the model, which reduces context usage and the number of model round trips for tasks that involve many calls or large data. Anthropic offers it as a feature of its API, and Cloudflare describes the same pattern for MCP tools under the name Code Mode.

Sources

  1. Anthropic (2025). Programmatic tool calling.
  2. Anthropic (2025). Introducing advanced tool use on the Claude Developer Platform.
  3. Cloudflare (2025). Code Mode.

Cite this entry

Protologue. (2026). Programmatic Tool Calling. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.4.0, PTL-0223). https://protologue.com/t/programmatic-tool-calling/

BibTeX
@misc{protologue_programmatic_tool_calling,
  title = {Programmatic Tool Calling},
  author = {{Protologue}},
  year = {2026},
  howpublished = {Protologue: A Taxonomy of Prompting and LLM Techniques, v1.4.0},
  note = {Entry PTL-0223},
  url = {https://protologue.com/t/programmatic-tool-calling/}
}

Markdown JSON