Hook Result • Rust AI Agent SDK

HookResult: Result from a hook execution

HookResult

Defined in the hooks module.

Rust AI Agent SDK

Result from a hook execution

Diagram

Allow

Deny

Event Trigger

Hook: HookResult

Decision

Process

Block

Fields

NameTypeDescription
decisionHookDecisionDecision (allow, deny, block, ask)
reasonOption<String>Reason for the decision
modified_inputOption<HashMap<StringModified input data (optional)
serde_json:Value>>Modified input data (optional)
additional_contextOption<String>Additional context
suppress_outputboolWhether to suppress output

Methods

allow

rust
fn allow() -> Self

Create an allow result

allow_with_reason

rust
fn allow_with_reason(reason: impl Into<String>) -> Self

Create an allow result with reason

Parameters:

NameType
reasonimpl Into&lt;String&gt;

deny

rust
fn deny(reason: impl Into<String>) -> Self

Create a deny result

Parameters:

NameType
reasonimpl Into&lt;String&gt;

block

rust
fn block(reason: impl Into<String>) -> Self

Create a block result

Parameters:

NameType
reasonimpl Into&lt;String&gt;

ask

rust
fn ask(reason: impl Into<String>) -> Self

Create an ask result

Parameters:

NameType
reasonimpl Into&lt;String&gt;

is_allowed

rust
fn is_allowed(&self) -> bool

Check if the result allows execution

is_denied

rust
fn is_denied(&self) -> bool

Check if the result denies execution

with_modified_input

rust
fn with_modified_input(mut self, input: HashMap<String, serde_json::Value>) -> Self

Add modified input

Parameters:

NameType
inputHashMap&lt;String
serde_json:Value&gt;

with_context

rust
fn with_context(mut self, context: impl Into<String>) -> Self

Add additional context

Parameters:

NameType
contextimpl Into&lt;String&gt;

suppress

rust
fn suppress(mut self) -> Self

Suppress output

Source

View on GitHub

praisonai/src/hooks/mod.rs at line 177


Related Documentation