Skip to main content

ToolCallContext

Struct ToolCallContext 

Source
pub struct ToolCallContext {
Show 30 fields pub mandate_preapproved: bool, pub mandate_execution: bool, pub mutation_forbidden: bool, pub kernel_approved: Option<ApprovalScope>, pub trusted_session: bool, pub user_role: Option<UserRole>, pub untrusted_source: bool, pub scope_escalation: Option<ScopeEscalation>, pub session_id: String, pub grant_session: String, pub channel_visibility: Option<ChannelVisibility>, pub channel_id: Option<String>, pub task_id: Option<String>, pub tool_call_id: Option<String>, pub lone_root_call: bool, pub turn_id: Option<String>, pub goal_id: Option<String>, pub goal_run_id: Option<String>, pub task_attempt_id: Option<String>, pub mandate_id: Option<String>, pub mandate_version: Option<i64>, pub project_scope: Option<String>, pub project: Option<ProjectRef>, pub workspace_collaboration_root: Option<String>, pub trust_roots: Option<Vec<String>>, pub trust_cwd: Option<String>, pub model: Option<String>, pub provider_kind: Option<String>, pub model_chain: Option<Vec<String>>, pub extensions: Extensions,
}
Expand description

The dispatcher’s facts about one tool call, passed to the tool beside its arguments.

This is a Rust-side control-plane type: it is NEVER serialized and never appears in model-visible JSON, tool schemas, logs, or persisted tool arguments. Every fact about who is calling, from where, and under what authority lives here and only here: a tool’s arguments are the model’s own, and the dispatcher strips any _-prefixed key a model sends.

Fields§

§mandate_preapproved: bool

True only after the final common dispatcher revalidated an exact, action-bound MandateAuthorityGrant for this mutating call, so tools can honor owner-delegated autonomy.

§mandate_execution: bool

True only when the common dispatcher resolved this call to an active autonomous mandate. Network adapters use this control-plane bit to keep one target-bound call from following redirects outside the target that was evaluated by the mandate authority kernel.

§mutation_forbidden: bool

Hard negative task contract propagated from the validated request. Open-ended adapters must prove an operation is observational before I/O.

§kernel_approved: Option<ApprovalScope>

What the agent kernel approved, set only by the dispatcher (never from arguments): Call for a call that came through the kernel, whose ApprovalPolicy already asked the owner where the daemon’s rules require it; Request for one exact inner request an approved outer call makes. A tool that needs the owner’s approval refuses a call without a matching scope rather than asking itself.

§trusted_session: bool

The turn is a trusted scheduled session (never one under a mandate), set only by the dispatcher from the channel context and the goal’s provenance.

§user_role: Option<UserRole>

The role of the turn’s user (None outside the dispatcher: an unknown caller is not the owner).

§untrusted_source: bool

The session was started by an automated trigger (an email, an event), not by the owner.

§scope_escalation: Option<ScopeEscalation>

Exact out-of-scope targets the controller routed to the owner’s approval instead of refusing them.

§session_id: String

The session the call belongs to (empty outside the dispatcher).

§grant_session: String

The session whose owner approvals cover this call: the chat that started the work. A sub-agent runs in a session of its own but works for that chat, so a tool’s own session-scoped grants (“allow for session”) key on this, never on session_id. Empty: session_id.

§channel_visibility: Option<ChannelVisibility>

Visibility of the channel the turn came from (None outside the dispatcher; each tool keeps its own fallback).

§channel_id: Option<String>

The channel the turn came from, when the channel has an id.

§task_id: Option<String>

The task the call runs under.

§tool_call_id: Option<String>

The model’s id for this tool call.

§lone_root_call: bool

The call is the only one in a root turn’s model response, so a reply the tool finishes the run with answers the user’s request directly.

§turn_id: Option<String>

The session’s current turn.

§goal_id: Option<String>

The goal the call serves: the agent’s goal, or (for cli_agent and terminal) the goal of the executor’s task, so background notifications reach the origin session.

§goal_run_id: Option<String>

The goal run of the mandate fence the call runs under.

§task_attempt_id: Option<String>

The task attempt of the mandate fence the call runs under.

§mandate_id: Option<String>

The mandate of the fence the call runs under.

§mandate_version: Option<i64>

The mandate version of the fence the call runs under.

§project_scope: Option<String>

The single project the turn is scoped to.

§project: Option<ProjectRef>

The project the owner’s turn works in (an app project, a chat placed in one), set only by the dispatcher from typed turn state. None for guests, public channels and mandate runs: project-scoped writes (a memory tool’s project notes) key on it.

§workspace_collaboration_root: Option<String>

A guest’s granted workspace root (only under an active grant).

§trust_roots: Option<Vec<String>>

The turn’s trusted file roots (set for terminal), so a run moved to the background records the trust its launch was judged with.

§trust_cwd: Option<String>

The cwd relative paths resolve against for Self::trust_roots.

§model: Option<String>

The live model (set for computer_use).

§provider_kind: Option<String>

The provider kind behind Self::model, as the daemon names it.

§model_chain: Option<Vec<String>>

The router’s models in order, when a router is configured.

§extensions: Extensions

Application facts whose types cannot live in the SDK (they depend on the application’s configuration), read by the tool that needs them through a typed getter.

Implementations§

Source§

impl ToolCallContext

Source

pub fn session(&self) -> Option<&str>

The session id, or None when the call carries none.

Source

pub fn grants_session(&self) -> &str

The session a tool’s own session-scoped grants key on (Self::grant_session, else the call’s session).

Trait Implementations§

Source§

impl Clone for ToolCallContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolCallContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ToolCallContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<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