Skip to content

The agent that grows with you

fix(delegation): avoid duplicating child goals in system prompts

KoNit-K0aa178736a81
diff --git a/tests/tools/test_delegate.py b/tests/tools/test_delegate.py
index dd3fee08413..b9c5b726835 100644
--- a/tests/tools/test_delegate.py
+++ b/tests/tools/test_delegate.py
@@ -141,10 +141,10 @@ class TestDelegateRequirements(unittest.TestCase):
self.assertNotIn("up to 7", overrides["description"])
class TestChildSystemPrompt(unittest.TestCase):
- def test_goal_only(self):
- prompt = _build_child_system_prompt("Fix the tests")
- self.assertIn("Fix the tests", prompt)
- self.assertIn("YOUR TASK", prompt)
+ def test_goal_is_not_duplicated_in_system_prompt(self):
+ prompt = _build_child_system_prompt("Reply with the single word PONG and stop.")
+ self.assertNotIn("Reply with the single word PONG and stop.", prompt)
+ self.assertNotIn("YOUR TASK", prompt)
self.assertNotIn("CONTEXT", prompt)
class TestStripBlockedTools(unittest.TestCase):
diff --git a/tools/delegate_tool_progress.py b/tools/delegate_tool_progress.py
index 5c10e3fa503..02207f2073d 100644
--- a/tools/delegate_tool_progress.py
+++ b/tools/delegate_tool_progress.py
@@ -182,7 +182,10 @@ def _build_child_system_prompt(
"""Focused system prompt for a child agent. role='orchestrator' appends a delegation-capability block (modeled on
OpenClaw's buildSubagentSystemPrompt); its depth note is literal truth grounded in the passed config so the LLM
can't confabulate nesting."""
- parts = ["You are a focused subagent working on a specific delegated task.", "", f"YOUR TASK:\n{goal}"]
+ # The goal is the child's first user turn (see ``_ChildRun.await_child``).
+ # Keeping it out of the system prompt avoids sending OAuth Anthropic the
+ # same task in both roles, while preserving the normal user-turn contract.
+ parts = ["You are a focused subagent working on a specific delegated task."]
if context and context.strip():
parts.append(f"\nCONTEXT:\n{context}")
if workspace_path and str(workspace_path).strip():