pub struct ToolCallContext {Show 31 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 user_message: 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: boolTrue 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: boolTrue 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: boolHard 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: boolThe 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: boolThe 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: StringThe session the call belongs to (empty outside the dispatcher).
grant_session: StringThe 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.
user_message: Option<String>The owner/user message text of this turn (control-plane only; used for
synchronous provenance verification in remember_fact).
tool_call_id: Option<String>The model’s id for this tool call.
lone_root_call: boolThe 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: ExtensionsApplication 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
impl ToolCallContext
Sourcepub fn grants_session(&self) -> &str
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).
Sourcepub fn scoped_grants(&self) -> Arc<ScopedGrants> ⓘ
pub fn scoped_grants(&self) -> Arc<ScopedGrants> ⓘ
The typed-scope grants the owner gave the work this call is part of
(Self::grants_session: the chat, shared by its sub-agents). The
runtime checks them before asking about a call whose tool offers a
reusable scope (crate::OutcomeTool::approval_grant); a tool may
read them too.