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: &ThreadId) -> Result<()>
pub async fn save_state(&self, thread_id: &ThreadId) -> Result<()>
Save the current agent state to the configured checkpointer.
Sourcepub async fn load_state(&self, thread_id: &ThreadId) -> Result<bool>
pub async fn load_state(&self, thread_id: &ThreadId) -> Result<bool>
Load agent state from the configured checkpointer.
Sourcepub async fn delete_thread(&self, thread_id: &ThreadId) -> Result<()>
pub async fn delete_thread(&self, thread_id: &ThreadId) -> Result<()>
Delete saved state for the specified thread.
Sourcepub async fn list_threads(&self) -> Result<Vec<ThreadId>>
pub async fn list_threads(&self) -> Result<Vec<ThreadId>>
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>
pub async fn resume_with_approval( &self, action: HitlAction, ) -> Result<AgentMessage>
Resume execution after human approval of an interrupt.
Sourcepub async fn handle_message(
&self,
input: impl AsRef<str>,
state: Arc<AgentStateSnapshot>,
) -> Result<AgentMessage>
pub async fn handle_message( &self, input: impl AsRef<str>, state: Arc<AgentStateSnapshot>, ) -> Result<AgentMessage>
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>
pub async fn handle_message_with_metadata( &self, input: impl AsRef<str>, metadata: Option<MessageMetadata>, state: Arc<AgentStateSnapshot>, ) -> Result<AgentMessage>
Handle message from string input with metadata - converts string to AgentMessage internally