pub enum AgentMessage {
Llm(LlmMessage),
Custom(Box<dyn CustomMessage>),
}Expand description
The top-level message type that wraps either an LLM message or a custom application-defined message.
Implements Serialize so events containing messages can be forwarded
across process boundaries. Llm variants delegate to the derived impl;
Custom variants serialize via serialize_custom_message (or as
null if the custom message does not support serialization).
Variants§
Llm(LlmMessage)
A standard LLM message (user, assistant, or tool result).
Custom(Box<dyn CustomMessage>)
A custom application-defined message.
Implementations§
Source§impl AgentMessage
impl AgentMessage
Sourcepub const fn cache_hint(&self) -> Option<&CacheHint>
pub const fn cache_hint(&self) -> Option<&CacheHint>
Get the cache hint for this message (if any).
Returns None for Custom messages (they are never sent to the LLM).
Sourcepub const fn set_cache_hint(&mut self, hint: CacheHint)
pub const fn set_cache_hint(&mut self, hint: CacheHint)
Set the cache hint on this message.
No-op for Custom messages.
Sourcepub const fn clear_cache_hint(&mut self)
pub const fn clear_cache_hint(&mut self)
Clear the cache hint on this message.
Sourcepub fn downcast_ref<T: 'static>(&self) -> Result<&T, DowncastError>
pub fn downcast_ref<T: 'static>(&self) -> Result<&T, DowncastError>
Attempt to downcast the inner custom message to a concrete type.
Returns Ok(&T) if this is a Custom variant and the inner type matches T.
Returns Err(DowncastError) if this is an Llm variant or the type does not match.