pub struct ToolCall { /* private fields */ }Expand description
A complete model-initiated tool invocation.
use reef_core::opaque;
use reef_core::value::tool_call;
let call = tool_call::ToolCall::new(
tool_call::Id::new("call-1".into()),
tool_call::Name::new("search".into()),
opaque::Payload::copy_from_slice(br#"{"q":"reef"}"#),
);
assert_eq!(call.id().as_str(), "call-1");
assert_eq!(call.name().as_str(), "search");
assert_eq!(call.arguments().as_bytes(), br#"{"q":"reef"}"#);§Equality
Field-wise content: same Id, same Name, and a Payload equal by
the byte-wise rule that type documents. It is not correlation identity.
Correlation identity is Id.
ToolCallDecision::Modify
can replace the call before execution and change the name and arguments;
the runtime preserves the model-assigned id as correlation identity. Two values
that share an id are not therefore equal, and two values that differ in id are
not therefore “the same call in a later edit.”
Empty Id and Name values compare equal at this leaf; the event layer
still rejects empty identities. The relation is total, so this is an Eq.
Nothing here is normalized before the comparison: two argument payloads a
provider would read as the same JSON are unequal whenever their bytes
differ, for the same reason Payload documents.
use reef_core::opaque;
use reef_core::value::tool_call;
let call = |id: &str, name: &str, arguments: &[u8]| {
tool_call::ToolCall::new(
tool_call::Id::new(id.into()),
tool_call::Name::new(name.into()),
opaque::Payload::copy_from_slice(arguments),
)
};
assert_eq!(
call("call-1", "search", br#"{"q":"reef"}"#),
call("call-1", "search", br#"{"q":"reef"}"#)
);
// Same correlation identity; different name, so a different call.
assert_ne!(
call("call-1", "search", br#"{"q":"reef"}"#),
call("call-1", "lookup", br#"{"q":"reef"}"#)
);
// Same JSON to a provider; different bytes, so a different call.
assert_ne!(
call("call-1", "search", br#"{"q":"reef"}"#),
call("call-1", "search", br#"{ "q" : "reef" }"#)
);
// Empty leaves compare equal here; the event layer still rejects empty ids.
assert_eq!(call("", "", b""), call("", "", b""));