Skip to main content

AgentRunTimeBuilder

Struct AgentRunTimeBuilder 

Source
pub struct AgentRunTimeBuilder { /* private fields */ }
Expand description

AgentRunTime 的构造器。

provider / model / 两类存储 / sandbox 是必填项; 中间件与实时消息通道可选。可观测性由标准 tracing span/event 产出, 是否导出到 OpenTelemetry / 日志 / 文件由宿主程序配置 subscriber 决定。

let runtime = AgentRunTimeBuilder::new()
    .provider(provider)
    .model("gpt-4o")
    .checkpoint_storage(storage.clone())
    .transcript_storage(storage)
    .sandbox(sandbox)
    .tools(tools)
    .middleware(Arc::new(MyGuardrail))
    .build()?;

Implementations§

Source§

impl AgentRunTimeBuilder

Source

pub fn new() -> Self

Source

pub fn provider(self, provider: Arc<dyn LlmProvider>) -> Self

Source

pub fn model(self, model: impl Into<String>) -> Self

Source

pub fn system_prompt(self, system_prompt: impl Into<String>) -> Self

Source

pub fn temperature(self, temperature: f32) -> Self

Source

pub fn max_tokens(self, max_tokens: u32) -> Self

Source

pub fn max_iter(self, max_iter: u32) -> Self

Source

pub fn max_consecutive_fail_count(self, count: u32) -> Self

Source

pub fn checkpoint_storage(self, storage: Arc<dyn CheckpointStorage>) -> Self

Source

pub fn transcript_storage(self, storage: Arc<dyn TranscriptStorage>) -> Self

Source

pub fn sandbox(self, sandbox: Arc<dyn Sandbox>) -> Self

Source

pub fn tools(self, tools: ToolRegistry) -> Self

Source

pub fn skill_dir(self, path: impl Into<PathBuf>) -> Self

Source

pub fn skill_dirs<I, P>(self, paths: I) -> Self
where I: IntoIterator<Item = P>, P: Into<PathBuf>,

Source

pub fn middleware(self, middleware: Arc<dyn Middleware>) -> Self

追加一个中间件(可多次调用,按调用顺序构成 onion 链)。

Source

pub fn messages(self, messages: MessageChannel) -> Self

设置对前端的实时消息通道(不设则为 disconnected,消息静默丢弃)。

Source

pub fn retry_backoff(self, base: Duration) -> Self

可重试失败的退避基数(默认 200ms,实际等待为指数退避 + jitter)。 传 Duration::ZERO 可关闭退避(测试常用)。

Source

pub fn tool_timeout(self, timeout: Duration) -> Self

单个工具调用的超时时间(默认 120s)。传 Duration::ZERO 可关闭工具超时。

Source

pub fn build(self) -> Result<AgentRunTime, AgentError>

Trait Implementations§

Source§

impl Default for AgentRunTimeBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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