pub struct DetectionConfig {
pub loop_threshold: usize,
pub stop_threshold: usize,
pub enable_loop_detection: bool,
pub max_history: usize,
pub convergence_threshold: f32,
pub convergence_count: usize,
pub enable_convergence_detection: bool,
pub on_converge: ConvergenceAction,
}Expand description
Configuration for the DetectionManager.
Groups all tunables for loop detection and convergence detection in a
single struct so consumers can construct a DetectionManager with
one call to DetectionManager::new_with_config.
The Default implementation provides sensible production values:
loop threshold 3, stop threshold 10, convergence threshold 0.95, and
convergence count 3.
§Sections
The configuration is divided into two groups:
- Loop detection —
loop_threshold,stop_threshold,enable_loop_detection,max_history. - Convergence detection —
convergence_threshold,convergence_count,enable_convergence_detection,on_converge.
§Example
let config = DetectionConfig {
loop_threshold: 5, // allow more repetition before flagging
convergence_threshold: 0.9, // looser similarity threshold
..DetectionConfig::default()
};
let dm = DetectionManager::new_with_config(config);§See Also
DetectionConfig::to_convergence_config— converts toConvergenceConfig.DetectionConfig::to_loop_detector_config— converts toLoopDetectorConfig.
Fields§
§loop_threshold: usizeConsecutive similar operations before declaring a loop. Default: 3.
Number of times the same (tool, primary_param, result_hash)
signature must recur within the window before
DetectedPattern::LoopDetected is reported. Lower it to catch loops
sooner at the cost of more false positives.
stop_threshold: usizeRepetitions triggering forced stop (0 = disabled). Default: 10.
When a single operation’s repetition count reaches this value, the
detector sets LoopStatus::should_stop so the caller halts the
agent. Setting it to 0 disables forced stops entirely while still
issuing warnings. The count is window-relative, not cumulative:
max_history eviction can reset it, so a
stuck operation interleaved with enough distinct traffic may never
reach the threshold — raise max_history if slow loops must be
caught.
enable_loop_detection: boolWhether loop detection is enabled. Default: true.
Master switch for the tool-loop subsystem. When false,
DetectionManager::record_operation short-circuits and returns
DetectedPattern::NoPattern without consulting the loop detector.
max_history: usizeMax operations kept in loop detector history. Default: 100.
Size of the sliding window the loop detector retains. A larger window catches slower loops that span many interleaved operations; a smaller one uses less memory and forgets stale patterns faster.
convergence_threshold: f32Jaccard similarity threshold for convergence (0.0–1.0). Default: 0.95.
Minimum Jaccard similarity a response must share with its predecessor
to extend the convergence streak. Lower it to catch paraphrased
repetition; raise it toward 1.0 to demand near-verbatim matches.
convergence_count: usizeConsecutive similar responses for convergence. Default: 3.
Streak length of consecutive similar responses required before
DetectedPattern::ConvergenceDetected is reported. Maps to the
convergence detector’s window size.
enable_convergence_detection: boolWhether convergence detection is enabled. Default: true.
Master switch for the response-convergence subsystem. When false,
DetectionManager::record_response short-circuits and returns
DetectedPattern::NoPattern without consulting the convergence
detector.
on_converge: ConvergenceActionAction on convergence. Default: ConvergenceAction::Warn —
text similarity is a heuristic with irreducible false positives, so
its default punishment is not execution. Set
ConvergenceAction::Stop to restore stop-on-converge.
The ConvergenceAction forwarded to callers once convergence is
detected — stop, warn, switch phase, ask the user, or compact the
history. Drives how the agent responds to a detected stall.
Implementations§
Source§impl DetectionConfig
impl DetectionConfig
Sourcepub fn to_convergence_config(&self) -> ConvergenceConfig
pub fn to_convergence_config(&self) -> ConvergenceConfig
Convert convergence settings into a ConvergenceConfig.
§Field Mapping
DetectionConfig field | ConvergenceConfig field |
|---|---|
enable_convergence_detection | enabled |
convergence_count | window_size |
convergence_threshold | similarity_threshold |
on_converge | on_converge |
Sourcepub fn to_loop_detector_config(&self) -> LoopDetectorConfig
pub fn to_loop_detector_config(&self) -> LoopDetectorConfig
Convert the loop-related settings into a LoopDetectorConfig.
§Field Mapping
DetectionConfig field | LoopDetectorConfig field |
|---|---|
max_history | window_size |
loop_threshold | repetition_threshold |
stop_threshold | stop_threshold |
Trait Implementations§
Source§impl Clone for DetectionConfig
impl Clone for DetectionConfig
Source§fn clone(&self) -> DetectionConfig
fn clone(&self) -> DetectionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more