pub struct ToolResultToState { /* private fields */ }Expand description
Promotes a named tool’s result into a state event.
A tool whose job is to produce state — load_document, set_filters —
otherwise forces the agent to emit the result and then publish the state by
hand. This transformer does it: when tool_name returns, its JSON content
becomes a STATE_SNAPSHOT or a STATE_DELTA.
The result event is kept by default so the client still sees the tool
completed; replacing drops it instead. Content that is
not JSON of the expected shape is left alone — a malformed result must not
take down the run.
let mut promote = ToolResultToState::snapshot("load_document").replacing();
promote.transform(Event::tool_call_start("c1", "load_document"));
let out = promote.transform(Event::tool_call_result("m1", "c1", r#"{"title":"Notes"}"#));
assert_eq!(out, vec![Event::state_snapshot(serde_json::json!({"title": "Notes"}))]);Implementations§
Source§impl ToolResultToState
impl ToolResultToState
Trait Implementations§
Source§impl Clone for ToolResultToState
impl Clone for ToolResultToState
Source§fn clone(&self) -> ToolResultToState
fn clone(&self) -> ToolResultToState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolResultToState
impl Debug for ToolResultToState
Auto Trait Implementations§
impl Freeze for ToolResultToState
impl RefUnwindSafe for ToolResultToState
impl Send for ToolResultToState
impl Sync for ToolResultToState
impl Unpin for ToolResultToState
impl UnsafeUnpin for ToolResultToState
impl UnwindSafe for ToolResultToState
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
Mutably borrows from an owned value. Read more