vtcode-core 0.182.7

Core library for VT Code - a Rust-based terminal coding agent
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
use super::*;

#[tokio::test]
async fn runtime_prompt_budget_with_registry_catalog() {
    use crate::config::ToolDocumentationMode;
    use crate::config::types::CapabilityLevel;
    use crate::core::agent::harness_kernel::SessionToolCatalogSnapshot;
    use crate::llm::providers::OpenAIProvider;
    use crate::prompts::{
        RuntimePromptContract, append_fresh_runtime_tool_prompt_sections_for_model, append_runtime_mode_sections,
    };
    use crate::tools::handlers::{SessionSurface, SessionToolsConfig, ToolModelCapabilities};
    use crate::tools::registry::ToolRegistry;

    let workspace = tempfile::tempdir().expect("workspace");
    let registry = ToolRegistry::new_for_schema(workspace.path().to_path_buf()).await;
    let provider = OpenAIProvider::new("offline-fixture".into());
    for planning in [false, true] {
        let catalog_config = SessionToolsConfig::full_public(
            SessionSurface::Interactive,
            CapabilityLevel::CodeSearch,
            ToolDocumentationMode::Progressive,
            ToolModelCapabilities::default(),
        )
        .with_planning_active(planning);
        let definitions = registry.model_tools(catalog_config).await;
        assert!(!definitions.is_empty());
        let snapshot =
            SessionToolCatalogSnapshot::new(7, 9, planning, true, Some(std::sync::Arc::new(definitions)), false);
        for mode in [
            SystemPromptMode::Default,
            SystemPromptMode::Minimal,
            SystemPromptMode::Lightweight,
            SystemPromptMode::Specialized,
        ] {
            for shell in [ShellPromptProfile::UnixLike, ShellPromptProfile::PowerShell] {
                let mut config = VTCodeConfig::default();
                config.agent.system_prompt_mode = mode;
                config.agent.shell_prompt_profile = shell;
                config.agent.include_temporal_context = false;
                config.agent.include_working_directory = false;
                config.agent.max_system_prompt_tokens = 100_000;
                config.context.max_context_tokens = 128_000;
                let sections = build_prompt_sections_with_layers(
                    Some(&config),
                    None,
                    &crate::prompts::resources::SystemPromptLayers::default(),
                );
                let mut prompt = join_prompt_sections(&sections);
                append_runtime_mode_sections(
                    &mut prompt,
                    RuntimePromptContract {
                        planning_active: planning,
                        request_user_input_enabled: true,
                        ..Default::default()
                    },
                );
                append_fresh_runtime_tool_prompt_sections_for_model(
                    &mut prompt,
                    &snapshot,
                    true,
                    shell.resolve_for_current_platform(),
                    &provider,
                    crate::config::constants::models::openai::DEFAULT_MODEL,
                    Some(&config),
                );
                let lines = prompt.lines().count();
                let tokens = estimate_tokens(&prompt);
                eprintln!("{mode:?} {shell:?} planning={planning}: {lines} lines, {tokens} tokens");
                assert!(lines <= BUILT_IN_COMPOSED_MAX_LINES, "{mode:?} {shell:?} planning={planning}: {lines} lines");
                assert!(
                    tokens <= REGISTRY_RUNTIME_MAX_TOKENS_USIZE,
                    "{mode:?} {shell:?} planning={planning}: {tokens} tokens"
                );
            }
        }
    }
}

#[test]
fn built_in_composed_prompt_budget_without_workspace_additions() {
    for mode in [
        SystemPromptMode::Default,
        SystemPromptMode::Minimal,
        SystemPromptMode::Lightweight,
        SystemPromptMode::Specialized,
    ] {
        let mut config = VTCodeConfig::default();
        config.agent.system_prompt_mode = mode;
        config.agent.include_temporal_context = false;
        config.agent.include_working_directory = false;
        config.agent.instruction_max_bytes = 0;
        config.agent.shell_prompt_profile = ShellPromptProfile::UnixLike;
        let sections = build_prompt_sections_with_layers(
            Some(&config),
            None,
            &crate::prompts::resources::SystemPromptLayers::default(),
        );
        let prompt = join_prompt_sections(&sections);
        let lines = prompt.lines().count();
        let tokens = estimate_tokens(&prompt);
        eprintln!("{mode:?}: {lines} lines, {tokens} estimated tokens");
        assert!(lines <= BUILT_IN_COMPOSED_MAX_LINES, "{mode:?} built-in prompt has {lines} lines");
        assert!(
            tokens <= BUILT_IN_COMPOSED_MAX_TOKENS_USIZE,
            "{mode:?} built-in prompt has {tokens} estimated tokens"
        );
    }
}

