#[non_exhaustive]pub struct ToolContext {
pub run_id: RunId,
pub session_id: String,
pub call_id: String,
pub turn: u32,
pub cancel: CancellationToken,
pub extensions: Extensions,
pub declines: Option<SharedDeclines>,
pub authority: Option<Authority>,
pub nested: Option<NestedCalls>,
}Expand description
Trusted, harness-provided context for one call.
This is passed beside the model’s arguments rather than injected into them, so a model can never spoof a session id or role by inventing a field.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.run_id: RunId§session_id: String§call_id: String§turn: u32§cancel: CancellationTokenCancelled when the run is cancelled; long tools should watch it.
extensions: ExtensionsApplication values set with crate::AgentBuilder::tool_extensions.
declines: Option<SharedDeclines>The owner’s declines in this run, live. A tool that starts another run shares them with it.
What this run may do, when a hook enforces it. A tool that starts another run must not let it do more.
nested: Option<NestedCalls>Has a call the tool makes on its own (a program it drives asks to
act) judged by the run’s safeguards; see crate::NestedCalls.
None outside a running batch.
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn new(session_id: impl Into<String>, call_id: impl Into<String>) -> Self
pub fn new(session_id: impl Into<String>, call_id: impl Into<String>) -> Self
A context with a fresh run id, turn 0 and a new cancel token. The loop fills in the real values; tests and adapters use this directly.