pub struct AgentConfig {Show 17 fields
pub system_prompt: Option<String>,
pub system_prompt_file: Option<PathBuf>,
pub max_turns: u32,
pub max_tokens: u32,
pub effort: Option<Effort>,
pub thinking: bool,
pub cache_prompt: bool,
pub force_final_answer: bool,
pub max_output_tokens: Option<u64>,
pub max_cost_usd: Option<f64>,
pub compact_at_tokens: Option<u64>,
pub timezone: Option<String>,
pub compact_keep_recent: usize,
pub loop_guard: bool,
pub boredom: bool,
pub compact_validate: bool,
pub step_escalation: bool,
}Fields§
§system_prompt: Option<String>§system_prompt_file: Option<PathBuf>Read the system prompt from a file. Wins over system_prompt.
max_turns: u32Hard stop on runaway loops: how many model turns one run may take.
max_tokens: u32§effort: Option<Effort>§thinking: bool§cache_prompt: boolMark the tools + system prefix as cacheable.
force_final_answer: boolWhen the turn budget runs out, spend one more turn with the tools removed so the model has to answer with what it has. Without this a model that never stops searching returns nothing at all.
max_output_tokens: Option<u64>Stop once this many output tokens have been generated in one run.
max_turns bounds the number of round trips; this bounds their size,
which is what actually runs up a bill.
max_cost_usd: Option<f64>Stop once one run has cost this much. Requires prices on the provider.
compact_at_tokens: Option<u64>Summarise the middle of the conversation once the prompt passes this many tokens.
Measured against what the provider reported for the last turn rather
than an estimate, so it tracks the real prompt including cached tokens.
Unset by default: compaction is lossy, and silently paraphrasing
someone’s conversation because it got long is a decision they should
make. Set it to roughly two thirds of the model’s context window — or
set context_window on the provider and let
AgentConfig::compact_at work it out.
timezone: Option<String>IANA timezone name for the user, e.g. America/New_York. Unset means
the machine’s. See AgentConfig::timezone.
compact_keep_recent: usizeTurns kept verbatim after a compaction. The recent ones are where the work is; a summary of the last two turns is worse than the turns.
loop_guard: boolStop a run that repeats an identical tool call, with an identical
result, right after a compaction (StopCause::Loop).
On by default — the asymmetry is deliberate. A general repeated-call detector would need a measurement to justify watching all of ordinary work; this one exists to escape the specific loop that burns unbounded tokens at the largest prompts a run will ever send, and a no-config user should get that protection. Identical arguments with a changing result is polling and never trips it.
boredom: boolTell a run when an approach has stopped teaching it anything
(docs/GOAL-SYSTEM-DESIGN.md §9.1).
On by default, beside loop_guard, and the pair is the point: the
guard ends a run that is re-living what a compaction dropped, and
this speaks to one that is going nowhere while there is still something
to do about it. It spends nothing — the run was going to happen — so
there is no cost to weigh against the no-config user getting it. Off is
for pinning a scorecard, where any harness-authored text is part of
what a case measures.
compact_validate: boolCheck each summary against the transcript it replaces before installing it, and regenerate once with the omissions named.
Summaries fail by omission — they preserve what is true and drop task-critical specifics — and the producer cannot see its own gaps. A separate grounded comparison can: it reads both texts side by side, which is a different task from generating either. Measured elsewhere (Slipstream) at +6.4–8.8 points on SWE-bench Verified for under 1% latency, with ~90% of catches being omissions. Costs one extra request per compaction, two when a regeneration is needed.
step_escalation: boolEscalate an ambiguous completed step to a quarantined model call
(docs/GOAL-SYSTEM-DESIGN.md §5.5 — a span far longer than its
siblings, or a step whose own words claim a check its calls never
made) instead of staying silent.
Off by default, unlike boredom/compact_validate: those ship on
because each was argued from a measurement (boredom costs nothing;
compact_validate’s omission-catch rate was measured elsewhere). This
one has no corpus yet — the pre-filter’s thresholds are argued, not
measured, same honesty as step.rs’s own constants — so it follows
compact_at_tokens’s posture instead: unset until a person decides to
spend the model call.
Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub const COMPACT_FRACTION: f64 = 0.66
pub const COMPACT_FRACTION: f64 = 0.66
Fraction of a known context window at which to start compacting.
Two thirds, because the threshold is checked between turns against what the last one reported: the next turn still has to fit the model’s reply, and a burst of parallel tool results can add several thousand tokens before anything gets to look again. Leaving a third of the window is what makes the reactive check safe.
Sourcepub fn timezone(&self) -> Option<Tz>
pub fn timezone(&self) -> Option<Tz>
The user’s IANA timezone (America/New_York), when it is not the
machine’s.
A server runs in UTC and the model has no clock, so without this every “what’s on Thursday” is answered in the wrong zone — and wrongly in a way that looks right, since the times are internally consistent. An IANA name rather than an offset, because an offset is wrong twice a year.
Sourcepub fn compact_at(&self, context_window: Option<u64>) -> Option<u64>
pub fn compact_at(&self, context_window: Option<u64>) -> Option<u64>
Where compaction kicks in for a run: the explicit setting if there is one, otherwise derived from the provider’s context window.
Deriving it is what turns compaction from something you must remember to configure into something that just works — and the failure it prevents is total, not gradual: one turn over the window and the server refuses the request outright.
pub fn resolve_system_prompt(&self) -> Result<Option<String>>
Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Source§fn clone(&self) -> AgentConfig
fn clone(&self) -> AgentConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more