#[test]
fn composed_prompt_preserves_override_and_append_layers() {
    use crate::prompts::resources::SystemPromptLayers;
    use crate::prompts::runtime_guidance::RUNTIME_GUIDANCE_SECTION;

    let layers = SystemPromptLayers {
        override_body: Some("custom override".to_string()),
        append_bodies: vec!["first append".to_string(), "second append".to_string()],
    };
    let sections = build_prompt_sections_with_layers(None, None, &layers);
    let prompt = join_prompt_sections(&sections);

    assert!(prompt.starts_with("custom override\n\nfirst append\n\nsecond append\n\n"));
    assert_eq!(prompt.matches(RUNTIME_GUIDANCE_SECTION).count(), 1);
    assert!(!prompt.contains(PROMPT_TITLE));
}

#[test]
fn empty_tool_context_keeps_workspace_tool_heading_without_generated_guidance() {
    let layers = crate::prompts::resources::SystemPromptLayers {
        override_body: Some("## Active Tools\nWorkspace instructions.".to_string()),
        append_bodies: Vec::new(),
    };
    let sections = build_prompt_sections_with_layers_option(None, Some(&PromptContext::default()), &layers, false);
    assert!(sections.iter().all(|section| section.kind != SectionKind::ToolGuidelines));
    let prompt = join_prompt_sections(&sections);
    assert!(prompt.contains("## Active Tools\nWorkspace instructions."));
    assert_eq!(prompt.matches("## Active Tools").count(), 1);
}

