@@ -142,6 +142,45 @@ pub struct ToolCall {
142142 pub id : String ,
143143 pub call_id : Option < String > ,
144144 pub function : ToolFunction ,
145+ /// Optional cryptographic signature for the tool call.
146+ ///
147+ /// This field is used by some providers (e.g., Google) to provide a signature
148+ /// that can verify the authenticity and integrity of the tool call. When present,
149+ /// it allows verification that the tool call was actually generated by the model
150+ /// and has not been tampered with.
151+ ///
152+ /// This is an optional, provider-specific feature and will be `None` for providers
153+ /// that don't support tool call signatures.
154+ pub signature : Option < String > ,
155+ /// Additional provider-specific parameters to be sent to the completion model provider
156+ pub additional_params : Option < serde_json:: Value > ,
157+ }
158+
159+ impl ToolCall {
160+ pub fn new ( id : String , function : ToolFunction ) -> Self {
161+ Self {
162+ id,
163+ call_id : None ,
164+ function,
165+ signature : None ,
166+ additional_params : None ,
167+ }
168+ }
169+
170+ pub fn with_call_id ( mut self , call_id : String ) -> Self {
171+ self . call_id = Some ( call_id) ;
172+ self
173+ }
174+
175+ pub fn with_signature ( mut self , signature : Option < String > ) -> Self {
176+ self . signature = signature;
177+ self
178+ }
179+
180+ pub fn with_additional_params ( mut self , additional_params : Option < serde_json:: Value > ) -> Self {
181+ self . additional_params = additional_params;
182+ self
183+ }
145184}
146185
147186/// Describes a tool function to call with a name and arguments, generally produced by a provider.
@@ -151,6 +190,12 @@ pub struct ToolFunction {
151190 pub arguments : serde_json:: Value ,
152191}
153192
193+ impl ToolFunction {
194+ pub fn new ( name : String , arguments : serde_json:: Value ) -> Self {
195+ Self { name, arguments }
196+ }
197+ }
198+
154199// ================================================================
155200// Base content models
156201// ================================================================
@@ -612,14 +657,13 @@ impl AssistantContent {
612657 name : impl Into < String > ,
613658 arguments : serde_json:: Value ,
614659 ) -> Self {
615- AssistantContent :: ToolCall ( ToolCall {
616- id : id. into ( ) ,
617- call_id : None ,
618- function : ToolFunction {
660+ AssistantContent :: ToolCall ( ToolCall :: new (
661+ id. into ( ) ,
662+ ToolFunction {
619663 name : name. into ( ) ,
620664 arguments,
621665 } ,
622- } )
666+ ) )
623667 }
624668
625669 pub fn tool_call_with_call_id (
@@ -628,14 +672,16 @@ impl AssistantContent {
628672 name : impl Into < String > ,
629673 arguments : serde_json:: Value ,
630674 ) -> Self {
631- AssistantContent :: ToolCall ( ToolCall {
632- id : id. into ( ) ,
633- call_id : Some ( call_id) ,
634- function : ToolFunction {
635- name : name. into ( ) ,
636- arguments,
637- } ,
638- } )
675+ AssistantContent :: ToolCall (
676+ ToolCall :: new (
677+ id. into ( ) ,
678+ ToolFunction {
679+ name : name. into ( ) ,
680+ arguments,
681+ } ,
682+ )
683+ . with_call_id ( call_id) ,
684+ )
639685 }
640686
641687 pub fn reasoning ( reasoning : impl AsRef < str > ) -> Self {
0 commit comments