pub struct ToolExecutionContext<'a> {
pub session_id: Option<&'a str>,
pub tool_call_id: &'a str,
pub event_tx: Option<&'a Sender<AgentEvent>>,
pub available_tool_schemas: Option<&'a [ToolSchema]>,
pub bypass_permissions: bool,
}Expand description
Context passed to tools during execution.
All fields are optional and should be treated as best-effort hints.
⚠️ Real tool dispatch must build this via ToolExecutionContext::for_dispatch
(both agent loops do), NOT a struct literal — that routes every per-session
flag through ToolExecutionSessionFlags so a new flag can’t be wired into
one loop and silently skipped in the other. Struct literals are for tests
and tools that synthesize a child context.
Fields§
§session_id: Option<&'a str>Bamboo session id that is executing the tool.
tool_call_id: &'a strTool call id from the model (ToolCall.id).
event_tx: Option<&'a Sender<AgentEvent>>Event sender for streaming progress to clients (agent SSE stream).
available_tool_schemas: Option<&'a [ToolSchema]>Snapshot of tools currently available to the executing session.
bypass_permissions: boolWhen true, the executing session is in “bypass permissions” mode, so
tool permission checks are skipped. Sourced per-session from the
session’s runtime state (runtime.json), not the global checker.
Implementations§
Source§impl<'a> ToolExecutionContext<'a>
impl<'a> ToolExecutionContext<'a>
pub fn none(tool_call_id: &'a str) -> ToolExecutionContext<'a>
Sourcepub fn for_dispatch(
session_id: &'a str,
tool_call_id: &'a str,
event_tx: &'a Sender<AgentEvent>,
available_tool_schemas: &'a [ToolSchema],
flags: ToolExecutionSessionFlags,
) -> ToolExecutionContext<'a>
pub fn for_dispatch( session_id: &'a str, tool_call_id: &'a str, event_tx: &'a Sender<AgentEvent>, available_tool_schemas: &'a [ToolSchema], flags: ToolExecutionSessionFlags, ) -> ToolExecutionContext<'a>
Build a context for a real tool dispatch, applying every per-session flag
from ToolExecutionSessionFlags. This is the SINGLE place that maps
session flags onto the context, and the only constructor the agent loops
use — keep both loops (per_call.rs, result_handler.rs) on it so a new
per-session field reaches all dispatch paths without per-site edits.
Sourcepub fn cloned_sender(&self) -> Option<Sender<AgentEvent>>
pub fn cloned_sender(&self) -> Option<Sender<AgentEvent>>
Clone the sender (when present) for use in spawned tasks.
Sourcepub async fn emit(&self, event: AgentEvent)
pub async fn emit(&self, event: AgentEvent)
Best-effort emit of an event (ignored if no sender).
Sourcepub async fn emit_tool_token(&self, content: impl Into<String>)
pub async fn emit_tool_token(&self, content: impl Into<String>)
Convenience helper for streaming tool-scoped output.
Trait Implementations§
Source§impl<'a> Clone for ToolExecutionContext<'a>
impl<'a> Clone for ToolExecutionContext<'a>
Source§fn clone(&self) -> ToolExecutionContext<'a>
fn clone(&self) -> ToolExecutionContext<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more