#[test]
fn planning_prompt_size_fixed_fixture() {
    use crate::core::agent::harness_kernel::SessionToolCatalogSnapshot;
    use crate::llm::provider::ToolDefinition;
    use crate::llm::providers::OpenAIProvider;
    use crate::prompts::{
        RuntimePromptContract, append_runtime_mode_sections, append_runtime_tool_prompt_sections_for_model,
    };

    struct PlanningPromptSizeCase {
        density: &'static str,
        prompt_budget_tokens: u64,
        max_prompt_bytes: usize,
        max_estimated_tokens: usize,
    }

    let provider = OpenAIProvider::new("offline-fixture".into());
    let names = [
        tools::EXEC_COMMAND,
        tools::CODE_SEARCH,
        tools::TASK_TRACKER,
        tools::REQUEST_USER_INPUT,
    ];
    let snapshot = SessionToolCatalogSnapshot::new(
        7,
        9,
        true,
        true,
        Some(std::sync::Arc::new(
            names
                .iter()
                .map(|name| {
                    ToolDefinition::function(
                        (*name).to_string(),
                        "Fixture tool".to_string(),
                        serde_json::json!({"type": "object"}),
                    )
                })
                .collect(),
        )),
        false,
    );
    // Budgets and their raise histories live on the constants; see `prompt_budgets.rs`.
    for case in [
        PlanningPromptSizeCase {
            density: "Default",
            prompt_budget_tokens: 100_000,
            max_prompt_bytes: PLANNING_FIXTURE_DEFAULT_MAX_BYTES,
            max_estimated_tokens: PLANNING_FIXTURE_DEFAULT_MAX_TOKENS_USIZE,
        },
        PlanningPromptSizeCase {
            density: "Minimal",
            prompt_budget_tokens: 1,
            max_prompt_bytes: PLANNING_FIXTURE_MINIMAL_MAX_BYTES,
            max_estimated_tokens: PLANNING_FIXTURE_MINIMAL_MAX_TOKENS_USIZE,
        },
    ] {
        let mut config = VTCodeConfig::default();
        config.agent.system_prompt_mode = SystemPromptMode::Minimal;
        config.agent.include_temporal_context = false;
        config.agent.include_working_directory = true;
        config.agent.instruction_max_bytes = 0;
        config.agent.shell_prompt_profile = ShellPromptProfile::UnixLike;
        let mut context = PromptContext {
            available_tools: names.iter().map(|name| (*name).to_string()).collect(),
            ..Default::default()
        };
        context.set_current_directory(PathBuf::from("/workspace"));
        let sections = build_prompt_sections_with_layers(
            Some(&config),
            Some(&context),
            &crate::prompts::resources::SystemPromptLayers::default(),
        );
        let (mut prompt, report) = apply_token_budget(
            sections,
            config.agent.max_system_prompt_tokens,
            config.agent.system_prompt_budget_warning,
            config.agent.trim_system_prompt,
            0,
        );
        assert!(report.trimmed_sections.is_empty(), "fixture must include every composed section");
        assert_eq!(report.layer_token_estimate, 0, "default layers contribute nothing");
        append_runtime_mode_sections(
            &mut prompt,
            RuntimePromptContract {
                planning_active: true,
                request_user_input_enabled: true,
                ..Default::default()
            },
        );
        config.agent.max_system_prompt_tokens = case.prompt_budget_tokens;
        append_runtime_tool_prompt_sections_for_model(
            &mut prompt,
            &snapshot,
            true,
            ResolvedShellPromptProfile::UnixLike,
            &provider,
            crate::config::constants::models::openai::DEFAULT_MODEL,
            Some(&config),
        );
        eprintln!(
            "planning fixture {}: {} lines, {} bytes, {} estimated tokens",
            case.density,
            prompt.lines().count(),
            prompt.len(),
            estimate_tokens(&prompt)
        );
        assert!(prompt.contains(PLANNING_WORKFLOW_PLAN_PERSISTENCE_POLICY_LINE));
        assert!(prompt.contains("Checklists do not persist plans"));
        assert!(prompt.contains("Rejected plans stay blocked; repair before approval"));
        assert!(
            prompt.lines().count() <= BUILT_IN_COMPOSED_MAX_LINES,
            "{} planning fixture exceeded line budget",
            case.density
        );
        assert!(prompt.len() <= case.max_prompt_bytes, "{} planning fixture exceeded byte budget", case.density);
        assert!(
            estimate_tokens(&prompt) <= case.max_estimated_tokens,
            "{} planning fixture exceeded token budget",
            case.density
        );
    }
}
#[tokio::test]
async fn test_minimal_mode_selection() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Minimal;
    // Disable enhancements for base prompt size testing
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    // Minimal prompt should remain compact and deterministic without AGENTS.md injection.
    // Char bound is a smoke check only; tokens are authoritative.
    // Budget and its raise history live on the constant; see `prompt_budgets.rs`.
    assert!(
        result.len() < MINIMAL_COMPOSED_MAX_BYTES,
        "Minimal mode should produce <{MINIMAL_COMPOSED_MAX_BYTES} chars (was {} chars)",
        result.len()
    );
    assert!(result.contains("VT Code"), "Should contain VT Code identifier");
}
#[tokio::test]
async fn test_default_prompt_selection() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Default;
    // Disable enhancements for base prompt size testing
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    // Budget and its raise history live on the constant; see `prompt_budgets.rs`.
    assert!(
        result.len() <= DEFAULT_COMPOSED_MAX_BYTES,
        "Default mode should stay sparse with runtime guidance (<={DEFAULT_COMPOSED_MAX_BYTES} bytes, was {} bytes)",
        result.len()
    );
    assert!(result.contains("`exec_command`, `write_stdin`, and `apply_patch`"));
    assert!(result.contains("## Shell Profile"));
    assert!(!result.contains("task_tracker"));
    assert!(!result.contains("@file"));
    assert!(result.contains("Planning workflow"));
}
#[tokio::test]
async fn test_lightweight_mode_selection() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Lightweight;
    // Disable enhancements for base prompt size testing
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    assert!(result.len() > 100, "Lightweight should be >100 chars");
    // Budget and its raise history live on the constant; see `prompt_budgets.rs`.
    assert!(
        result.len() < LIGHTWEIGHT_COMPOSED_MAX_BYTES,
        "Lightweight should be compact with runtime guidance (<{LIGHTWEIGHT_COMPOSED_MAX_BYTES} chars, was {} chars)",
        result.len()
    );
    assert!(result.contains("task_tracker"));
    assert!(!result.contains("@file"));
    assert!(result.contains("act directly in this thread"));
}
#[tokio::test]
async fn test_lightweight_mode_skips_structured_reasoning_by_default() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Lightweight;
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;
    config.agent.include_structured_reasoning_tags = None;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    assert!(
        !result.contains("## Structured Reasoning"),
        "Lightweight mode should omit structured reasoning by default"
    );
}
#[tokio::test]
async fn test_lightweight_mode_allows_explicit_structured_reasoning() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Lightweight;
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;
    config.agent.include_structured_reasoning_tags = Some(true);

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    assert!(
        result.contains("## Structured Reasoning"),
        "Lightweight mode should include structured reasoning when explicitly enabled"
    );
    assert!(result.contains("<reasoning_plan>"));
    assert!(!result.contains("`<plan>` steps"), "<plan> is reserved for approval artifacts");
}
#[tokio::test]
async fn test_default_prompt_omits_structured_reasoning_by_default() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Default;
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;
    config.agent.include_structured_reasoning_tags = None;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    assert!(
        !result.contains("## Structured Reasoning"),
        "Default mode should omit structured reasoning by default"
    );
}
#[tokio::test]
async fn test_specialized_prompt_omits_structured_reasoning_by_default() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Specialized;
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;
    config.agent.include_structured_reasoning_tags = None;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    assert!(
        !result.contains("## Structured Reasoning"),
        "Specialized mode should omit structured reasoning unless explicitly enabled"
    );
}
#[tokio::test]
async fn test_specialized_mode_selection() {
    let mut config = VTCodeConfig::default();
    config.agent.system_prompt_mode = SystemPromptMode::Specialized;
    // Disable enhancements for base prompt size testing
    config.agent.include_temporal_context = false;
    config.agent.include_working_directory = false;
    config.agent.instruction_max_bytes = 0;

    let result = compose_system_instruction_text(&PathBuf::from("."), Some(&config), None).await;

    // Budget and its raise history live on the constant; see `prompt_budgets.rs`.
    assert!(
        result.len() <= SPECIALIZED_COMPOSED_MAX_BYTES,
        "Specialized should stay sparse with runtime guidance (<={SPECIALIZED_COMPOSED_MAX_BYTES} chars, was {} chars)",
        result.len()
    );
    assert!(result.contains("task_tracker"));
    assert!(result.contains("<proposed_plan>"));
    assert!(result.contains(
        "- When repo-wide invariants matter, also read the architecture documents the instruction map points to."
    ));
    // Shipped prompts serve any repository, so they name no VT Code-specific doc.
    assert!(!result.contains("ARCHITECTURAL_INVARIANTS"));
}
#[test]
fn test_prompt_mode_enum_parsing() {
    assert_eq!(SystemPromptMode::parse("minimal"), Some(SystemPromptMode::Minimal));
    assert_eq!(SystemPromptMode::parse("LIGHTWEIGHT"), Some(SystemPromptMode::Lightweight));
    assert_eq!(SystemPromptMode::parse("Default"), Some(SystemPromptMode::Default));
    assert_eq!(SystemPromptMode::parse("specialized"), Some(SystemPromptMode::Specialized));
    assert_eq!(SystemPromptMode::parse("invalid"), None);
}
#[test]
fn operating_profile_deltas_share_canonical_sentences() {
    assert!(MINIMAL_OPERATING_PROFILE_DELTA.contains(OPERATING_TASK_TRACKER));
    assert!(LIGHTWEIGHT_OPERATING_PROFILE_DELTA.contains(OPERATING_TASK_TRACKER));
    assert!(OPERATING_TASK_TRACKER.contains("use `task_tracker` updates over lists"));
    // `start_planning` guidance has one home: the tool-gated Active Tools
    // line, which is present only when the tool is.
    for delta in [
        DEFAULT_OPERATING_PROFILE_DELTA,
        MINIMAL_OPERATING_PROFILE_DELTA,
        LIGHTWEIGHT_OPERATING_PROFILE_DELTA,
        SPECIALIZED_OPERATING_PROFILE_DELTA,
    ] {
        assert!(!delta.contains("start_planning"), "{delta}");
    }
    assert!(!DEFAULT_OPERATING_PROFILE_DELTA.contains("task_tracker"));
}
/// Regression guard: `PLANNING_WORKFLOW_PLAN_QUALITY_LINE` must keep
/// instructing the model to write file:symbol references as plain text
/// / inline code, not as markdown links or editor/IDE URI schemes (a
/// model was observed emitting `vscode-file://` pseudo-links pointing at
/// the editor binary instead of the referenced repo file).
#[test]
fn plan_quality_line_requires_scope_section() {
    let line = PLANNING_WORKFLOW_PLAN_QUALITY_LINE;
    assert!(line.contains("`## Scope`"));
    assert!(line.contains("never tracker steps"));
}
#[test]
fn plan_quality_line_keeps_rejected_work_blocked_until_repaired() {
    assert!(PLANNING_WORKFLOW_PLAN_QUALITY_LINE.contains("Rejected plans stay blocked; repair before approval"));
}
#[test]
fn plan_quality_line_forbids_markdown_link_file_references() {
    let line = PLANNING_WORKFLOW_PLAN_QUALITY_LINE;
    assert!(line.contains("never as markdown links or editor/IDE URIs"));
    assert!(line.contains("vscode-file://"));
    assert!(line.contains("plain text or inline code"));
}
/// The initial prompt must show the exact step grammar the validator
/// enforces, not just describe it — the repair directive prints the
/// canonical example only after a first rejection (turn_912/913 failed
/// every implementation step on "lacks a concrete target or verification"
/// without the model ever seeing an example). Keep the inline literal in
/// sync with the validator's canonical format.
#[test]
fn plan_quality_line_shows_canonical_step_format() {
    assert!(
        PLANNING_WORKFLOW_PLAN_QUALITY_LINE
            .contains(crate::tools::handlers::planning_workflow::artifacts::CANONICAL_STEP_FORMAT),
        "quality line must embed artifacts::CANONICAL_STEP_FORMAT verbatim"
    );
}
#[test]
fn plan_quality_line_requires_concrete_verify_checks() {
    assert!(PLANNING_WORKFLOW_PLAN_QUALITY_LINE.contains("never as a semicolon chain"));
    assert!(PLANNING_WORKFLOW_PLAN_QUALITY_LINE.contains("npx markdownlint-cli2 README.md"));
    let line = PLANNING_WORKFLOW_PLAN_QUALITY_LINE;
    assert!(line.contains("must exit 0 on success"));
    assert!(line.contains("grep/rg exit 1 cannot satisfy completion"));
    assert!(line.contains("both present and absent inputs"));
    assert!(line.contains("one concrete `verify:`/`verification:` command or observable check"));
    assert!(
        line.contains("Scope each `verify:` command to the step's files"),
        "quality line must scope verify commands to the step's files so full-repo checks cannot fail on pre-existing out-of-scope findings"
    );
    assert!(line.contains("vague prose"));
    assert!(line.contains("comma-separated verify entries that are not commands or observable checks"));
    assert!(
        line.contains("Commas inside single or double quotes stay inside one verify item"),
        "quality line must state the quoted-comma bracket rule so first-attempt plans do not fragment shell patterns"
    );
    assert!(
        line.contains("sed -n") && line.contains("grep -n"),
        "quality line must name inspection commands that recovery synthesis naturally emits"
    );
    assert!(
        line.contains("`git log`")
            && line.contains("`git show`")
            && line.contains("`git diff`")
            && line.contains("`git blame`")
    );
    assert!(line.contains("Reuse evidence; focus output"));
}
#[test]
fn planning_workflow_persistence_policy_assigns_plan_lifecycle_to_runtime() {
    let line = PLANNING_WORKFLOW_PLAN_PERSISTENCE_POLICY_LINE;
    assert!(line.contains("Emit exactly one final `<proposed_plan>` block"));
    assert!(line.contains("no surrounding prose"));
    assert!(line.contains("Do not use shell commands or file-writing tools to create or modify `.vtcode/plans/`"));
    assert!(line.contains("runtime owns plan/tracker persistence and validation"));
    assert!(line.contains("approval controls only after successful persistence"));
    assert!(line.contains("Checklists do not persist plans"));
    assert!(line.contains("Resume cancelled planning only on fresh input"));
    assert!(PLANNING_WORKFLOW_PLAN_POLICY_LINE.contains("Exhausted plan validation or recovery waits for retry"));
    assert!(PLANNING_WORKFLOW_PLAN_POLICY_LINE.contains("Explicit Plan mode requires approval even in full-auto"));
    assert!(PLANNING_WORKFLOW_PLAN_POLICY_LINE.contains("User answers never approve implementation"));
}
#[test]
fn test_minimal_prompt_token_count() {
    let approx_tokens = estimate_token_count(minimal_system_prompt());
    // Budget and its raise history live on the constant; see `prompt_budgets.rs`.
    assert!(
        approx_tokens <= MINIMAL_STATIC_PROMPT_MAX_TOKENS_U64,
        "Minimal prompt should stay compact, got ~{approx_tokens}"
    );
}