From f5028ddd3a7ac55fe4422fc6d8a5ab205cf576ca Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 27 Sep 2026 12:13:11 +0530 Subject: [PATCH] test(agent): trim async handoff tests to two invariants Keep the stack at <=2 invariant tests: the guidance is injected only when delegate_task is in the toolset (and after the generic keep-working blocks), and the stable prompt tier stays byte-identical across rebuilds so the prompt-cache prefix does not drift. --- tests/agent/test_system_prompt.py | 34 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/agent/test_system_prompt.py b/tests/agent/test_system_prompt.py index 6a45e76b96..da0f9a2bf9 100644 --- a/tests/agent/test_system_prompt.py +++ b/tests/agent/test_system_prompt.py @@ -372,25 +372,23 @@ class TestAsyncDelegationHandoffGuidance: _execution_guidance=execution_guidance, )) - def test_kimi_handoff_overrides_generic_tool_persistence(self): - stable = self._prompt("kimi-coding/kimi-k3", tool_use_enforcement=False) - assert "Execution discipline" in stable - assert "Tool-use enforcement" not in stable - assert "Async handoff" in stable - assert stable.index("Async handoff") > stable.index("Execution discipline") - assert "Do not manufacture polling, no-op, placeholder, or unrelated tool calls" in stable + @pytest.mark.parametrize("tools,expected", [ + (("delegate_task", "execute_code"), True), + (("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) + assert ("Async handoff" in stable) is expected + if expected: + # 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_follows_tool_enforcement_for_models_that_receive_both(self): - stable = self._prompt("openai/gpt-5.5") - assert "Tool-use enforcement" in stable - assert "Execution discipline" in stable - assert stable.index("Async handoff") > stable.index("Tool-use enforcement") - assert stable.index("Async handoff") > stable.index("Execution discipline") - - def test_no_delegation_tool_means_no_handoff_guidance(self): - stable = self._prompt("kimi-coding/kimi-k3", valid_tool_names=("execute_code",)) - assert "Execution discipline" in stable - assert "Async handoff" not in stable + 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: