pub struct DeepAgent { /* private fields */ }Expand description
Core Deep Agent runtime implementation
This struct contains all the runtime state and behavior for a Deep Agent, including middleware management, tool execution, HITL support, and state persistence.
Implementations§
Source§impl DeepAgent
impl DeepAgent
Sourcepub async fn save_state(&self, thread_id: &String) -> Result<(), Error>
pub async fn save_state(&self, thread_id: &String) -> Result<(), Error>
Save the current agent state to the configured checkpointer.
Sourcepub async fn load_state(&self, thread_id: &String) -> Result<bool, Error>
pub async fn load_state(&self, thread_id: &String) -> Result<bool, Error>
Load agent state from the configured checkpointer.
Sourcepub async fn delete_thread(&self, thread_id: &String) -> Result<(), Error>
pub async fn delete_thread(&self, thread_id: &String) -> Result<(), Error>
Delete saved state for the specified thread.
Sourcepub async fn list_threads(&self) -> Result<Vec<String>, Error>
pub async fn list_threads(&self) -> Result<Vec<String>, Error>
List all threads with saved state.
Sourcepub fn current_interrupt(&self) -> Option<AgentInterrupt>
pub fn current_interrupt(&self) -> Option<AgentInterrupt>
Get the current pending interrupt, if any.
Sourcepub fn add_broadcaster(&self, broadcaster: Arc<dyn EventBroadcaster>)
pub fn add_broadcaster(&self, broadcaster: Arc<dyn EventBroadcaster>)
Add a broadcaster dynamically to the agent’s event dispatcher.
Add a single broadcaster dynamically after the agent is built.
This is useful for per-conversation or per-customer broadcasters.
§Example
use std::sync::Arc;
// agent.add_broadcaster(Arc::new(MyBroadcaster::new()));Sourcepub fn add_broadcasters(&self, broadcasters: Vec<Arc<dyn EventBroadcaster>>)
pub fn add_broadcasters(&self, broadcasters: Vec<Arc<dyn EventBroadcaster>>)
Add multiple broadcasters at once.
This is useful when you need to add several broadcasters for a conversation (e.g., WhatsApp, SSE, DynamoDB).
§Example
use std::sync::Arc;
// agent.add_broadcasters(vec![
// Arc::new(WhatsAppBroadcaster::new(phone)),
// Arc::new(SseBroadcaster::new(channel)),
// Arc::new(DynamoDbBroadcaster::new(table)),
// ]);Sourcepub async fn resume_with_approval(
&self,
action: HitlAction,
) -> Result<AgentMessage, Error>
pub async fn resume_with_approval( &self, action: HitlAction, ) -> Result<AgentMessage, Error>
Resume execution after human approval of an interrupt.
Sourcepub async fn handle_message(
&self,
input: impl AsRef<str>,
state: Arc<AgentStateSnapshot>,
) -> Result<AgentMessage, Error>
pub async fn handle_message( &self, input: impl AsRef<str>, state: Arc<AgentStateSnapshot>, ) -> Result<AgentMessage, Error>
Handle message from string input - converts string to AgentMessage internally
Sourcepub async fn handle_message_with_metadata(
&self,
input: impl AsRef<str>,
metadata: Option<MessageMetadata>,
state: Arc<AgentStateSnapshot>,
) -> Result<AgentMessage, Error>
pub async fn handle_message_with_metadata( &self, input: impl AsRef<str>, metadata: Option<MessageMetadata>, state: Arc<AgentStateSnapshot>, ) -> Result<AgentMessage, Error>
Handle message from string input with metadata - converts string to AgentMessage internally
Trait Implementations§
Source§impl AgentHandle for DeepAgent
impl AgentHandle for DeepAgent
fn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AgentDescriptor> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
fn handle_message<'life0, 'async_trait>(
&'life0 self,
input: AgentMessage,
_state: Arc<AgentStateSnapshot>,
) -> Pin<Box<dyn Future<Output = Result<AgentMessage, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
Source§fn handle_message_stream<'life0, 'async_trait>(
&'life0 self,
input: AgentMessage,
_state: Arc<AgentStateSnapshot>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
fn handle_message_stream<'life0, 'async_trait>(
&'life0 self,
input: AgentMessage,
_state: Arc<AgentStateSnapshot>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
Source§fn current_interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentInterrupt>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
fn current_interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentInterrupt>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
Source§fn resume_with_approval<'life0, 'async_trait>(
&'life0 self,
action: HitlAction,
) -> Pin<Box<dyn Future<Output = Result<AgentMessage, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
fn resume_with_approval<'life0, 'async_trait>(
&'life0 self,
action: HitlAction,
) -> Pin<Box<dyn Future<Output = Result<AgentMessage, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
DeepAgent: 'async_trait,
Auto Trait Implementations§
impl Freeze for DeepAgent
impl !RefUnwindSafe for DeepAgent
impl Send for DeepAgent
impl Sync for DeepAgent
impl Unpin for DeepAgent
impl !UnwindSafe for DeepAgent
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more