Skip to main content

AgentRunTime

Struct AgentRunTime 

Source
pub struct AgentRunTime { /* private fields */ }

Implementations§

Source§

impl AgentRunTime

Source§

impl AgentRunTime

Source

pub async fn run( &self, agent_state: Agent, cancellation_token: CancellationToken, ) -> Result<Agent, AgentError>

驱动一个 Agent 跑到停车点(终态或中断),并负责 checkpoint 生命周期:

  • Success / Fail 是终态,运行结束时清掉该会话残留的 checkpoint —— 既回收存储, 也避免下次 resume 读到陈旧快照。
  • Interrupted 的 checkpoint 由内层在停车时写入,这里保留,留给 resume
Source

pub async fn resume( &self, session_id: &str, cancellation_token: CancellationToken, ) -> Result<Option<Agent>, AgentError>

恢复被中断的会话:有 checkpoint 就从中断点接着跑,没有则什么都不做返回 Ok(None)

这是与 submit 互补的入口 —— resume 续上被中断的 in-flight 状态, submit 表示用户发了新消息(会丢弃尚未恢复的中断态)。

Source

pub async fn run_session( &self, session_id: &str, cancellation_token: CancellationToken, ) -> Result<Agent, AgentError>

一站式入口:有 checkpoint 则恢复,否则从全新 Ready 开始,跑到停车点。 适合“按 session_id 拉起一轮“的调用方,无需自己拼装 Agent

Source

pub async fn create_session(&self) -> Result<String, AgentError>

Source

pub async fn create_subsession( &self, parent_session_id: &str, ) -> Result<String, AgentError>

parent_session_id 名下创建一个子会话:子 transcript 的 parent 指向父会话, 同时在父会话上登记这条 subsession(父 → 子)。用于把子 agent 的独立会话挂回发起它的 turn。

Source

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.

Source

pub async fn submit( &self, session_id: &str, user_text: impl Into<String>, ) -> Result<Agent, AgentError>

框架对外的“用户说话“入口:把一条用户消息追加进会话历史, 返回一个 Ready 状态交给 run 驱动一轮对话。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more