Skip to main content

ToolOutput

Trait ToolOutput 

Source
pub trait ToolOutput: Send {
    // Required methods
    fn log_preview(&self) -> String;
    fn success_for_logging(&self) -> bool;
    fn to_response_item(
        &self,
        call_id: &str,
        payload: &ToolPayload,
    ) -> ResponseInputItem;

    // Provided methods
    fn contains_external_context(&self) -> bool { ... }
    fn post_tool_use_id(&self, call_id: &str) -> String { ... }
    fn post_tool_use_input(&self, _payload: &ToolPayload) -> Option<Value> { ... }
    fn post_tool_use_response(
        &self,
        _call_id: &str,
        _payload: &ToolPayload,
    ) -> Option<Value> { ... }
    fn code_mode_result(&self, payload: &ToolPayload) -> Value { ... }
}
Expand description

Model-facing output contract returned by executable tool runtimes.

Required Methods§

Provided Methods§

Source

fn contains_external_context(&self) -> bool

Whether this output contains external context that should disable memory generation when memories.disable_on_external_context is enabled.

Source

fn post_tool_use_id(&self, call_id: &str) -> String

Returns the tool call id exposed to PostToolUse hooks for this output.

Source

fn post_tool_use_input(&self, _payload: &ToolPayload) -> Option<Value>

Returns the tool input exposed to PostToolUse hooks for this output.

Source

fn post_tool_use_response( &self, _call_id: &str, _payload: &ToolPayload, ) -> Option<Value>

Returns the stable value exposed to PostToolUse hooks for this tool output.

Tool handlers decide whether a tool participates in PostToolUse, but this method lets the output type own any conversion from model-facing response content to hook-facing data. Returning None means the output should not produce a post-use hook payload, not merely that the tool had empty output.

Source

fn code_mode_result(&self, payload: &ToolPayload) -> Value

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToolOutput for CallToolResult

Source§

impl<T> ToolOutput for Box<T>
where T: ToolOutput + ?Sized,

Implementors§