Skip to content

Build orchestrator prompt sections conditionally on registered tools (semantic_search-less MCP config) #1201

Description

@vitali87

Follow-up to #1199 / PR #1200, prompted by review feedback there.

Gap

#1200 makes the orchestrator system prompt reference the registered short tool names, closing the rename drift. But the prompt text itself is static: when a canonical tool is not registered, the prompt still instructs the model to use it (with a runtime warning logged). One legitimate configuration hits this today: the MCP path (codebase_rag/mcp/tools.py) omits semantic_search when the vector backend is unavailable, yet the built prompt still contains the whole "WHEN TO USE SEMANTIC SEARCH FIRST" strategy section (prompts.py, the t.semantic_search sites around lines 156-183) telling the model to start with a tool that is not in its schema.

For prose-following models this is the same failure mode #1199 documented — a call to an unregistered name is dropped silently and the run burns retries on empty turns — just narrower: it needs a config where the tool is genuinely absent, rather than affecting every install.

Work

Make the prompt sections conditional on tool availability rather than interpolation-only:

  • extract_tool_names (or a sibling) should expose which canonical tools are actually registered, not just their names — e.g. return (ToolNames, frozenset[AgenticToolName]) or make the availability set a field.
  • build_rag_orchestrator_prompt builds the semantic-search strategy subsection (2a/2c workflows) only when semantic_search is registered; the graph-first guidance in 2b becomes the unconditional default in its absence.
  • Same treatment for any other tool that can legitimately be absent (structural_search/structural_replace are also conditional in the MCP path, though they are not in ToolNames today).
  • The runtime warning from fix: derive orchestrator prompt tool names from AgenticToolName so the prompt matches the registered tools #1200 stays — it then indicates a genuinely unexpected registration gap rather than a known configuration.

Tests

Extend test_prompt_tool_names.py: build the prompt from a tool list without semantic_search and assert the prompt neither backtick-references it nor instructs starting with semantic search; with the full list, assert the strategy section is present (guards against the section silently disappearing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmediumMedium strength issuetestsRelated to testing

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions