pub struct ToolContext {Show 14 fields
pub project_root: String,
pub minimal: bool,
pub resolved_paths: HashMap<String, String>,
pub crp_mode: CrpMode,
pub cache: Option<SharedCache>,
pub session: Option<Arc<RwLock<SessionState>>>,
pub tool_calls: Option<Arc<RwLock<Vec<ToolCallRecord>>>>,
pub agent_id: Option<Arc<RwLock<Option<String>>>>,
pub workflow: Option<Arc<RwLock<Option<WorkflowRun>>>>,
pub ledger: Option<Arc<RwLock<ContextLedger>>>,
pub client_name: Option<Arc<RwLock<String>>>,
pub pipeline_stats: Option<Arc<RwLock<PipelineStats>>>,
pub call_count: Option<Arc<AtomicUsize>>,
pub autonomy: Option<Arc<AutonomyState>>,
}Expand description
Context passed to tool handlers. Contains pre-resolved values that many tools need, avoiding repeated async lock acquisition inside handlers. Extended with shared server state for tools that need cache/session access.
Fields§
§project_root: String§minimal: bool§resolved_paths: HashMap<String, String>Pre-resolved paths keyed by argument name (e.g. “path” -> “/abs/dir”).
crp_mode: CrpModeCRP mode for compression-aware tools.
cache: Option<SharedCache>Shared cache handle for tools that need read/write access.
session: Option<Arc<RwLock<SessionState>>>Shared session handle for tools that need session access.
tool_calls: Option<Arc<RwLock<Vec<ToolCallRecord>>>>Tool call records for session-aware tools (e.g. ctx_session status).
agent_id: Option<Arc<RwLock<Option<String>>>>Current agent identity for multi-agent tools.
workflow: Option<Arc<RwLock<Option<WorkflowRun>>>>Active workflow run state.
ledger: Option<Arc<RwLock<ContextLedger>>>Context ledger for handoff operations.
client_name: Option<Arc<RwLock<String>>>Client name (cursor, claude, etc.).
pipeline_stats: Option<Arc<RwLock<PipelineStats>>>Pipeline stats for metrics/proof tools.
call_count: Option<Arc<AtomicUsize>>Global call counter for context tools.
autonomy: Option<Arc<AutonomyState>>Autonomy state for search repeat detection.
Implementations§
Source§impl ToolContext
impl ToolContext
Auto Trait Implementations§
impl Freeze for ToolContext
impl !RefUnwindSafe for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContext
impl !UnwindSafe for ToolContext
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more