Skip to main content

ToolUseContext

Struct ToolUseContext 

Source
pub struct ToolUseContext {
Show 42 fields pub options: ToolUseContextOptions, pub abort_signal: Option<()>, pub read_file_state: Option<Arc<dyn Any + Send + Sync>>, pub get_app_state: Box<dyn Fn() -> Box<dyn Any> + Send + Sync>, pub set_app_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>, pub set_app_state_for_tasks: Option<Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>>, pub handle_elicitation: Option<Arc<dyn Fn(String, Value, ()) -> Pin<Box<dyn Future<Output = Value> + Send>> + Send + Sync>>, pub set_tool_jsx: Option<SetToolJsxFn>, pub add_notification: Option<Arc<dyn Fn(Value) + Send + Sync>>, pub append_system_message: Option<Box<dyn Fn(SystemMessage) + Send + Sync>>, pub send_os_notification: Option<Box<dyn Fn(String, String) + Send + Sync>>, pub nested_memory_attachment_triggers: Option<Arc<Mutex<HashSet<String>>>>, pub loaded_nested_memory_paths: Option<Arc<Mutex<HashSet<String>>>>, pub dynamic_skill_dir_triggers: Option<Arc<Mutex<HashSet<String>>>>, pub discovered_skill_names: Option<Arc<Mutex<HashSet<String>>>>, pub user_modified: bool, pub set_in_progress_tool_use_ids: Box<dyn Fn(Box<dyn Fn(&HashSet<String>) -> HashSet<String>>) + Send + Sync>, pub set_has_interruptible_tool_in_progress: Option<Box<dyn Fn(bool) + Send + Sync>>, pub set_response_length: Box<dyn Fn(Box<dyn Fn(usize) -> usize>) + Send + Sync>, pub push_api_metrics_entry: Option<Box<dyn Fn(u64) + Send + Sync>>, pub set_stream_mode: Option<Box<dyn Fn(String) + Send + Sync>>, pub on_compact_progress: Option<Box<dyn Fn(CompactProgressEvent) + Send + Sync>>, pub set_sdk_status: Option<Box<dyn Fn(String) + Send + Sync>>, pub open_message_selector: Option<Box<dyn Fn() + Send + Sync>>, pub update_file_history_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>, pub update_attribution_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>, pub set_conversation_id: Option<Box<dyn Fn(String) + Send + Sync>>, pub agent_id: Option<String>, pub agent_type: Option<String>, pub require_can_use_tool: bool, pub messages: Vec<Message>, pub file_reading_limits: Option<FileReadingLimits>, pub glob_limits: Option<GlobLimits>, pub tool_decisions: Option<Arc<Mutex<HashMap<String, ToolDecisionEntry>>>>, pub query_tracking: Option<QueryChainTracking>, pub request_prompt: Option<Arc<dyn Fn(String, Option<String>) -> Box<dyn Fn(Value) -> Pin<Box<dyn Future<Output = Value> + Send>> + Send> + Send + Sync>>, pub tool_use_id: Option<String>, pub critical_system_reminder_experimental: Option<String>, pub preserve_tool_use_results: bool, pub local_denial_tracking: Option<Arc<Mutex<DenialTrackingState>>>, pub content_replacement_state: Option<Arc<dyn Any + Send + Sync>>, pub rendered_system_prompt: Option<Arc<dyn Any + Send + Sync>>,
}
Expand description

Context passed to tool calls during execution, providing access to configuration, state, callbacks, and other runtime infrastructure.

This mirrors the TypeScript ToolUseContext type.

Fields§

§options: ToolUseContextOptions§abort_signal: Option<()>

Abort signal (placeholder - wired to the consumer’s AbortController).

§read_file_state: Option<Arc<dyn Any + Send + Sync>>§get_app_state: Box<dyn Fn() -> Box<dyn Any> + Send + Sync>§set_app_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>§set_app_state_for_tasks: Option<Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>>§handle_elicitation: Option<Arc<dyn Fn(String, Value, ()) -> Pin<Box<dyn Future<Output = Value> + Send>> + Send + Sync>>§set_tool_jsx: Option<SetToolJsxFn>§add_notification: Option<Arc<dyn Fn(Value) + Send + Sync>>§append_system_message: Option<Box<dyn Fn(SystemMessage) + Send + Sync>>§send_os_notification: Option<Box<dyn Fn(String, String) + Send + Sync>>§nested_memory_attachment_triggers: Option<Arc<Mutex<HashSet<String>>>>§loaded_nested_memory_paths: Option<Arc<Mutex<HashSet<String>>>>§dynamic_skill_dir_triggers: Option<Arc<Mutex<HashSet<String>>>>§discovered_skill_names: Option<Arc<Mutex<HashSet<String>>>>§user_modified: bool§set_in_progress_tool_use_ids: Box<dyn Fn(Box<dyn Fn(&HashSet<String>) -> HashSet<String>>) + Send + Sync>§set_has_interruptible_tool_in_progress: Option<Box<dyn Fn(bool) + Send + Sync>>§set_response_length: Box<dyn Fn(Box<dyn Fn(usize) -> usize>) + Send + Sync>§push_api_metrics_entry: Option<Box<dyn Fn(u64) + Send + Sync>>§set_stream_mode: Option<Box<dyn Fn(String) + Send + Sync>>§on_compact_progress: Option<Box<dyn Fn(CompactProgressEvent) + Send + Sync>>§set_sdk_status: Option<Box<dyn Fn(String) + Send + Sync>>§open_message_selector: Option<Box<dyn Fn() + Send + Sync>>§update_file_history_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>§update_attribution_state: Box<dyn Fn(Box<dyn Fn(Box<dyn Any>) -> Box<dyn Any>>) + Send + Sync>§set_conversation_id: Option<Box<dyn Fn(String) + Send + Sync>>§agent_id: Option<String>§agent_type: Option<String>§require_can_use_tool: bool§messages: Vec<Message>§file_reading_limits: Option<FileReadingLimits>§glob_limits: Option<GlobLimits>§tool_decisions: Option<Arc<Mutex<HashMap<String, ToolDecisionEntry>>>>§query_tracking: Option<QueryChainTracking>§request_prompt: Option<Arc<dyn Fn(String, Option<String>) -> Box<dyn Fn(Value) -> Pin<Box<dyn Future<Output = Value> + Send>> + Send> + Send + Sync>>§tool_use_id: Option<String>§critical_system_reminder_experimental: Option<String>§preserve_tool_use_results: bool§local_denial_tracking: Option<Arc<Mutex<DenialTrackingState>>>§content_replacement_state: Option<Arc<dyn Any + Send + Sync>>§rendered_system_prompt: Option<Arc<dyn Any + Send + Sync>>

Implementations§

Source§

impl ToolUseContext

Source

pub fn stub() -> Self

Create a minimal stub ToolUseContext for callers (like query engine) that don’t have a real one but need one for memory extraction.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more