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 more