pub fn bind_call_args(
tool: &dyn Tool,
positional: &[Value],
keyword: &[(String, Value)],
) -> ValueAvailable on crate features
agents and codeact only.Expand description
Bind a call’s positional and keyword arguments onto a tool’s parameters,
producing the single JSON object a Tool expects.
This is the one place positional arguments are mapped onto names, so no
runtime needs the tool’s schema at the call boundary. Keyword arguments are
inserted by name; positional arguments are matched, in order, against the
tool’s parameter names (the schema’s required list first, then any
remaining properties). A positional argument with no corresponding name
(or for a tool with no schema) falls back to arg0, arg1, … so nothing
is silently dropped. A keyword always wins over a positional for the same
name.
§Example
use std::sync::Arc;
use adk_agent::codeact::bind_call_args;
use serde_json::{json, Value};
let tool = Add;
let bound = bind_call_args(&tool, &[json!(1), json!(2)], &[]);
assert_eq!(bound, json!({"a": 1, "b": 2}));