Skip to content

fix: prevent agents from duplicating delegated subagent work#2400

Open
code-yeongyu wants to merge 1 commit intodevfrom
fix/subagent-self-execute
Open

fix: prevent agents from duplicating delegated subagent work#2400
code-yeongyu wants to merge 1 commit intodevfrom
fix/subagent-self-execute

Conversation

@code-yeongyu
Copy link
Owner

@code-yeongyu code-yeongyu commented Mar 9, 2026

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)

  1. seelosc: "there's no point in firing off subagents if the main agent is going to do the task themselves" — Sisyphus delegates design to sis-junior but does the design itself; fires explore agents but explores on its own then cancels them
  2. moneyput: "sisyphus + opus 4.6 keeps reading the explore agents checking if it's done then it gets impatient and reads everything which bloats the context"
  3. swiggityswerve: "GPT 5.4 as Atlas keeps stopping to ask about continuation at each step of a plan instead of just doing it"
  4. boxer01: "got the same issue right now"

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)

  • New buildAntiDuplicationSection() in dynamic-agent-prompt-builder.ts with explicit rules
  • FORBIDDEN: After delegating to explore/librarian, manually grep/search for the same information
  • ALLOWED: Continue with non-overlapping work that does not depend on the delegated research
  • Updated all "keep working" → "continue only with non-overlapping work"
  • Added "Delegation Trust Rule" to explore section
  • Added "Delegation Duplication" to anti-patterns list

Atlas Auto-Continue

  • New <auto_continue> section in all 3 Atlas variants (default, gemini, gpt)
  • NEVER ask "should I continue?" between plan steps
  • Auto-continue after verification passes
  • Only pause for: missing info, external dependency, critical failure
  • Fixed plan file path bug (.sisyphus/tasks/.sisyphus/plans/)

Testing

  • 3553 tests pass, 0 failures
  • New test files: anti-duplication.test.ts, delegation-trust-prompt.test.ts, atlas-prompt.test.ts

Summary 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/.

  • Bug Fixes
    • Add anti-duplication rules and examples; integrate into Sisyphus, Hephaestus, and Sisyphus‑Junior prompts; change “keep working” to “continue only with non-overlapping work”.
    • Add “Delegation Trust Rule” to the explore section and flag “Delegation Duplication” in anti‑patterns.
    • Introduce Atlas auto‑continue in all variants (default/gpt/gemini): never ask for approval; auto‑continue after verification; pause only when truly blocked.
    • Fix Atlas plan path to .sisyphus/plans/{plan-name}.md.
    • Update background_output: default full_session is now false while a task is active and true once completed to reduce context bloat.
    • Add tests for anti‑duplication, delegation trust, and Atlas prompts; suite passes.

Written for commit 21ddd55. Summary will update on new commits.

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
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts introduces a dynamic full_session default 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 reconcile full_session runtime 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")
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

}

const isActive = isTaskActiveStatus(resolvedTask.status)
const fullSessionProvided = args.full_session !== undefined
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant