Skip to main content

AgentRuntimeBuilder

Struct AgentRuntimeBuilder 

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

Builder for AgentRuntime.

§Required

  • llm(...) — The LLM provider.

All other methods are optional with sensible defaults.

Implementations§

Source§

impl AgentRuntimeBuilder

Source

pub fn new() -> Self

Create a new builder with default values.

Source

pub fn prompt_segments(self, segments: PromptSegments) -> Self

Goal-328: forward structured prompt segments to the kernel so the local ContextBreakdown estimator can size the static buckets (system_prompt, rules, skills, subagents, tools, mcp_dynamic). Callers that built the prompt via crate::assemble_system_prompt should chain the returned segments through this method:

ⓘ
let assembled = assemble_system_prompt(base, ws, &skills, sub);
let mut builder = AgentRuntimeBuilder::new()
    .system_prompt(assembled.full())
    .prompt_segments(assembled.segments);
Source

pub fn with_plan_mode_tools(self, enabled: bool) -> Self

Register enter_plan_mode, exit_plan_mode, and request_plan_mode tools. Call this only from channels that have a live human reviewer (TUI, interactive CLI). Headless and batch callers must NOT set this — the tools block indefinitely waiting for confirm_plan().

Source

pub fn llm(self, llm: Arc<dyn ChatProvider>) -> Self

Set the LLM provider (required).

Source

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

Set the tool registry (optional, defaults to a local empty registry).

Source

pub fn skills(self, skills: Vec<Skill>) -> Self

Goal-318: set the skills list for Globs-mode automatic injection.

Source

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

Set an initial system prompt (optional).

This is prepended to the transcript as the first message.

Source

pub fn max_steps(self, n: usize) -> Self

Set the maximum number of LLM calls per turn (optional, default 0 (unlimited)).

Source

pub fn max_transcript_chars(self, n: usize) -> Self

Set a transcript character limit (optional, default unlimited).

Source

pub fn compactor(self, compactor: Compactor) -> Self

Set an optional compactor for summarising old messages.

Source

pub fn microcompactor(self, microcompactor: Microcompactor) -> Self

Set an optional microcompactor for no-LLM proactive pruning of old tool results by count.

Source

pub fn streaming(self, enabled: bool) -> Self

Enable or disable streaming of partial tokens (optional, default false).

Source

pub fn hooks(self, hooks: HookRegistry) -> Self

Set the hook registry (optional).

Source

pub fn seed_transcript(self, messages: Vec<Message>) -> Self

Seed the transcript with messages from a previous session.

These messages are placed after any system prompt, before the first user turn. Use this to resume an existing conversation.

Source

pub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self

Set the event sink for streaming events (optional, defaults to NullSink).

Source

pub fn shutdown_token(self, token: CancellationToken) -> Self

Set the cancellation token for graceful shutdown. When the token is cancelled, the runtime’s underlying kernel terminates the step loop with FinishReason::Cancelled at the next step boundary.

Source

pub fn stuck_window(self, n: usize) -> Self

Set the stuck-detection sliding window size.

Source

pub fn stuck_error_rate(self, rate: f64) -> Self

Set the stuck-detection error rate threshold.

Source

pub fn goal_eval_transcript_tail(self, n: usize) -> Self

Set the tail-window size for the goal-evaluator judge.

Each turn, the goal loop calls GoalEvaluator::evaluate with the most-recent n transcript messages. Smaller values reduce judge cost; larger values give the judge more context for long sessions. Defaults to 12 (matching the previous hard-coded GOAL_EVAL_TRANSCRIPT_TAIL constant). Goal-291.

Source

pub fn file_reinjector(self, r: FileReinjector) -> Self

Set an optional file re-injector for post-compaction restoration of recently-read file contents as System attachments.

Source

pub fn skill_reinjector(self, r: SkillReinjector) -> Self

Set an optional skill re-injector for post-compaction restoration.

Source

pub fn build(self) -> Result<AgentRuntime>

Build the AgentRuntime.

Returns an error if the LLM provider is missing.

Trait Implementations§

Source§

impl Debug for AgentRuntimeBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> IntoMaybeUndefined<T> for T

Source§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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