vtcode_core/config/core/
agent.rs

1use crate::config::constants::{defaults, project_doc};
2use crate::config::types::{ReasoningEffortLevel, UiSurfacePreference};
3use serde::{Deserialize, Serialize};
4
5/// Agent-wide configuration
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct AgentConfig {
8    /// AI provider for single agent mode (gemini, openai, anthropic, openrouter, xai)
9    #[serde(default = "default_provider")]
10    pub provider: String,
11
12    /// Default model to use
13    #[serde(default = "default_model")]
14    pub default_model: String,
15
16    /// UI theme identifier controlling ANSI styling
17    #[serde(default = "default_theme")]
18    pub theme: String,
19
20    /// Enable TODO planning workflow integrations (update_plan tool, onboarding hints)
21    #[serde(default = "default_todo_planning_mode")]
22    pub todo_planning_mode: bool,
23
24    /// Preferred rendering surface for the interactive chat UI (auto, alternate, inline)
25    #[serde(default)]
26    pub ui_surface: UiSurfacePreference,
27
28    /// Maximum number of conversation turns before auto-termination
29    #[serde(default = "default_max_conversation_turns")]
30    pub max_conversation_turns: usize,
31
32    /// Reasoning effort level for models that support it (low, medium, high)
33    /// Applies to: Claude, GPT-5, Gemini, Qwen3, DeepSeek with reasoning capability
34    #[serde(default = "default_reasoning_effort")]
35    pub reasoning_effort: ReasoningEffortLevel,
36
37    /// Enable an extra self-review pass to refine final responses
38    #[serde(default = "default_enable_self_review")]
39    pub enable_self_review: bool,
40
41    /// Maximum number of self-review passes
42    #[serde(default = "default_max_review_passes")]
43    pub max_review_passes: usize,
44
45    /// Enable prompt refinement pass before sending to LLM
46    #[serde(default = "default_refine_prompts_enabled")]
47    pub refine_prompts_enabled: bool,
48
49    /// Max refinement passes for prompt writing
50    #[serde(default = "default_refine_max_passes")]
51    pub refine_prompts_max_passes: usize,
52
53    /// Optional model override for the refiner (empty = auto pick efficient sibling)
54    #[serde(default)]
55    pub refine_prompts_model: String,
56
57    /// Session onboarding and welcome message configuration
58    #[serde(default)]
59    pub onboarding: AgentOnboardingConfig,
60
61    /// Maximum bytes of AGENTS.md content to load from project hierarchy
62    #[serde(default = "default_project_doc_max_bytes")]
63    pub project_doc_max_bytes: usize,
64}
65
66impl Default for AgentConfig {
67    fn default() -> Self {
68        Self {
69            provider: default_provider(),
70            default_model: default_model(),
71            theme: default_theme(),
72            todo_planning_mode: default_todo_planning_mode(),
73            ui_surface: UiSurfacePreference::default(),
74            max_conversation_turns: default_max_conversation_turns(),
75            reasoning_effort: default_reasoning_effort(),
76            enable_self_review: default_enable_self_review(),
77            max_review_passes: default_max_review_passes(),
78            refine_prompts_enabled: default_refine_prompts_enabled(),
79            refine_prompts_max_passes: default_refine_max_passes(),
80            refine_prompts_model: String::new(),
81            onboarding: AgentOnboardingConfig::default(),
82            project_doc_max_bytes: default_project_doc_max_bytes(),
83        }
84    }
85}
86
87fn default_provider() -> String {
88    defaults::DEFAULT_PROVIDER.to_string()
89}
90fn default_model() -> String {
91    defaults::DEFAULT_MODEL.to_string()
92}
93fn default_theme() -> String {
94    defaults::DEFAULT_THEME.to_string()
95}
96
97fn default_todo_planning_mode() -> bool {
98    true
99}
100fn default_max_conversation_turns() -> usize {
101    150
102}
103fn default_reasoning_effort() -> ReasoningEffortLevel {
104    ReasoningEffortLevel::default()
105}
106
107fn default_enable_self_review() -> bool {
108    false
109}
110
111fn default_max_review_passes() -> usize {
112    1
113}
114
115fn default_refine_prompts_enabled() -> bool {
116    false
117}
118
119fn default_refine_max_passes() -> usize {
120    1
121}
122
123fn default_project_doc_max_bytes() -> usize {
124    project_doc::DEFAULT_MAX_BYTES
125}
126
127#[derive(Debug, Clone, Deserialize, Serialize)]
128pub struct AgentOnboardingConfig {
129    /// Toggle onboarding message rendering
130    #[serde(default = "default_onboarding_enabled")]
131    pub enabled: bool,
132
133    /// Introductory text shown at session start
134    #[serde(default = "default_intro_text")]
135    pub intro_text: String,
136
137    /// Whether to include project overview in onboarding message
138    #[serde(default = "default_show_project_overview")]
139    pub include_project_overview: bool,
140
141    /// Whether to include language summary in onboarding message
142    #[serde(default = "default_show_language_summary")]
143    pub include_language_summary: bool,
144
145    /// Whether to include AGENTS.md highlights in onboarding message
146    #[serde(default = "default_show_guideline_highlights")]
147    pub include_guideline_highlights: bool,
148
149    /// Whether to surface usage tips inside the welcome text banner
150    #[serde(default = "default_show_usage_tips_in_welcome")]
151    pub include_usage_tips_in_welcome: bool,
152
153    /// Whether to surface suggested actions inside the welcome text banner
154    #[serde(default = "default_show_recommended_actions_in_welcome")]
155    pub include_recommended_actions_in_welcome: bool,
156
157    /// Maximum number of guideline bullets to surface
158    #[serde(default = "default_guideline_highlight_limit")]
159    pub guideline_highlight_limit: usize,
160
161    /// Tips for collaborating with the agent effectively
162    #[serde(default = "default_usage_tips")]
163    pub usage_tips: Vec<String>,
164
165    /// Recommended follow-up actions to display
166    #[serde(default = "default_recommended_actions")]
167    pub recommended_actions: Vec<String>,
168
169    /// Placeholder suggestion for the chat input bar
170    #[serde(default)]
171    pub chat_placeholder: Option<String>,
172}
173
174impl Default for AgentOnboardingConfig {
175    fn default() -> Self {
176        Self {
177            enabled: default_onboarding_enabled(),
178            intro_text: default_intro_text(),
179            include_project_overview: default_show_project_overview(),
180            include_language_summary: default_show_language_summary(),
181            include_guideline_highlights: default_show_guideline_highlights(),
182            include_usage_tips_in_welcome: default_show_usage_tips_in_welcome(),
183            include_recommended_actions_in_welcome: default_show_recommended_actions_in_welcome(),
184            guideline_highlight_limit: default_guideline_highlight_limit(),
185            usage_tips: default_usage_tips(),
186            recommended_actions: default_recommended_actions(),
187            chat_placeholder: None,
188        }
189    }
190}
191
192fn default_onboarding_enabled() -> bool {
193    true
194}
195
196fn default_intro_text() -> String {
197    "Let's get oriented. I preloaded workspace context so we can move fast.".to_string()
198}
199
200fn default_show_project_overview() -> bool {
201    true
202}
203
204fn default_show_language_summary() -> bool {
205    false
206}
207
208fn default_show_guideline_highlights() -> bool {
209    true
210}
211
212fn default_show_usage_tips_in_welcome() -> bool {
213    false
214}
215
216fn default_show_recommended_actions_in_welcome() -> bool {
217    false
218}
219
220fn default_guideline_highlight_limit() -> usize {
221    3
222}
223
224fn default_usage_tips() -> Vec<String> {
225    vec![
226        "Describe your current coding goal or ask for a quick status overview.".to_string(),
227        "Reference AGENTS.md guidelines when proposing changes.".to_string(),
228        "Draft or refresh your TODO list with update_plan before coding.".to_string(),
229        "Prefer asking for targeted file reads or diffs before editing.".to_string(),
230    ]
231}
232
233fn default_recommended_actions() -> Vec<String> {
234    vec![
235        "Start the session by outlining a 3–6 step TODO plan via update_plan.".to_string(),
236        "Review the highlighted guidelines and share the task you want to tackle.".to_string(),
237        "Ask for a workspace tour if you need more context.".to_string(),
238    ]
239}