Skip to main content

FILE_DISCOVERY_GUIDANCE

Constant FILE_DISCOVERY_GUIDANCE 

Source
pub const FILE_DISCOVERY_GUIDANCE: &str = "## File discovery\n\n\
- To explore the project, prefer the dedicated discovery tools over shelling \
out: `glob` finds files by pattern (e.g. `**/*.py`, `src/*.rs`), `grep` \
searches file contents by regular expression, and `list_dir` lists a \
directory's entries. They return structured, project-scoped results and are \
cheaper than a shell command. Reach for the shell tool only for actions these \
do not cover (running builds, tests, or other commands).";
Expand description

The file-discovery block, lifted OUT of BASE_PREAMBLE (#4602).

Why: this block names three concrete tools — glob, grep, list_dir — so it is only true for an agent whose registry actually carries them. While it lived inside BASE_PREAMBLE it reached the interactive PM too, whose registry holds harness tools only; the PM then emitted list_dir/glob calls that ToolCallExtractor::validate rejected as ToolCallExtractError::UnknownTool and the TUI rendered as <name>(<invalid-arguments>). Keeping it a separate constant lets crate::prompt::assemble_system_prompt_for_mode gate it on the run’s registry, and keeps BASE_PREAMBLE free of any tool-specific claim. What: the verbatim text of the former ## File discovery section, appended as its own section only when the registry carries every tool it names (crate::prompt::FILE_DISCOVERY_TOOLS). Test: prompt::tests::guidance_never_names_an_unregistered_tool, prompt::tests::file_discovery_guidance_follows_the_registry.