pub struct ToolCallbackContext {
pub inner: Arc<dyn CallbackContext>,
pub tool_name: String,
pub tool_input: Value,
}Expand description
Wraps a CallbackContext to inject tool name and input for before-tool
and after-tool callbacks.
Used by the agent runtime to provide tool context to BeforeToolCallback
and AfterToolCallback invocations.
§Example
ⓘ
let tool_ctx = Arc::new(ToolCallbackContext::new(
ctx.clone(),
"search".to_string(),
serde_json::json!({"query": "hello"}),
));
callback(tool_ctx as Arc<dyn CallbackContext>).await;Fields§
§inner: Arc<dyn CallbackContext>The inner callback context to delegate to.
tool_name: StringThe name of the tool being executed.
tool_input: ValueThe input arguments for the tool being executed.
Implementations§
Source§impl ToolCallbackContext
impl ToolCallbackContext
Sourcepub fn new(
inner: Arc<dyn CallbackContext>,
tool_name: String,
tool_input: Value,
) -> ToolCallbackContext
pub fn new( inner: Arc<dyn CallbackContext>, tool_name: String, tool_input: Value, ) -> ToolCallbackContext
Creates a new ToolCallbackContext wrapping the given inner context.
Trait Implementations§
Source§impl CallbackContext for ToolCallbackContext
impl CallbackContext for ToolCallbackContext
fn artifacts(&self) -> Option<Arc<dyn Artifacts>>
Source§fn tool_outcome(&self) -> Option<ToolOutcome>
fn tool_outcome(&self) -> Option<ToolOutcome>
Returns structured metadata about the most recent tool execution.
Available in after-tool callbacks and plugin hooks.
Returns
None when not in a tool execution context.Source§fn tool_name(&self) -> Option<&str>
fn tool_name(&self) -> Option<&str>
Returns the name of the tool about to be executed.
Available in before-tool and after-tool callback contexts.
Source§fn tool_input(&self) -> Option<&Value>
fn tool_input(&self) -> Option<&Value>
Returns the input arguments for the tool about to be executed.
Available in before-tool and after-tool callback contexts.
Returns the shared state for parallel agent coordination.
Returns
None when not running inside a ParallelAgent with shared state enabled.Source§impl ReadonlyContext for ToolCallbackContext
impl ReadonlyContext for ToolCallbackContext
fn invocation_id(&self) -> &str
fn agent_name(&self) -> &str
fn user_id(&self) -> &str
fn app_name(&self) -> &str
fn session_id(&self) -> &str
fn branch(&self) -> &str
fn user_content(&self) -> &Content
Source§fn try_invocation_id(&self) -> Result<InvocationId, AdkError>
fn try_invocation_id(&self) -> Result<InvocationId, AdkError>
Returns the invocation identifier as a typed
InvocationId. Read moreSource§fn try_identity(&self) -> Result<AdkIdentity, AdkError>
fn try_identity(&self) -> Result<AdkIdentity, AdkError>
Returns the stable session-scoped
AdkIdentity triple. Read moreSource§fn try_execution_identity(&self) -> Result<ExecutionIdentity, AdkError>
fn try_execution_identity(&self) -> Result<ExecutionIdentity, AdkError>
Returns the full per-invocation
ExecutionIdentity. Read moreAuto Trait Implementations§
impl Freeze for ToolCallbackContext
impl !RefUnwindSafe for ToolCallbackContext
impl Send for ToolCallbackContext
impl Sync for ToolCallbackContext
impl Unpin for ToolCallbackContext
impl UnsafeUnpin for ToolCallbackContext
impl !UnwindSafe for ToolCallbackContext
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::RequestCreates a shared type from an unshared type.