Skip to main content

Module system

Module system 

Source
Expand description

System instructions and prompt management.

Prompt variants share one canonical base contract plus thin mode deltas and compact runtime addenda. Project-specific behavior comes from dynamically loaded instruction maps (AGENTS.md/CLAUDE.md), dynamic tool guidance, skill metadata, and runtime notices.

Re-exports§

pub use crate::prompts::static_prompts::agent_identity_label;
pub use crate::prompts::static_prompts::default_lightweight_prompt;
pub use crate::prompts::static_prompts::default_system_prompt;
pub use crate::prompts::static_prompts::lightweight_instruction_text;
pub use crate::prompts::static_prompts::minimal_instruction_text;
pub use crate::prompts::static_prompts::minimal_system_prompt;
pub use crate::prompts::static_prompts::specialized_instruction_text;
pub use crate::prompts::static_prompts::specialized_system_prompt;
pub use crate::prompts::static_prompts::static_profile_prompt;

Structs§

SystemPromptConfig
System instruction configuration
SystemPromptReport
Result of measuring a composed system prompt against the configured token budget (agent.max_system_prompt_tokens).

Enums§

SectionKind
Identifies which layer of the system prompt a PromptSection belongs to.

Constants§

CONTRACT_HEADER
DEFAULT_OPERATING_PROFILE_DELTA
DEFAULT_SPECIFIC_LINES
Default/Lightweight/Specialized mode: extended working style beyond the universal runtime guidance (instruction map, communication detail, corrections, delegation, code style, and test design). Each rule has exactly one home; do not restate runtime-guidance rules here.
LIGHTWEIGHT_OPERATING_PROFILE_DELTA
MINIMAL_OPERATING_PROFILE_DELTA
MINIMAL_SPECIFIC_LINES
Minimal mode has no additional contract lines; universal behavior lives in the compiled runtime-guidance section shared by every profile.
OPERATING_TASK_TRACKER
Shared operating-profile sentences reused across modes.
PLANNING_WORKFLOW_EXIT_INSTRUCTION_LINE
Shared Planning workflow instruction line for transitioning to implementation.
PLANNING_WORKFLOW_HINT
Hint shown when planning workflow is active.
PLANNING_WORKFLOW_IMPLEMENTATION_PROMPT
Shared Planning workflow task-tracking line clarifying availability and aliasing. Implementation prompt used when transitioning from planning to execution.
PLANNING_WORKFLOW_IMPLEMENT_REMINDER
Shared reminder appended when presenting plans while still in Planning workflow.
PLANNING_WORKFLOW_INTERVIEW_POLICY_LINE
PLANNING_WORKFLOW_NO_AUTO_EXIT_LINE
Shared Planning workflow guard line requiring explicit transition from planning to execution.
PLANNING_WORKFLOW_NO_REQUEST_USER_INPUT_POLICY_LINE
PLANNING_WORKFLOW_PLAN_PERSISTENCE_POLICY_LINE
Canonical contract for model-authored plan output and runtime-owned persistence.
PLANNING_WORKFLOW_PLAN_POLICY_LINE
Shared Planning workflow policy line directing context-aware read-only research and plain-text question resolution.
PLANNING_WORKFLOW_PLAN_QUALITY_LINE
Compact, spec-like plan quality line. The previous wording (“summary, steps, test cases, assumptions”) let the model emit verbosely large plans that blew the generation token budget and were cut off mid-<proposed_plan> — which previously re-triggered the recovery loop forever. This mandates a tight spec that fits a small token budget and prefers file:symbol references over prose. It also forbids wrapping those references in markdown link syntax or editor/IDE URI schemes (e.g. vscode-file://, file://) — plans are read in terminals and other non-hyperlink surfaces, and a bare path/to/file.rs:42 reference is portable while a broken pseudo-link pointing at the editor binary itself is not. The canonical one-line step format, mirrored from tools::handlers::planning_workflow::artifacts::CANONICAL_STEP_FORMAT (const contexts cannot concat!, so the sync is enforced by the plan_quality_line_shows_canonical_step_format test below). Showing the exact shape up front matters: the repair directive prints it only after a rejection, and turn_912/913 showed planners repeatedly failing “step lacks a concrete target or verification” without ever seeing an example. The optional ## Expected Outcomes / ## Dependencies and Prerequisites sections are requested only “when material” so plans carry outcomes and prerequisites without inflating every plan past the token budget.
PLANNING_WORKFLOW_READ_ONLY_HEADER
Shared Planning workflow header used by both static and incremental prompt builders.
PLANNING_WORKFLOW_READ_ONLY_NOTICE_LINE
Shared Planning workflow notice line describing strict read-only enforcement.
PLANNING_WORKFLOW_RESEARCH_SCOPE_LINE
Scale research effort to the request instead of always exhaustively enumerating the repository. Checkpoint turn_647 showed a “make a simple plan to improve launch time” request burn 70+ tool calls across dozens of files until the turn’s tool wall-clock budget was exhausted with no plan delivered — the model had no signal to stop researching and draft. This line gives it a concrete budget to self-regulate against.
PLANNING_WORKFLOW_TASK_TRACKER_LINE
PROMPT_INTRO
Identity line. apply_agent_identity replaces the first VT Code in this line with the active agent label, so the label must appear exactly once.
PROMPT_ROLE_PARAGRAPH
Natural-language role framing inserted between the identity line and the runtime guidance for the Default and Specialized profiles. It sets the working posture and effort calibration; the concrete rules live in the sections below it. Omitted from Minimal and Lightweight modes to respect their compact budgets (see the parent-ratio guard in subagents/config.rs).
PROMPT_TITLE
SHARED_CONTRACT_LINES
Contract rules shared across all prompt modes that are not universal user-facing runtime guidance: state the harness must carry across compaction. Grounding, honesty, and scope rules live in runtime_guidance::RUNTIME_GUIDANCE_SECTION so they also survive a workspace system.md override.
SPECIALIZED_OPERATING_PROFILE_DELTA

Functions§

apply_coordinator_role_guidance
Align cached base guidance with the selected role, including switches away from the coordinator.
apply_output_style
Apply output style to a generated system instruction
compose_system_instruction_text
Compose the base system instruction plus compact tool/skill/environment addenda.
compose_system_instruction_with_report
Compose the system instruction and return the token-budget report alongside it. See SystemPromptReport and SectionKind::trim_priority for the budget/trim behavior driven by agent.max_system_prompt_tokens, agent.system_prompt_budget_warning, and agent.trim_system_prompt.
estimate_token_count
Estimate prompt tokens through the shared workspace tokenizer.
generate_lightweight_instruction
Generate a lightweight system instruction for simple operations
generate_minimal_instruction
Generate a minimal system instruction (pi-inspired, <1K tokens)
generate_specialized_instruction
Generate a specialized system instruction for advanced operations
generate_system_instruction_with_config
Generate the stable base system instruction with configuration-aware sections.
generate_system_instruction_with_config_and_report
Same as generate_system_instruction_with_config but also returns the SystemPromptReport for the composed prompt, whether served from cache or freshly built.
generate_system_instruction_with_context_and_report
Generate a system instruction using a context-aware cache identity.
measure_system_prompt_size
Measure the system prompt size without applying budget trimming or warnings.