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
impl AgentRuntimeBuilder
Sourcepub fn prompt_segments(self, segments: PromptSegments) -> Self
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);Sourcepub fn with_plan_mode_tools(self, enabled: bool) -> Self
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().
Sourcepub fn llm(self, llm: Arc<dyn ChatProvider>) -> Self
pub fn llm(self, llm: Arc<dyn ChatProvider>) -> Self
Set the LLM provider (required).
Sourcepub fn tools(self, tools: ToolRegistry) -> Self
pub fn tools(self, tools: ToolRegistry) -> Self
Set the tool registry (optional, defaults to a local empty registry).
Sourcepub fn skills(self, skills: Vec<Skill>) -> Self
pub fn skills(self, skills: Vec<Skill>) -> Self
Goal-318: set the skills list for Globs-mode automatic injection.
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
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.
Sourcepub fn max_steps(self, n: usize) -> Self
pub fn max_steps(self, n: usize) -> Self
Set the maximum number of LLM calls per turn (optional, default 0 (unlimited)).
Sourcepub fn max_transcript_chars(self, n: usize) -> Self
pub fn max_transcript_chars(self, n: usize) -> Self
Set a transcript character limit (optional, default unlimited).
Sourcepub fn compactor(self, compactor: Compactor) -> Self
pub fn compactor(self, compactor: Compactor) -> Self
Set an optional compactor for summarising old messages.
Sourcepub fn microcompactor(self, microcompactor: Microcompactor) -> Self
pub fn microcompactor(self, microcompactor: Microcompactor) -> Self
Set an optional microcompactor for no-LLM proactive pruning of old tool results by count.
Sourcepub fn streaming(self, enabled: bool) -> Self
pub fn streaming(self, enabled: bool) -> Self
Enable or disable streaming of partial tokens (optional, default false).
Sourcepub fn hooks(self, hooks: HookRegistry) -> Self
pub fn hooks(self, hooks: HookRegistry) -> Self
Set the hook registry (optional).
Sourcepub fn seed_transcript(self, messages: Vec<Message>) -> Self
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.
Sourcepub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
pub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
Set the event sink for streaming events (optional, defaults to NullSink).
Sourcepub fn shutdown_token(self, token: CancellationToken) -> Self
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.
Sourcepub fn stuck_window(self, n: usize) -> Self
pub fn stuck_window(self, n: usize) -> Self
Set the stuck-detection sliding window size.
Sourcepub fn stuck_error_rate(self, rate: f64) -> Self
pub fn stuck_error_rate(self, rate: f64) -> Self
Set the stuck-detection error rate threshold.
Sourcepub fn goal_eval_transcript_tail(self, n: usize) -> Self
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.
Sourcepub fn file_reinjector(self, r: FileReinjector) -> Self
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.
Sourcepub fn skill_reinjector(self, r: SkillReinjector) -> Self
pub fn skill_reinjector(self, r: SkillReinjector) -> Self
Set an optional skill re-injector for post-compaction restoration.
Sourcepub fn build(self) -> Result<AgentRuntime>
pub fn build(self) -> Result<AgentRuntime>
Build the AgentRuntime.
Returns an error if the LLM provider is missing.