Skip to main content

ToolPermissionContext

Struct ToolPermissionContext 

Source
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: String

The tool the model wants to invoke (e.g. "Edit", "Bash").

§tool_input: Value

The JSON input the model generated for the call.

§tool_use_id: String

Identifier 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

Source

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.

Source

pub fn with_suggestions(self, suggestions: Vec<PermissionUpdate>) -> Self

Attach permission-rule suggestions parsed from the control request’s permission_suggestions field.

Source

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.

Trait Implementations§

Source§

impl Clone for ToolPermissionContext

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 ToolPermissionContext

Source§

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

Formats the value using the given formatter. 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more