pub struct ToolOutput {
pub content: Vec<ContentPart>,
pub structured_content: Option<Value>,
pub metadata: BTreeMap<String, Value>,
pub is_error: bool,
pub model_visible: bool,
}Expand description
Successful canonical tool output.
Fields§
§content: Vec<ContentPart>Ordered model-visible presentation content.
structured_content: Option<Value>Optional structured output value used for contract validation and by protocols that support a separate structured result channel.
metadata: BTreeMap<String, Value>Namespaced host metadata retained across Agent and protocol bridges.
is_error: boolWhether execution completed with a model-visible application error.
model_visible: boolWhether the value is safe to expose verbatim to a model.
Implementations§
Source§impl ToolOutput
impl ToolOutput
Sourcepub fn model_visible(value: Value) -> Self
pub fn model_visible(value: Value) -> Self
Creates model-visible output from a JSON value.
JSON values are retained as structured content and mirrored as text for providers that only accept textual function results.
Sourcepub fn rich(content: Vec<ContentPart>) -> Self
pub fn rich(content: Vec<ContentPart>) -> Self
Creates a model-visible rich result.
Sourcepub fn with_structured_content(self, value: Value) -> Self
pub fn with_structured_content(self, value: Value) -> Self
Attaches a structured value alongside the presentation content.
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Adds namespaced host metadata.
Sourcepub fn host_only(content: Vec<ContentPart>) -> Self
pub fn host_only(content: Vec<ContentPart>) -> Self
Creates host-only output that must not be exposed to a model.
Sourcepub fn model_error(content: Vec<ContentPart>) -> Self
pub fn model_error(content: Vec<ContentPart>) -> Self
Creates a rich, model-visible application error result.
Trait Implementations§
Source§impl Clone for ToolOutput
impl Clone for ToolOutput
Source§fn clone(&self) -> ToolOutput
fn clone(&self) -> ToolOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more