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§
- System
Prompt Config - System instruction configuration
- System
Prompt Report - Result of measuring a composed system prompt against the configured token
budget (
agent.max_system_prompt_tokens).
Enums§
- Section
Kind - Identifies which layer of the system prompt a
PromptSectionbelongs 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 barepath/to/file.rs:42reference is portable while a broken pseudo-link pointing at the editor binary itself is not. The canonical one-line step format, mirrored fromtools::handlers::planning_workflow::artifacts::CANONICAL_STEP_FORMAT(const contexts cannot concat!, so the sync is enforced by theplan_quality_line_shows_canonical_step_formattest 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 Prerequisitessections 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_identityreplaces the firstVT Codein 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_SECTIONso they also survive a workspacesystem.mdoverride. - 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
SystemPromptReportandSectionKind::trim_priorityfor the budget/trim behavior driven byagent.max_system_prompt_tokens,agent.system_prompt_budget_warning, andagent.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_configbut also returns theSystemPromptReportfor 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.