From 0d9329bd95f0466472f24f2e6e186718ab9e1d40 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 27 Sep 2026 12:56:35 +0530 Subject: [PATCH] test(agent): fold async handoff test and dedupe rationale comment The byte-stability test for the handoff block only re-asserted determinism of a constant gated on tool-name membership; stable-tier rebuild stability is already covered by test_system_prompt_restore and test_skills_auto_load. Its one unique check (block appears exactly once) moves into the positive branch of the parametrized injection test, and the _prompt helper now takes only the tool names since every caller used the same model/gates. The rationale comment lived twice (prompt_builder constant and the system_prompt call site); keep only the call-site ordering note. --- agent/prompt_builder.py | 3 --- tests/agent/test_system_prompt.py | 18 ++++++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index 218530f019..6548cf123e 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -392,9 +392,6 @@ TASK_COMPLETION_GUIDANCE = ( "produce. Reporting a blocker honestly is always better than inventing a result." ) -# Tool-scoped exception to the universal "keep working" guidance. Background delegation's -# delivery contract requires the parent turn to end before a completed child can re-enter the conversation; -# manufacturing activity to keep that turn open therefore prevents the dependency from ever arriving. ASYNC_HANDOFF_GUIDANCE = ( "# Async handoff\n" "When delegate_task explicitly says background work will deliver its result only after you end the current turn, " diff --git a/tests/agent/test_system_prompt.py b/tests/agent/test_system_prompt.py index da0f9a2bf9..a81d95febb 100644 --- a/tests/agent/test_system_prompt.py +++ b/tests/agent/test_system_prompt.py @@ -363,13 +363,12 @@ class TestExecutionGuidanceInjection: class TestAsyncDelegationHandoffGuidance: """A background child cannot re-enter until the parent yields its current turn (#124072).""" - def _prompt(self, model, *, tool_use_enforcement="auto", execution_guidance="auto", - valid_tool_names=("delegate_task", "execute_code")): + def _prompt(self, valid_tool_names): return _stable_prompt(_make_agent( valid_tool_names=list(valid_tool_names), - model=model, - _tool_use_enforcement=tool_use_enforcement, - _execution_guidance=execution_guidance, + model="openai/gpt-5.5", + _tool_use_enforcement="auto", + _execution_guidance="auto", )) @pytest.mark.parametrize("tools,expected", [ @@ -377,19 +376,14 @@ class TestAsyncDelegationHandoffGuidance: (("execute_code",), False), ]) def test_handoff_injected_only_with_delegate_task(self, tools, expected): - stable = self._prompt("openai/gpt-5.5", valid_tool_names=tools) + stable = self._prompt(tools) assert ("Async handoff" in stable) is expected if expected: + assert stable.count("Async handoff") == 1 # Must follow the generic "keep working" blocks so it reads as their exception. assert stable.index("Async handoff") > stable.index("Tool-use enforcement") assert stable.index("Async handoff") > stable.index("Execution discipline") - def test_handoff_prompt_is_byte_stable_across_turns(self): - # Stable tier is the prompt-cache prefix: rebuilding it must not drift. - first = self._prompt("openai/gpt-5.5") - assert first == self._prompt("openai/gpt-5.5") - assert first.count("Async handoff") == 1 - class TestNamedProfileHintIntegration: """The same defect through the REAL resolution chain (#72894).