pub struct AgentRunTime { /* private fields */ }Implementations§
Source§impl AgentRunTime
impl AgentRunTime
pub fn from_config(config: AgentRuntimeConfig) -> Result<Self, AgentError>
Source§impl AgentRunTime
impl AgentRunTime
Sourcepub async fn run(
&self,
agent_state: Agent,
cancellation_token: CancellationToken,
) -> Result<Agent, AgentError>
pub async fn run( &self, agent_state: Agent, cancellation_token: CancellationToken, ) -> Result<Agent, AgentError>
驱动一个 Agent 跑到停车点(终态或中断),并负责 checkpoint 生命周期:
Success/Fail是终态,运行结束时清掉该会话残留的 checkpoint —— 既回收存储, 也避免下次resume读到陈旧快照。Interrupted的 checkpoint 由内层在停车时写入,这里保留,留给resume。
Sourcepub async fn resume(
&self,
session_id: &str,
cancellation_token: CancellationToken,
) -> Result<Option<Agent>, AgentError>
pub async fn resume( &self, session_id: &str, cancellation_token: CancellationToken, ) -> Result<Option<Agent>, AgentError>
恢复被中断的会话:有 checkpoint 就从中断点接着跑,没有则什么都不做返回 Ok(None)。
这是与 submit 互补的入口 —— resume 续上被中断的 in-flight 状态,
submit 表示用户发了新消息(会丢弃尚未恢复的中断态)。
Sourcepub async fn run_session(
&self,
session_id: &str,
cancellation_token: CancellationToken,
) -> Result<Agent, AgentError>
pub async fn run_session( &self, session_id: &str, cancellation_token: CancellationToken, ) -> Result<Agent, AgentError>
一站式入口:有 checkpoint 则恢复,否则从全新 Ready 开始,跑到停车点。
适合“按 session_id 拉起一轮“的调用方,无需自己拼装 Agent。
pub async fn create_session(&self) -> Result<String, AgentError>
Auto Trait Implementations§
impl !Freeze for AgentRunTime
impl !RefUnwindSafe for AgentRunTime
impl !UnwindSafe for AgentRunTime
impl Send for AgentRunTime
impl Sync for AgentRunTime
impl Unpin for AgentRunTime
impl UnsafeUnpin for AgentRunTime
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