fix: prevent agents from duplicating delegated subagent work#2400
fix: prevent agents from duplicating delegated subagent work#2400code-yeongyu wants to merge 1 commit intodevfrom
Conversation
Addresses user reports where Sisyphus/Hephaestus would delegate tasks to explore/librarian subagents but then immediately perform the same search/work themselves, wasting context and defeating the purpose of delegation. Changes: - Add Anti-Duplication section to dynamic-agent-prompt-builder with clear rules: once you delegate, do NOT manually re-do the same search - Update all agent prompts (sisyphus, hephaestus, sis-junior gemini/gpt) to use 'non-overlapping work' instead of 'keep working' after delegation - Add buildAntiDuplicationSection() with explicit examples of forbidden vs allowed behavior after delegation - Add 'Delegation Trust Rule' to explore section - Add 'Delegation Duplication' to anti-patterns list Atlas fixes: - Add AUTO-CONTINUE POLICY to all Atlas variants (default, gemini, gpt) preventing the 'should I continue?' confirmation loop between plan steps - Fix plan file path in default atlas (.sisyphus/tasks/ -> .sisyphus/plans/) - Update GPT atlas uncertainty section to only ask questions during initial plan analysis, not during execution Fixes: subagent delegation duplication, Atlas continuation prompting
There was a problem hiding this comment.
2 issues found across 14 files
Confidence score: 3/5
- There is moderate merge risk: a high-confidence compatibility issue indicates plans should be written to
.opencode/plans/, and keeping.sisyphus/plans/can break Opencode-native plan tooling/permissions expectations. src/tools/background-task/create-background-output.tsintroduces a dynamicfull_sessiondefault that conflicts with the schema description, creating concrete behavior-vs-doc mismatch risk for callers and integrations.- Pay close attention to
src/agents/atlas/atlas-prompt.test.ts,src/tools/background-task/create-background-output.ts- align plan storage path with Opencode conventions and reconcilefull_sessionruntime defaults with the declared schema.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/agents/atlas/atlas-prompt.test.ts">
<violation number="1" location="src/agents/atlas/atlas-prompt.test.ts:86">
P1: Custom agent: **Opencode Compatibility**
To maintain compatibility with Opencode's native plan tooling and permissions, plans should be stored in `.opencode/plans/` rather than `.sisyphus/plans/`. Opencode explicitly whitelists `.opencode/plans/*.md` for plan-related operations.</violation>
</file>
<file name="src/tools/background-task/create-background-output.ts">
<violation number="1" location="src/tools/background-task/create-background-output.ts:125">
P2: The new dynamic default for `full_session` contradicts the tool schema description.
This line changes the default behavior to `false` when the task is active. However, the tool schema description (around line 53) still states `(default: true)`. This discrepancy will mislead the LLM into expecting full session output by default, potentially causing it to incorrectly conclude the subagent hasn't produced any output when it only receives a status update. Update the schema description to document the dynamic default (e.g., `default: true if completed, false if active`).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const prompt = ATLAS_SYSTEM_PROMPT | ||
|
|
||
| // when / then | ||
| expect(prompt).toContain(".sisyphus/plans/{plan-name}.md") |
There was a problem hiding this comment.
P1: Custom agent: Opencode Compatibility
To maintain compatibility with Opencode's native plan tooling and permissions, plans should be stored in .opencode/plans/ rather than .sisyphus/plans/. Opencode explicitly whitelists .opencode/plans/*.md for plan-related operations.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agents/atlas/atlas-prompt.test.ts, line 86:
<comment>To maintain compatibility with Opencode's native plan tooling and permissions, plans should be stored in `.opencode/plans/` rather than `.sisyphus/plans/`. Opencode explicitly whitelists `.opencode/plans/*.md` for plan-related operations.</comment>
<file context>
@@ -0,0 +1,118 @@
+ const prompt = ATLAS_SYSTEM_PROMPT
+
+ // when / then
+ expect(prompt).toContain(".sisyphus/plans/{plan-name}.md")
+ expect(prompt).not.toContain(".sisyphus/tasks/{plan-name}.yaml")
+ expect(prompt).not.toContain(".sisyphus/tasks/")
</file context>
| } | ||
|
|
||
| const isActive = isTaskActiveStatus(resolvedTask.status) | ||
| const fullSessionProvided = args.full_session !== undefined |
There was a problem hiding this comment.
P2: The new dynamic default for full_session contradicts the tool schema description.
This line changes the default behavior to false when the task is active. However, the tool schema description (around line 53) still states (default: true). This discrepancy will mislead the LLM into expecting full session output by default, potentially causing it to incorrectly conclude the subagent hasn't produced any output when it only receives a status update. Update the schema description to document the dynamic default (e.g., default: true if completed, false if active).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/background-task/create-background-output.ts, line 125:
<comment>The new dynamic default for `full_session` contradicts the tool schema description.
This line changes the default behavior to `false` when the task is active. However, the tool schema description (around line 53) still states `(default: true)`. This discrepancy will mislead the LLM into expecting full session output by default, potentially causing it to incorrectly conclude the subagent hasn't produced any output when it only receives a status update. Update the schema description to document the dynamic default (e.g., `default: true if completed, false if active`).</comment>
<file context>
@@ -123,6 +122,10 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
}
const isActive = isTaskActiveStatus(resolvedTask.status)
+ const fullSessionProvided = args.full_session !== undefined
+ const fullSession = fullSessionProvided
+ ? (args.full_session ?? true)
</file context>
Problem
Users reported that Sisyphus/Hephaestus spawn subagents (explore, librarian, sis-junior) but then immediately perform the same task themselves, making subagents pointless.
User Reports (Discord #get-help)
Root Cause
Agent prompts said "keep working" after firing background agents, with no clear rule against duplicating the delegated research. Atlas had no auto-continue policy, causing confirmation loops.
Changes
Anti-Duplication (Sisyphus, Hephaestus, Sis-Junior)
buildAntiDuplicationSection()indynamic-agent-prompt-builder.tswith explicit rulesAtlas Auto-Continue
<auto_continue>section in all 3 Atlas variants (default, gemini, gpt).sisyphus/tasks/→.sisyphus/plans/)Testing
anti-duplication.test.ts,delegation-trust-prompt.test.ts,atlas-prompt.test.tsSummary by cubic
Stops main agents from redoing work after delegating to subagents and removes Atlas “should I continue?” pauses between plan steps. Also fixes the Atlas plan path to
.sisyphus/plans/..sisyphus/plans/{plan-name}.md.background_output: defaultfull_sessionis now false while a task is active and true once completed to reduce context bloat.Written for commit 21ddd55. Summary will update on new commits.