Skip to content

The agent that grows with you

test(agent): fold async handoff test and dedupe rationale comment

kshitijk4poor0d9329bd95f0
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index 218530f0198..6548cf123e4 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 da0f9a2bf90..a81d95febb5 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).