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 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,
Handle a message with streaming response
Default implementation falls back to non-streaming handle_message()
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,
Get the current pending interrupt if any
Returns None if no interrupts are pending
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,
Resume execution after human approval of an interrupt Read more
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.