pub struct FunctionTool { /* private fields */ }Expand description
A tool wrapping a user-provided async closure.
Implementations§
Source§impl FunctionTool
impl FunctionTool
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
parameters: Option<Schema>,
f: Arc<dyn for<'a> Fn(Value, &'a mut ToolContext) -> BoxFuture<'a, Result<Value>> + Send + Sync + 'static>,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, parameters: Option<Schema>, f: Arc<dyn for<'a> Fn(Value, &'a mut ToolContext) -> BoxFuture<'a, Result<Value>> + Send + Sync + 'static>, ) -> Self
Construct.
Sourcepub fn with_long_running(self, yes: bool) -> Self
pub fn with_long_running(self, yes: bool) -> Self
Mark the tool as long-running.
Sourcepub fn require_confirmation(self, yes: bool) -> Self
pub fn require_confirmation(self, yes: bool) -> Self
Require explicit user confirmation before each call (human-in-the-
loop). The agent pauses with an adk_request_confirmation request
instead of dispatching; see crate::core::tool_confirmation.
Sourcepub fn with_confirmation_hint(self, hint: impl Into<String>) -> Self
pub fn with_confirmation_hint(self, hint: impl Into<String>) -> Self
Custom hint shown to the user when confirmation is requested.
Trait Implementations§
Source§impl Debug for FunctionTool
impl Debug for FunctionTool
Source§impl DynTool for FunctionTool
impl DynTool for FunctionTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Human description.
Source§fn is_long_running(&self) -> bool
fn is_long_running(&self) -> bool
Whether this tool yields a long-running operation. Read more
Source§fn requires_confirmation(&self, _args: &Value) -> bool
fn requires_confirmation(&self, _args: &Value) -> bool
Whether this call requires explicit user confirmation before it can
run (human-in-the-loop). When
true, the agent pauses with an
adk_request_confirmation request instead of dispatching the tool;
see crate::core::tool_confirmation. args lets implementations
decide per call (e.g. only confirm destructive operations).Source§fn confirmation_hint(&self, _args: &Value) -> String
fn confirmation_hint(&self, _args: &Value) -> String
Human-readable hint shown to the user when confirmation is
requested. Defaults to a generic message naming the tool.
Source§fn declaration(&self) -> Option<FunctionDeclaration>
fn declaration(&self) -> Option<FunctionDeclaration>
JSON-Schema declaration of the tool’s parameters;
None for tools
(e.g. Gemini built-ins) that should not be advertised to the model.Source§fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 mut ToolContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 mut ToolContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool with JSON args.
Source§fn auth_config(&self) -> Option<&AuthConfig>
fn auth_config(&self) -> Option<&AuthConfig>
Auth requirements for this tool. When
Some, the runner resolves the
credential via crate::auth::CredentialManager before calling
Self::run, and injects the result into
crate::core::ToolContext::auth_credential. When the underlying
flow needs interactive consent the runner emits an
adk_request_credential function-call event instead of dispatching
the tool.Source§fn process_llm_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 mut LlmRequest,
_ctx: &'life2 mut ToolContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn process_llm_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 mut LlmRequest,
_ctx: &'life2 mut ToolContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called before the request is sent. Default: append the tool’s
declaration into
req.config.tools.Auto Trait Implementations§
impl !RefUnwindSafe for FunctionTool
impl !UnwindSafe for FunctionTool
impl Freeze for FunctionTool
impl Send for FunctionTool
impl Sync for FunctionTool
impl Unpin for FunctionTool
impl UnsafeUnpin for FunctionTool
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
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request