Skip to content

fix(mcp): send every repo search to code_search in the server instructions - #37

Merged
wongk merged 1 commit into
mainfrom
fix/server-instructions-code-search-first
Sep 25, 2026
Merged

wongk merged 1 commit into
mainfrom
fix/server-instructions-code-search-first

Conversation

@wongk

@wongk wongk commented Sep 25, 2026

Copy link
Copy Markdown

Why

#35 made the "search with code_search" rule firmer in integrations/agents/shared/tool-discipline.md. It never reached Claude Code.

scripts/sync_agent_context.py deliberately gives Claude personas only a one-line tool rule (_CLAUDE_TOOL_DISCIPLINE), because Claude Code gets the full tool discipline from the MCP server's instructions field, SERVER_INSTRUCTIONS. Claude Code's lemoncrow:code build agents and main sessions are exactly the population the audit measured:

  • Opus 5.5 build agents used code search for 3% of repo searches.
  • Opus 5 build agents used it for 12%.
  • Opus 5.5 build agents ran 22 shell repo searches per 100 tool calls.

#35 left all of them with the old wording. I claimed otherwise in #35's description without checking the generated Claude files.

Change

SERVER_INSTRUCTIONS gets the same rule #35 gave the other hosts:

  • "Any repo search (symbols, strings, regex) → code_search, all terms in ONE call" replaces "Lead with code_search… never shell-grep or re-verify indexed results". Opus 5.5 read the old wording as covering only results already indexed.
  • The bash bullet now names the commands: never grep -r/rg/git grep/find on the repo.

SERVER_INSTRUCTIONS was already at its 215-token ceiling. It stays at exactly 215, because the new wording replaces two things:

  • the description of what a code_search call returns, which the tool's own schema already carries;
  • the "re-verify" clause, which "inline source = already read" still covers.

This string ships to every host that renders MCP instructions. Codex and OpenCode ignore it; they already got the rule through #35's persona text.

Checked

  • test_telegraphic_budget.py passes; the instructions are 215 of 215 tokens.
  • 511 gateway and integration tests that exercise initialize or the instructions pass.
  • Nothing else in the repo copies the old wording.
  • ruff and black are clean.

Follow-up

Once this is installed, rerun the transcript audit and compare Opus 5.5's share of repo searches against the 3% baseline.

…tions Claude Code reads

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Co-Authored-By: lemoncrow <302591943+lemoncrow-agent[bot]@users.noreply.github.com>
LemonCrow-Session: 90d6a214-e1bd-4377-b621-531411b973b6
LemonCrow-Model: claude-opus-5-5
@wongk
wongk merged commit 000f3b3 into main Sep 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant