Lookup by name
The runtime maintains a map of registered tools by name. Lookup is O(1). If the model requests a tool that doesn't exist, an error message is fed back into the loop so the model can recover.
Advertisement
Argument validation
Before invoking, the runtime validates the model's arguments against the tool's declared JSON schema. Bad args produce a structured error the model can read and retry from.
public class WeatherTool implements Tool {
@Override
public Schema schema() {
return Schema.object()
.property("city", Schema.string().required())
.property("units", Schema.string().defaultValue("metric"));
}
@Override
public Object call(Map args) {
String city = (String) args.get("city");
return fetchWeather(city);
}
} Advertisement
Invocation with timeout
The runtime wraps call() in a timeout supervisor (default 30s). Slow tools don't hang the loop — they raise ToolTimeoutException which routes through onToolError.