fix(prompt): dedupe parallel-tool-call steer; correct its rationale

The universal PARALLEL_TOOL_CALL_GUIDANCE block already lives on main, but it
shipped with two rough edges this change cleans up:

- It duplicated the batching steer for Google models. The
  GOOGLE_MODEL_OPERATIONAL_GUIDANCE block still carried its own
  "Parallel tool calls" bullet, so Gemini/Gemma received the instruction
  twice in one prompt. Drop the redundant bullet — the universal block is now
  the single source.
- Its comment claimed "nothing in the open-source system prompt encouraged
  batching," which was wrong: the steer existed for Google models only. Reword
  to say the gap was that every *other* model got nothing.
- Tighten the test that asserts the steer (precedence-correct), and add an
  invariant guarding against re-introducing the Google duplicate.
This commit is contained in:
Brooklyn Nicholson 2026-06-18 13:22:12 -05:00
parent 0fa7d6f660
commit 07e785d60a
2 changed files with 18 additions and 8 deletions

View File

@ -320,9 +320,11 @@ TASK_COMPLETION_GUIDANCE = (
# concurrently when they are independent (read-only tools always; path-scoped # concurrently when they are independent (read-only tools always; path-scoped
# file ops when their targets don't overlap — see # file ops when their targets don't overlap — see
# run_agent._execute_tool_calls / tool_dispatch_helpers). The missing piece # run_agent._execute_tool_calls / tool_dispatch_helpers). The missing piece
# was telling the *model* to emit those calls together in the first place; # was telling the *model* to emit those calls together in the first place.
# nothing in the open-source system prompt encouraged batching. This block # Until now the only batching steer in the prompt lived in
# closes that gap. # GOOGLE_MODEL_OPERATIONAL_GUIDANCE — Gemini/Gemma got it, every other model
# got nothing. This block makes the steer universal; the now-redundant
# Google-only bullet has been dropped so no model receives it twice.
# #
# Short on purpose — shipped in the cached system prompt to every user, every # Short on purpose — shipped in the cached system prompt to every user, every
# session. Token cost is paid once at install and amortised across all # session. Token cost is paid once at install and amortised across all
@ -425,9 +427,10 @@ GOOGLE_MODEL_OPERATIONAL_GUIDANCE = (
"package.json, requirements.txt, Cargo.toml, etc. before importing.\n" "package.json, requirements.txt, Cargo.toml, etc. before importing.\n"
"- **Conciseness:** Keep explanatory text brief — a few sentences, not " "- **Conciseness:** Keep explanatory text brief — a few sentences, not "
"paragraphs. Focus on actions and results over narration.\n" "paragraphs. Focus on actions and results over narration.\n"
"- **Parallel tool calls:** When you need to perform multiple independent " # Parallel-tool-call steering now lives in the universal
"operations (e.g. reading several files), make all the tool calls in a " # PARALLEL_TOOL_CALL_GUIDANCE block (injected for all models), so it is no
"single response rather than sequentially.\n" # longer duplicated here — keeping it would send Gemini/Gemma the same
# instruction twice.
"- **Non-interactive commands:** Use flags like -y, --yes, --non-interactive " "- **Non-interactive commands:** Use flags like -y, --yes, --non-interactive "
"to prevent CLI tools from hanging on prompts.\n" "to prevent CLI tools from hanging on prompts.\n"
"- **Keep going:** Work autonomously until the task is fully resolved. " "- **Keep going:** Work autonomously until the task is fully resolved. "

View File

@ -28,6 +28,7 @@ from agent.prompt_builder import (
TOOL_USE_ENFORCEMENT_MODELS, TOOL_USE_ENFORCEMENT_MODELS,
OPENAI_MODEL_EXECUTION_GUIDANCE, OPENAI_MODEL_EXECUTION_GUIDANCE,
PARALLEL_TOOL_CALL_GUIDANCE, PARALLEL_TOOL_CALL_GUIDANCE,
GOOGLE_MODEL_OPERATIONAL_GUIDANCE,
MEMORY_GUIDANCE, MEMORY_GUIDANCE,
SESSION_SEARCH_GUIDANCE, SESSION_SEARCH_GUIDANCE,
PLATFORM_HINTS, PLATFORM_HINTS,
@ -1512,8 +1513,9 @@ class TestParallelToolCallGuidance:
def test_steers_batching_into_one_response(self): def test_steers_batching_into_one_response(self):
text = PARALLEL_TOOL_CALL_GUIDANCE.lower() text = PARALLEL_TOOL_CALL_GUIDANCE.lower()
# Must tell the model to group independent calls together. # Must tell the model to group independent calls together — accept any
assert "single response" in text or "same" in text and "turn" in text # phrasing that means "one turn" without freezing exact wording.
assert "single response" in text or ("same" in text and "turn" in text)
assert "independent" in text assert "independent" in text
def test_carves_out_dependent_calls(self): def test_carves_out_dependent_calls(self):
@ -1533,6 +1535,11 @@ class TestParallelToolCallGuidance:
# Heading delimits it as its own section in the assembled prompt. # Heading delimits it as its own section in the assembled prompt.
assert PARALLEL_TOOL_CALL_GUIDANCE.lstrip().startswith("#") assert PARALLEL_TOOL_CALL_GUIDANCE.lstrip().startswith("#")
def test_not_duplicated_in_google_guidance(self):
# The universal block is now the single source of parallel-batching
# steer. The Google-only block must NOT carry its own copy, otherwise
# Gemini/Gemma would receive the instruction twice in one prompt.
assert "parallel tool call" not in GOOGLE_MODEL_OPERATIONAL_GUIDANCE.lower()
# ========================================================================= # =========================================================================