pub enum AgentEvent {
Thought(String),
Action {
tool: String,
input: String,
},
Observation(String),
Result(String),
Error(String),
}Expand description
A single event emitted by a running agent.
Each variant maps to one stage of the ReAct loop or to an error condition.
Serialises to a JSON object with a "type" discriminant field, e.g.:
{"type":"thought","content":"I should search the web."}
{"type":"action","tool":"search","input":"{\"q\":\"Rust\"}"}
{"type":"observation","content":"Rust is a systems language."}
{"type":"result","content":"The answer is 42."}
{"type":"error","content":"Tool not found: foobar"}Variants§
Thought(String)
A reasoning thought produced before taking an action.
Action
An action dispatched to a tool.
Fields
Observation(String)
An observation returned by a tool after an action.
Result(String)
The final result produced by the agent.
Error(String)
An error that occurred during agent execution.
Implementations§
Source§impl AgentEvent
impl AgentEvent
Sourcepub fn to_sse(&self) -> Result<String, AgentRuntimeError>
pub fn to_sse(&self) -> Result<String, AgentRuntimeError>
Serialise the event to an SSE-formatted string: data: {json}\n\n.
Returns an error only if serde_json fails to serialise the value,
which cannot happen for this well-formed enum in practice.
Sourcepub fn event_type(&self) -> &'static str
pub fn event_type(&self) -> &'static str
Return a short machine-readable event type label.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Return true if this is a terminal event (result or error).
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
Returns a duplicate of the value. Read more
1.0.0 · 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 AgentEvent
impl Debug for AgentEvent
Source§impl<'de> Deserialize<'de> for AgentEvent
impl<'de> Deserialize<'de> for AgentEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AgentEvent
impl PartialEq for AgentEvent
Source§impl Serialize for AgentEvent
impl Serialize for AgentEvent
impl Eq for AgentEvent
impl StructuralPartialEq for AgentEvent
Auto Trait Implementations§
impl Freeze for AgentEvent
impl RefUnwindSafe for AgentEvent
impl Send for AgentEvent
impl Sync for AgentEvent
impl Unpin for AgentEvent
impl UnsafeUnpin for AgentEvent
impl UnwindSafe for AgentEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.