pub struct FunctionDefinition {
pub name: String,
pub description: Option<String>,
pub parameters: Option<Value>,
pub cache_control: Option<CacheControl>,
}Expand description
JSON Schema description of a callable function.
Why: The model needs the name, a description, and parameter schema to decide
when and how to call the function correctly.
What: name is the call target; description guides model selection;
parameters is a raw serde_json::Value holding the JSON Schema object
for flexibility (different tools may use different schema shapes).
Test: function_definition_round_trip.
Fields§
§name: StringThe function name as registered with the model.
description: Option<String>Human-readable description guiding the model’s decision to call it.
parameters: Option<Value>JSON Schema object describing the function’s parameter shape.
cache_control: Option<CacheControl>Prompt-cache breakpoint (#2156). When set, serialises as a sibling
"cache_control":{"type":"ephemeral"} field alongside this function’s
schema — the shape block/goose’s (verified, production) OpenRouter
provider uses to cache Claude tool definitions via the OpenAI-compat
endpoint. agent_loop::build_request sets this on the LAST tool
definition only: Anthropic caches everything up to and including a
breakpoint, so marking just the last tool caches the entire
(byte-stable) tools array as a single prefix.
Trait Implementations§
Source§impl Clone for FunctionDefinition
impl Clone for FunctionDefinition
Source§fn clone(&self) -> FunctionDefinition
fn clone(&self) -> FunctionDefinition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FunctionDefinition
impl Debug for FunctionDefinition
Source§impl<'de> Deserialize<'de> for FunctionDefinition
impl<'de> Deserialize<'de> for FunctionDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FunctionDefinition
impl PartialEq for FunctionDefinition
Source§fn eq(&self, other: &FunctionDefinition) -> bool
fn eq(&self, other: &FunctionDefinition) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for FunctionDefinition
impl Serialize for FunctionDefinition
impl StructuralPartialEq for FunctionDefinition
Auto Trait Implementations§
impl Freeze for FunctionDefinition
impl RefUnwindSafe for FunctionDefinition
impl Send for FunctionDefinition
impl Sync for FunctionDefinition
impl Unpin for FunctionDefinition
impl UnsafeUnpin for FunctionDefinition
impl UnwindSafe for FunctionDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more