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§
Trait Implementations§
Source§impl CallbackContext for ToolCallbackContext
impl CallbackContext for ToolCallbackContext
Source§fn artifacts(&self) -> Option<Arc<dyn Artifacts>>
fn artifacts(&self) -> Option<Arc<dyn Artifacts>>
Returns the artifact store, if one is configured.
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
Source§fn invocation_id(&self) -> &str
fn invocation_id(&self) -> &str
Returns the current invocation identifier.
Source§fn agent_name(&self) -> &str
fn agent_name(&self) -> &str
Returns the name of the currently executing agent.
Source§fn session_id(&self) -> &str
fn session_id(&self) -> &str
Returns the session identifier.
Source§fn user_content(&self) -> &Content
fn user_content(&self) -> &Content
Returns the user’s input content for this invocation.
Source§fn try_app_name(&self) -> Result<AppName>
fn try_app_name(&self) -> Result<AppName>
Source§fn try_user_id(&self) -> Result<UserId>
fn try_user_id(&self) -> Result<UserId>
Source§fn try_session_id(&self) -> Result<SessionId>
fn try_session_id(&self) -> Result<SessionId>
Source§fn try_invocation_id(&self) -> Result<InvocationId>
fn try_invocation_id(&self) -> Result<InvocationId>
Returns the invocation identifier as a typed
InvocationId. Read moreSource§fn try_identity(&self) -> Result<AdkIdentity>
fn try_identity(&self) -> Result<AdkIdentity>
Returns the stable session-scoped
AdkIdentity triple. Read moreSource§fn try_execution_identity(&self) -> Result<ExecutionIdentity>
fn try_execution_identity(&self) -> Result<ExecutionIdentity>
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