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
93 lines
3.3 KiB
TypeScript
93 lines
3.3 KiB
TypeScript
/// <reference types="bun-types" />
|
|
|
|
import { describe, it, expect } from "bun:test"
|
|
import { buildAntiDuplicationSection } from "./dynamic-agent-prompt-builder"
|
|
|
|
describe("buildAntiDuplicationSection", () => {
|
|
it("#given no arguments #when building anti-duplication section #then returns comprehensive rule section", () => {
|
|
//#given: no special configuration needed
|
|
|
|
//#when: building the anti-duplication section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should contain the anti-duplication rule with all key concepts
|
|
expect(result).toContain("Anti-Duplication Rule")
|
|
expect(result).toContain("CRITICAL")
|
|
expect(result).toContain("DO NOT perform the same search yourself")
|
|
})
|
|
|
|
it("#given no arguments #when building #then explicitly forbids manual re-search after delegation", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should explicitly list forbidden behaviors
|
|
expect(result).toContain("FORBIDDEN")
|
|
expect(result).toContain("manually grep/search for the same information")
|
|
expect(result).toContain("Re-doing the research")
|
|
})
|
|
|
|
it("#given no arguments #when building #then allows non-overlapping work", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should explicitly allow non-overlapping work
|
|
expect(result).toContain("ALLOWED")
|
|
expect(result).toContain("non-overlapping work")
|
|
expect(result).toContain("work that doesn't depend on the delegated research")
|
|
})
|
|
|
|
it("#given no arguments #when building #then includes wait-for-results instructions", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should include instructions for waiting properly
|
|
expect(result).toContain("Wait for Results Properly")
|
|
expect(result).toContain("End your response")
|
|
expect(result).toContain("Wait for the completion notification")
|
|
expect(result).toContain("background_output")
|
|
})
|
|
|
|
it("#given no arguments #when building #then explains why this matters", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should explain the purpose
|
|
expect(result).toContain("Why This Matters")
|
|
expect(result).toContain("Wasted tokens")
|
|
expect(result).toContain("Confusion")
|
|
expect(result).toContain("Efficiency")
|
|
})
|
|
|
|
it("#given no arguments #when building #then provides code examples", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should include examples
|
|
expect(result).toContain("Example")
|
|
expect(result).toContain("WRONG")
|
|
expect(result).toContain("CORRECT")
|
|
expect(result).toContain("task(subagent_type=")
|
|
})
|
|
|
|
it("#given no arguments #when building #then uses proper markdown formatting", () => {
|
|
//#given: no special configuration
|
|
|
|
//#when: building the section
|
|
const result = buildAntiDuplicationSection()
|
|
|
|
//#then: should be wrapped in Anti_Duplication tag
|
|
expect(result).toContain("<Anti_Duplication>")
|
|
expect(result).toContain("</Anti_Duplication>")
|
|
})
|
|
})
|