pub struct RuntimeAgentBuilder { /* private fields */ }Expand description
Builder for RuntimeAgent with fluent API
Use new() to start building, then chain methods like with_agent(),
model(), temperature(), etc. Call build() to get the final runtime agent.
Implementations§
Source§impl RuntimeAgentBuilder
impl RuntimeAgentBuilder
Sourcepub async fn from_overlay(
layer: AgentConfigOverlay,
registry: &CapabilityRegistry,
ctx: &SystemPromptContext,
) -> Self
pub async fn from_overlay( layer: AgentConfigOverlay, registry: &CapabilityRegistry, ctx: &SystemPromptContext, ) -> Self
Build from a pre-merged AgentConfigOverlay.
This is the preferred way to build a RuntimeAgent. The caller merges
Harness/Agent/Session into a single AgentConfigOverlay (via AgentConfigOverlay::fold),
then this method resolves capabilities and assembles the final config.
§Example
let layer = AgentConfigOverlay::fold([
AgentConfigOverlay::from(&harness),
AgentConfigOverlay::from(&agent),
AgentConfigOverlay::from(&session),
]);
let runtime_agent = RuntimeAgentBuilder::from_overlay(layer, ®istry, &ctx)
.await
.model("gpt-5.2")
.build();Sourcepub async fn with_harness(
self,
harness: &Harness,
registry: &CapabilityRegistry,
ctx: &SystemPromptContext,
) -> Self
pub async fn with_harness( self, harness: &Harness, registry: &CapabilityRegistry, ctx: &SystemPromptContext, ) -> Self
Apply a Harness’s configuration to this builder.
Sets the system prompt from the harness and applies harness capabilities.
Calls system_prompt_contribution() on each capability for dynamic content.
Call this BEFORE with_agent() to establish the base prompt layer.
Sourcepub async fn with_agent(
self,
agent: &Agent,
registry: &CapabilityRegistry,
ctx: &SystemPromptContext,
) -> Self
pub async fn with_agent( self, agent: &Agent, registry: &CapabilityRegistry, ctx: &SystemPromptContext, ) -> Self
Apply an Agent’s configuration to this builder.
Prepends the agent’s system prompt and capabilities on top of the
existing prompt (typically from a harness). Call after with_harness().
§Example
let ctx = SystemPromptContext::without_file_store(session_id);
let runtime_agent = RuntimeAgentBuilder::new()
.with_harness(&harness, ®istry, &ctx).await
.with_agent(&agent, ®istry, &ctx).await
.with_capabilities(&session_caps, ®istry, &ctx).await
.model("gpt-4o")
.build();Sourcepub async fn with_capabilities(
self,
capability_ids: &[String],
registry: &CapabilityRegistry,
ctx: &SystemPromptContext,
) -> Self
pub async fn with_capabilities( self, capability_ids: &[String], registry: &CapabilityRegistry, ctx: &SystemPromptContext, ) -> Self
Apply capabilities to this builder.
Resolves dependencies, then collects contributions from capabilities:
- Dependencies are automatically included (topologically sorted)
system_prompt_contribution(ctx)called on each (may read from filesystem)- System prompt additions are prepended to the current system prompt
- Tool definitions are added to the tools list
§Arguments
capability_ids- Ordered list of capability IDs to applyregistry- The capability registry containing implementationsctx- Session context for dynamic prompt resolution
Sourcepub async fn with_capability_configs(
self,
capability_configs: &[AgentCapabilityConfig],
registry: &CapabilityRegistry,
ctx: &SystemPromptContext,
) -> Self
pub async fn with_capability_configs( self, capability_configs: &[AgentCapabilityConfig], registry: &CapabilityRegistry, ctx: &SystemPromptContext, ) -> Self
Apply capability configs to this builder, preserving per-capability configuration.
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set the system prompt
Sourcepub fn prepend_system_prompt(self, prefix: impl Into<String>) -> Self
pub fn prepend_system_prompt(self, prefix: impl Into<String>) -> Self
Prepend text to the system prompt
Sourcepub fn with_locale(self, locale: Option<&str>) -> Self
pub fn with_locale(self, locale: Option<&str>) -> Self
Prepend locale instructions for session-aware localization.
Sourcepub fn tool(self, tool: ToolDefinition) -> Self
pub fn tool(self, tool: ToolDefinition) -> Self
Add a tool
Sourcepub fn tools(self, tools: impl IntoIterator<Item = ToolDefinition>) -> Self
pub fn tools(self, tools: impl IntoIterator<Item = ToolDefinition>) -> Self
Add multiple tools
Sourcepub fn max_iterations(self, max: usize) -> Self
pub fn max_iterations(self, max: usize) -> Self
Set maximum iterations
Sourcepub fn network_access(self, network_access: Option<NetworkAccessList>) -> Self
pub fn network_access(self, network_access: Option<NetworkAccessList>) -> Self
Set the merged network access list.
Sourcepub fn temperature(self, temp: f32) -> Self
pub fn temperature(self, temp: f32) -> Self
Set temperature
Sourcepub fn max_tokens(self, tokens: u32) -> Self
pub fn max_tokens(self, tokens: u32) -> Self
Set max tokens
Sourcepub fn tool_search(self, config: ToolSearchConfig) -> Self
pub fn tool_search(self, config: ToolSearchConfig) -> Self
Set tool_search configuration
Sourcepub fn prompt_cache(self, config: PromptCacheConfig) -> Self
pub fn prompt_cache(self, config: PromptCacheConfig) -> Self
Set prompt caching configuration
Sourcepub fn build(self) -> RuntimeAgent
pub fn build(self) -> RuntimeAgent
Build the runtime agent.
Validates that tool_search is only enabled for models that support it (currently GPT-5.4 and newer). Clears tool_search for unsupported models to prevent 400 errors from the OpenAI API.
tool_search is capability-driven: it is only set when the
openai_tool_search capability is explicitly added to the agent
or harness. This method does NOT auto-enable it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeAgentBuilder
impl !UnwindSafe for RuntimeAgentBuilder
impl Freeze for RuntimeAgentBuilder
impl Send for RuntimeAgentBuilder
impl Sync for RuntimeAgentBuilder
impl Unpin for RuntimeAgentBuilder
impl UnsafeUnpin for RuntimeAgentBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request