pub struct ToolPermissionContext {
pub tool_name: String,
pub tool_input: Value,
pub tool_use_id: String,
pub agent_id: Option<String>,
pub suggestions: Vec<PermissionUpdate>,
pub blocked_path: Option<String>,
pub decision_reason: Option<String>,
pub title: Option<String>,
pub display_name: Option<String>,
pub description: Option<String>,
}Fields§
§tool_name: StringThe tool the model wants to invoke (e.g. "Edit", "Bash").
tool_input: ValueThe JSON input the model generated for the call.
tool_use_id: StringIdentifier of THIS tool call (always present - used to correlate
with the subsequent ToolResult in the stream). Matches the wire
tool_use_id field.
agent_id: Option<String>Sub-agent identifier when the request came from a Task-spawned
child agent. None for main-agent tool calls.
suggestions: Vec<PermissionUpdate>Permission-rule suggestions the CLI attached to this request.
Typically populated when the user has in-flight workspace
permission prompts. Wire shape:
ToolPermissionContext.suggestions - populated
from the control_request’s permission_suggestions list, with
unrecognised entries dropped.
blocked_path: Option<String>Path the CLI considered out-of-bounds when rejecting the tool
call (e.g. an Edit against a file outside the workspace).
None when the request is not path-scoped or the CLI didn’t
supply a value.
decision_reason: Option<String>Free-form reason the CLI surfaced for why the request needs
human review (e.g. "workspace not yet trusted"). Pass-through
for UIs that show it verbatim.
title: Option<String>Short title the CLI suggests for the prompt (e.g. "Run tests").
display_name: Option<String>Display name for the tool call (often a humanised tool name).
description: Option<String>Long-form description the CLI suggests as additional context in the prompt body.
Implementations§
Source§impl ToolPermissionContext
impl ToolPermissionContext
Sourcepub fn new(
tool_name: impl Into<String>,
tool_input: Value,
tool_use_id: impl Into<String>,
agent_id: Option<String>,
) -> Self
pub fn new( tool_name: impl Into<String>, tool_input: Value, tool_use_id: impl Into<String>, agent_id: Option<String>, ) -> Self
Construct a context. suggestions defaults to empty; use
with_suggestions to attach parsed
permission-rule hints.
Sourcepub fn with_suggestions(self, suggestions: Vec<PermissionUpdate>) -> Self
pub fn with_suggestions(self, suggestions: Vec<PermissionUpdate>) -> Self
Attach permission-rule suggestions parsed from the control
request’s permission_suggestions field.
Sourcepub fn with_display(
self,
blocked_path: Option<String>,
decision_reason: Option<String>,
title: Option<String>,
display_name: Option<String>,
description: Option<String>,
) -> Self
pub fn with_display( self, blocked_path: Option<String>, decision_reason: Option<String>, title: Option<String>, display_name: Option<String>, description: Option<String>, ) -> Self
Attach the optional display fields the CLI surfaces alongside
tool_name / tool_input so UIs can render rich permission
prompts (“the agent wants to <title>: <description>”). Each field
is independently optional; callers pass None for ones the CLI
didn’t populate.