pub struct AgentHandle { /* private fields */ }Expand description
Agent execution handle returned by AgentSupervisor::spawn().
Wraps Arc<Agent> with lifecycle state management.
Thread-safe: status tracked via atomic, cancel via shared flag.
Implementations§
Source§impl AgentHandle
impl AgentHandle
Sourcepub fn created_at_ms(&self) -> u64
pub fn created_at_ms(&self) -> u64
Creation timestamp (ms since epoch).
Sourcepub fn metrics(&self) -> MetricsSnapshot
pub fn metrics(&self) -> MetricsSnapshot
Current metrics snapshot.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the agent is currently running.
Sourcepub fn status(&self) -> AgentStatus
pub fn status(&self) -> AgentStatus
Current lifecycle status.
Sourcepub async fn run(
&self,
prompt: String,
) -> SdkResult<(Response, Vec<AgentEvent>)>
pub async fn run( &self, prompt: String, ) -> SdkResult<(Response, Vec<AgentEvent>)>
Run the agent with a prompt.
Transitions Created/Suspended → Running → Created (on success)
or Failed (on error).
Sourcepub async fn continue_with(
&self,
prompt: String,
) -> SdkResult<(Response, Vec<AgentEvent>)>
pub async fn continue_with( &self, prompt: String, ) -> SdkResult<(Response, Vec<AgentEvent>)>
Continue the conversation with a follow-up prompt.
Equivalent to run() — the underlying agent maintains conversation history.
Sourcepub async fn suspend(&self) -> SdkResult<AgentSnapshot>
pub async fn suspend(&self) -> SdkResult<AgentSnapshot>
Suspend the agent and create a checkpoint snapshot.
Transitions Created/Running → Suspended.
Sourcepub fn snapshot(&self) -> SdkResult<AgentSnapshot>
pub fn snapshot(&self) -> SdkResult<AgentSnapshot>
Take a snapshot without changing state.
Sourcepub fn switch_model(&self, model_id: &str) -> Result<()>
pub fn switch_model(&self, model_id: &str) -> Result<()>
Switch model mid-conversation.
The new provider is re-credentialed via the resolver; the old
api_key parameter was removed in 0.55.0 (issues #39/#40).
Sourcepub fn set_system_prompt(&self, prompt: String)
pub fn set_system_prompt(&self, prompt: String)
Update system prompt for future runs.
Sourcepub fn routing(&self) -> &RoutingControl
pub fn routing(&self) -> &RoutingControl
Get the runtime routing control for this agent.
Allows dynamic enabling/disabling of routing, model exclusion, and fallback model management.
Sourcepub fn disable_routing(&self)
pub fn disable_routing(&self)
Convenience: disable routing.
Sourcepub fn enable_routing(&self)
pub fn enable_routing(&self)
Convenience: enable routing.
Sourcepub fn exclude_route_model(&self, model_id: &str)
pub fn exclude_route_model(&self, model_id: &str)
Convenience: exclude a model from routing.
Trait Implementations§
Source§impl Clone for AgentHandle
impl Clone for AgentHandle
Source§fn clone(&self) -> AgentHandle
fn clone(&self) -> AgentHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AgentHandle
impl !UnwindSafe for AgentHandle
impl Freeze for AgentHandle
impl Send for AgentHandle
impl Sync for AgentHandle
impl Unpin for AgentHandle
impl UnsafeUnpin for AgentHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.