repair_tool_call: Repair Tool Call

View source: R/tool.R

repair_tool_callR Documentation

Repair Tool Call

Description

Attempts to repair a failed tool call. This implements a multi-layer repair strategy inspired by Opencode's experimental_repairToolCall:

  1. Try to fix tool name case issues (e.g., "GetWeather" -> "get_weather")

  2. If repair fails, route to an "invalid" tool for graceful handling

Usage

repair_tool_call(tool_call, tools, error_message = NULL)

Arguments

tool_call

A list with name, arguments, and optionally id.

tools

A list of available Tool objects.

error_message

Optional error message from the failed call.

Value

A repaired tool call list, or an "invalid" tool call if unrepairable.


aisdk documentation built on May 29, 2026, 9:07 a.m.