Skip to main content

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    /// Manually enable reasoning support for models that are not natively recognized.
20    /// Note: Setting this to false will NOT disable reasoning for known reasoning models (e.g. GPT-5).
21    #[serde(default)]
22    pub model_supports_reasoning: Option<bool>,
23
24    /// Manually enable reasoning effort support for models that are not natively recognized.
25    /// Note: Setting this to false will NOT disable reasoning effort for known models.
26    #[serde(default)]
27    pub model_supports_reasoning_effort: Option<bool>,
28}
29
30impl Default for ModelConfig {
31    fn default() -> Self {
32        Self {
33            skip_loop_detection: default_loop_detection_enabled(),
34            loop_detection_threshold: default_loop_detection_threshold(),
35            loop_detection_interactive: default_loop_detection_interactive(),
36            model_supports_reasoning: None,
37            model_supports_reasoning_effort: None,
38        }
39    }
40}
41
42#[inline]
43const fn default_loop_detection_enabled() -> bool {
44    false
45}
46
47#[inline]
48const fn default_loop_detection_threshold() -> usize {
49    2
50}
51
52#[inline]
53const fn default_loop_detection_interactive() -> bool {
54    true
55}