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>
Sourcepub async fn create_subsession(
&self,
parent_session_id: &str,
) -> Result<String, AgentError>
pub async fn create_subsession( &self, parent_session_id: &str, ) -> Result<String, AgentError>
在 parent_session_id 名下创建一个子会话:子 transcript 的 parent 指向父会话,
同时在父会话上登记这条 subsession(父 → 子)。用于把子 agent 的独立会话挂回发起它的 turn。
Sourcepub async fn run_turn(
&self,
session_id: Option<String>,
user_text: impl Into<String>,
cancellation_token: CancellationToken,
) -> Result<AgentTurn, AgentError>
pub async fn run_turn( &self, session_id: Option<String>, user_text: impl Into<String>, cancellation_token: CancellationToken, ) -> Result<AgentTurn, AgentError>
One-shot user turn entrypoint.
When session_id is None, a new session is created. When it is Some,
the existing transcript is reused; if the transcript is missing, the
session is initialized with that id before the user message is appended.
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