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
impl AgentRunTimeBuilder
pub fn new() -> Self
pub fn provider(self, provider: Arc<dyn LlmProvider>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
pub fn system_prompt(self, system_prompt: impl Into<String>) -> Self
pub fn temperature(self, temperature: f32) -> Self
pub fn max_tokens(self, max_tokens: u32) -> Self
pub fn max_iter(self, max_iter: u32) -> Self
pub fn max_consecutive_fail_count(self, count: u32) -> Self
pub fn checkpoint_storage(self, storage: Arc<dyn CheckpointStorage>) -> Self
pub fn transcript_storage(self, storage: Arc<dyn TranscriptStorage>) -> Self
pub fn sandbox(self, sandbox: Arc<dyn Sandbox>) -> Self
pub fn tools(self, tools: ToolRegistry) -> Self
pub fn skill_dir(self, path: impl Into<PathBuf>) -> Self
pub fn skill_dirs<I, P>(self, paths: I) -> Self
Sourcepub fn middleware(self, middleware: Arc<dyn Middleware>) -> Self
pub fn middleware(self, middleware: Arc<dyn Middleware>) -> Self
追加一个中间件(可多次调用,按调用顺序构成 onion 链)。
Sourcepub fn messages(self, messages: MessageChannel) -> Self
pub fn messages(self, messages: MessageChannel) -> Self
设置对前端的实时消息通道(不设则为 disconnected,消息静默丢弃)。
Sourcepub fn retry_backoff(self, base: Duration) -> Self
pub fn retry_backoff(self, base: Duration) -> Self
可重试失败的退避基数(默认 200ms,实际等待为指数退避 + jitter)。
传 Duration::ZERO 可关闭退避(测试常用)。
Sourcepub fn tool_timeout(self, timeout: Duration) -> Self
pub fn tool_timeout(self, timeout: Duration) -> Self
单个工具调用的超时时间(默认 120s)。传 Duration::ZERO 可关闭工具超时。
pub fn build(self) -> Result<AgentRunTime, AgentError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AgentRunTimeBuilder
impl !UnwindSafe for AgentRunTimeBuilder
impl Freeze for AgentRunTimeBuilder
impl Send for AgentRunTimeBuilder
impl Sync for AgentRunTimeBuilder
impl Unpin for AgentRunTimeBuilder
impl UnsafeUnpin for AgentRunTimeBuilder
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