vtcode_config/core/
model.rs

1use serde::{Deserialize, Serialize};
2
3/// Model-specific behavior configuration
4#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
5#[derive(Debug, Clone, Deserialize, Serialize)]
6pub struct ModelConfig {
7    /// Enable loop hang detection to identify when model is stuck in repetitive behavior
8    #[serde(default = "default_loop_detection_enabled")]
9    pub skip_loop_detection: bool,
10
11    /// Maximum number of identical tool calls (same tool + same arguments) before triggering loop detection
12    #[serde(default = "default_loop_detection_threshold")]
13    pub loop_detection_threshold: usize,
14
15    /// Enable interactive prompt for loop detection instead of silently halting
16    #[serde(default = "default_loop_detection_interactive")]
17    pub loop_detection_interactive: bool,
18}
19
20impl Default for ModelConfig {
21    fn default() -> Self {
22        Self {
23            skip_loop_detection: default_loop_detection_enabled(),
24            loop_detection_threshold: default_loop_detection_threshold(),
25            loop_detection_interactive: default_loop_detection_interactive(),
26        }
27    }
28}
29
30fn default_loop_detection_enabled() -> bool {
31    false
32}
33
34fn default_loop_detection_threshold() -> usize {
35    3
36}
37
38fn default_loop_detection_interactive() -> bool {
39    true
40}