Source Intelligence

DisclaimerUnofficial, and not affiliated with Anthropic. Nearly all of this is read straight out of what ships: npm bundles, captured prompts, published docs. Anthropic's own notes go in verbatim, marked as theirs. The rest is my reading, and every entry carries the strings behind it. If one looks wrong, vote it down and say why.

All of v2.0.32 Home All releases olderv2.0.31 v2.0.33newer
Claude Code v2.0.32

Automated Tool Execution API (BetaToolRunner)

What: A new toolRunner() method in the Messages API that automatically executes tools in an agentic loop, eliminating the need to manually handle tool_use/tool_result message cycles.

How to use:

const runner = client.beta.messages.toolRunner({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  max_iterations: 10, // Limit agentic loops
  tools: [
    {
      name: "get_weather",
      run: async (input) => {
        // Your tool implementation
        return "Sunny, 72°F";
      }
    }
  ],
  messages: [{ role: "user", content: "What's the weather?" }]
});

// Stream each iteration
for await (const messageStream of runner) {
  // Handle streaming response
}

// Or wait for completion
const finalMessage = await runner.done();

Details:

  • Automatically detects tool_use blocks in assistant responses and executes matching tools
  • Supports both streaming and non-streaming modes
  • Configurable iteration limits via max_iterations parameter
  • Tools must implement a run() method that returns results
  • Optional parse() method for input validation/transformation
  • Returns properly formatted tool_result messages with error handling
  • Can be controlled manually via generateToolResponse() and pushMessages() methods
  • Evidence: Class TYA at line 82603, function bh9() at line 82564, variable uZ1 at line 82604, new toolRunner() method at line 82828

See this entry in the whole of v2.0.32 →