pub struct SimpleToolContext { /* private fields */ }Expand description
A lightweight ToolContext with sensible defaults for non-agent callers.
Implements ReadonlyContext, CallbackContext, and ToolContext
with minimal configuration. Construct via SimpleToolContext::new with
a caller name; all other fields use safe defaults.
Implementations§
Source§impl SimpleToolContext
impl SimpleToolContext
Sourcepub fn new(caller_name: impl Into<String>) -> Self
pub fn new(caller_name: impl Into<String>) -> Self
Create a new context with the given caller name.
Generates unique UUIDs for invocation_id and function_call_id.
The caller name is returned by both agent_name()
and app_name().
Sourcepub fn with_function_call_id(self, id: impl Into<String>) -> Self
pub fn with_function_call_id(self, id: impl Into<String>) -> Self
Override the default function call ID.
By default a UUID is generated at construction. Use this builder method to provide a specific ID instead.
Trait Implementations§
Source§impl CallbackContext for SimpleToolContext
impl CallbackContext for SimpleToolContext
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 SimpleToolContext
impl ReadonlyContext for SimpleToolContext
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 moreSource§impl ToolContext for SimpleToolContext
impl ToolContext for SimpleToolContext
fn function_call_id(&self) -> &str
Source§fn actions(&self) -> EventActions
fn actions(&self) -> EventActions
Get the current event actions. Returns an owned copy for thread safety.
Source§fn set_actions(&self, actions: EventActions)
fn set_actions(&self, actions: EventActions)
Set the event actions (e.g., to trigger escalation or skip summarization).
fn search_memory<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !Freeze for SimpleToolContext
impl RefUnwindSafe for SimpleToolContext
impl Send for SimpleToolContext
impl Sync for SimpleToolContext
impl Unpin for SimpleToolContext
impl UnsafeUnpin for SimpleToolContext
impl UnwindSafe for SimpleToolContext
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> 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