pub struct ToolContext {
pub session_id: SessionId,
pub user_event_tx: UnboundedSender<UserEvent>,
pub llm_client: Option<Arc<dyn LlmProvider>>,
pub session_store: Option<Arc<dyn SessionStore>>,
pub language: Language,
pub cancel_token: CancellationToken,
pub max_output_chars: Option<usize>,
/* private fields */
}Fields§
§session_id: SessionId§user_event_tx: UnboundedSender<UserEvent>Channel for sending user-space events (progress, sub-agent, structured).
Tools should use emit_user_event() or emit_progress().
llm_client: Option<Arc<dyn LlmProvider>>§session_store: Option<Arc<dyn SessionStore>>§language: LanguageLanguage preference for tool output.
Defaults to Language::En if not set.
cancel_token: CancellationTokenCancellation token for checking if the operation should be cancelled.
max_output_chars: Option<usize>Output budget for this call, in characters (set from the engine’s
max_tool_output_chars). Tools that can return large results (e.g.
read_file) should self-truncate to this bound and mark the cut, so
the engine’s hard reject (§6.5) never fires for a paginated read.
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn emit_user_event(&self, event: UserEvent)
pub fn emit_user_event(&self, event: UserEvent)
Send a user-space event (progress, sub-agent forwarding, structured data).
Dual-write: the event goes to user_event_tx (the tool select arm
renders it in real time) and to the event bus for external subscribers
(bridge remote clients, persistence). The bus copy carries agent_id: None — the self-echo marker — so bus loopback drops it instead of
re-rendering (see crate::engine::runtime::is_self_echo_user_event).
Sourcepub fn emit_progress(&self, text: impl Into<String>)
pub fn emit_progress(&self, text: impl Into<String>)
Convenience: send a progress event with text.