ai.tools._typed_arguments

(internal) The arguments of a tool call as `reflect.call_any` takes them.

Reference version

Signature

function ai.tools._typed_arguments(
tool: string,
handler: reflect.AnyFunction<Returns = unknown, Throws = unknown>,
args: map<string, unknown>
) -> map<string, unknown> throws baml.errors.InvalidArgument

(internal) The arguments of a tool call as reflect.call_any takes them.

A provider hands over a model's arguments as parsed JSON: a class is a map, an enum a string, a list a list of json. reflect.call_any takes values of the parameter types, and the only JSON values that are such values are the scalars. So the parameters that were sent JSON are read as the fields of one class, the JSON is aligned to that class as any other model output is (baml.sap.coerce), and the fields of the result are the arguments.

An argument passes as it arrived when it names no parameter, and when it is already a value of its parameter's type: that is what BAML code passes when it calls a tool itself, and it is every value of an unknown parameter. reflect.call_any judges every argument that passed.

Source:<builtin>/ai/ns_tools/tools.bamlbytes 2997–4955