pub enum ToolOutput {
Text(String),
Blocks {
blocks: Vec<Value>,
summary: String,
},
}Expand description
Structured tool output. Text is the legacy contract (what execute
returns). Blocks carries Anthropic-shaped content blocks destined for
tool_result.content, plus a plain-text summary used everywhere a
String is expected today: UI preview, after_tool_call hooks, trace
ledger byte counts, headless logs, and providers that cannot carry the
blocks. INVARIANT: blocks[0] MUST be a {"type":"text"} block whose
text == summary (compaction reads blocks[0].text; non-Anthropic
translators join only text sub-blocks).
Variants§
Implementations§
Source§impl ToolOutput
impl ToolOutput
pub fn summary(&self) -> &str
Sourcepub fn into_parts(self) -> (String, Option<Vec<Value>>)
pub fn into_parts(self) -> (String, Option<Vec<Value>>)
(summary, Some(blocks)) for rich output, (text, None) for plain.
This is the one choke point every rich result passes through, so the
blocks[0] text-first invariant is ENFORCED here in every build: a
Blocks value whose first block is not {"type":"text"} gets a text
block built from summary prepended. Debug builds additionally
assert that an existing leading text block matches summary.
pub fn into_summary(self) -> String
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 moreAuto Trait Implementations§
impl Freeze for ToolOutput
impl RefUnwindSafe for ToolOutput
impl Send for ToolOutput
impl Sync for ToolOutput
impl Unpin for ToolOutput
impl UnsafeUnpin for ToolOutput
impl UnwindSafe for ToolOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.