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.
This commit is contained in:
kshitijk4poor
2026-09-27 12:56:35 +05:30
committed by kshitij
parent f5028ddd3a
commit 0d9329bd95
2 changed files with 6 additions and 15 deletions

View File

@@ -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, "

View File

@@ -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).