Configuration controls agent behavior at three levels: context management (ContextConfig), execution safety (ExecutionLimits), and the unified loop config (AgentLoopConfig) that bundles model, hooks, compaction, limits, caching, retry, and filters into a single borrowed struct for each agent_loop call.
Runtime state tracker that checks limits before each turn.
Field
Status
Description
limits
[EXISTS]
The ExecutionLimits being enforced
turns
[EXISTS]
Turn counter
tokens_used
[EXISTS]
Accumulated token count
cost_accumulated
[EXISTS]
Accumulated dollar cost
started_at
[EXISTS]
Instant when tracking began
When a limit is hit, check_limits() returns a reason string. The agent loop injects a "[Agent stopped: ...]" user message so the LLM (and user) can see what happened.
All static settings for a single agent_loop / agent_loop_continue call. Borrowed (&AgentLoopConfig) throughout the loop -- never mutated. 20+ fields organized by concern.
Note: Compaction strategies have been consolidated into CompactionConfig (G5). See in_memory_strategy and block_strategy fields on CompactionConfig. The former compaction_strategy and block_compaction_strategy fields no longer exist on AgentLoopConfig.
Synchronous filter applied to user input before the LLM call. Intentionally synchronous for hot-path performance; use before_turn for async moderation.
before_task / after_task [EXISTS] -- Session-level callbacks on SessionRecorderConfig. BeforeTaskFn: Arc<dyn Fn(&Session) -> bool> fires on first AgentStart with a new session_id. AfterTaskFn: Arc<dyn Fn(&Session)> fires on flush().
before_compaction_start / after_compaction_end [EXISTS] -- Compaction lifecycle callbacks (G1) on AgentLoopConfig. before_compaction_start(estimated_tokens, message_count) -> bool fires before CompactionStarted. after_compaction_end(msgs_before, msgs_after, tokens_before, tokens_after) fires after CompactionEnded.
Per-loop config tracking [EXISTS] -- Model, thinking_level, temperature, and other config values are captured per-loop in LoopConfigSnapshot on each LoopRecord (and in AgentStart.config_snapshot). Session no longer carries model_config, thinking_level, or temperature fields. Fallback hierarchy: Loop -> Agent default.
Config streamlining [DONE] -- Compaction strategies (in_memory_strategy, block_strategy) have been consolidated into CompactionConfig, completing G5. The dispatch logic in run.rs reads them from ctx_config.compaction. AgentLoopConfig no longer carries strategy fields.
ParallelLoopOutcome / ParallelLoopResult -- Defined in src/types/parallel.rs, these types support evaluational parallelism where multiple branches run concurrently and an EvaluationStrategy selects the winner. Related to config because parallel configs produce multiple AgentLoopConfig instances.