diff --git a/src/agents/hephaestus.ts b/src/agents/hephaestus.ts index f4f1dc043..f936de478 100644 --- a/src/agents/hephaestus.ts +++ b/src/agents/hephaestus.ts @@ -16,6 +16,82 @@ import { const MODE: AgentMode = "primary" +function buildTodoDisciplineSection(useTaskSystem: boolean): string { + if (useTaskSystem) { + return `## Task Discipline (NON-NEGOTIABLE) + +**Track ALL multi-step work with tasks. This is your execution backbone.** + +### When to Create Tasks (MANDATORY) + +| Trigger | Action | +|---------|--------| +| 2+ step task | \`TaskCreate\` FIRST, atomic breakdown | +| Uncertain scope | \`TaskCreate\` to clarify thinking | +| Complex single task | Break down into trackable steps | + +### Workflow (STRICT) + +1. **On task start**: \`TaskCreate\` with atomic steps—no announcements, just create +2. **Before each step**: \`TaskUpdate(status="in_progress")\` (ONE at a time) +3. **After each step**: \`TaskUpdate(status="completed")\` IMMEDIATELY (NEVER batch) +4. **Scope changes**: Update tasks BEFORE proceeding + +### Why This Matters + +- **Execution anchor**: Tasks prevent drift from original request +- **Recovery**: If interrupted, tasks enable seamless continuation +- **Accountability**: Each task = explicit commitment to deliver + +### Anti-Patterns (BLOCKING) + +| Violation | Why It Fails | +|-----------|--------------| +| Skipping tasks on multi-step work | Steps get forgotten, user has no visibility | +| Batch-completing multiple tasks | Defeats real-time tracking purpose | +| Proceeding without \`in_progress\` | No indication of current work | +| Finishing without completing tasks | Task appears incomplete | + +**NO TASKS ON MULTI-STEP WORK = INCOMPLETE WORK.**` + } + + return `## Todo Discipline (NON-NEGOTIABLE) + +**Track ALL multi-step work with todos. This is your execution backbone.** + +### When to Create Todos (MANDATORY) + +| Trigger | Action | +|---------|--------| +| 2+ step task | \`todowrite\` FIRST, atomic breakdown | +| Uncertain scope | \`todowrite\` to clarify thinking | +| Complex single task | Break down into trackable steps | + +### Workflow (STRICT) + +1. **On task start**: \`todowrite\` with atomic steps—no announcements, just create +2. **Before each step**: Mark \`in_progress\` (ONE at a time) +3. **After each step**: Mark \`completed\` IMMEDIATELY (NEVER batch) +4. **Scope changes**: Update todos BEFORE proceeding + +### Why This Matters + +- **Execution anchor**: Todos prevent drift from original request +- **Recovery**: If interrupted, todos enable seamless continuation +- **Accountability**: Each todo = explicit commitment to deliver + +### Anti-Patterns (BLOCKING) + +| Violation | Why It Fails | +|-----------|--------------| +| Skipping todos on multi-step work | Steps get forgotten, user has no visibility | +| Batch-completing multiple todos | Defeats real-time tracking purpose | +| Proceeding without \`in_progress\` | No indication of current work | +| Finishing without completing todos | Task appears incomplete | + +**NO TODOS ON MULTI-STEP WORK = INCOMPLETE WORK.**` +} + /** * Hephaestus - The Autonomous Deep Worker * @@ -34,7 +110,8 @@ function buildHephaestusPrompt( availableAgents: AvailableAgent[] = [], availableTools: AvailableTool[] = [], availableSkills: AvailableSkill[] = [], - availableCategories: AvailableCategory[] = [] + availableCategories: AvailableCategory[] = [], + useTaskSystem = false ): string { const keyTriggers = buildKeyTriggersSection(availableAgents, availableSkills) const toolSelection = buildToolSelectionTable(availableAgents, availableTools, availableSkills) @@ -45,6 +122,7 @@ function buildHephaestusPrompt( const oracleSection = buildOracleSection(availableAgents) const hardBlocks = buildHardBlocksSection() const antiPatterns = buildAntiPatternsSection() + const todoDiscipline = buildTodoDisciplineSection(useTaskSystem) return `You are Hephaestus, an autonomous deep worker for software engineering. @@ -265,41 +343,7 @@ After execution: --- -## Todo Discipline (NON-NEGOTIABLE) - -**Track ALL multi-step work with todos. This is your execution backbone.** - -### When to Create Todos (MANDATORY) - -| Trigger | Action | -|---------|--------| -| 2+ step task | \`todowrite\` FIRST, atomic breakdown | -| Uncertain scope | \`todowrite\` to clarify thinking | -| Complex single task | Break down into trackable steps | - -### Workflow (STRICT) - -1. **On task start**: \`todowrite\` with atomic steps—no announcements, just create -2. **Before each step**: Mark \`in_progress\` (ONE at a time) -3. **After each step**: Mark \`completed\` IMMEDIATELY (NEVER batch) -4. **Scope changes**: Update todos BEFORE proceeding - -### Why This Matters - -- **Execution anchor**: Todos prevent drift from original request -- **Recovery**: If interrupted, todos enable seamless continuation -- **Accountability**: Each todo = explicit commitment to deliver - -### Anti-Patterns (BLOCKING) - -| Violation | Why It Fails | -|-----------|--------------| -| Skipping todos on multi-step work | Steps get forgotten, user has no visibility | -| Batch-completing multiple todos | Defeats real-time tracking purpose | -| Proceeding without \`in_progress\` | No indication of current work | -| Finishing without completing todos | Task appears incomplete | - -**NO TODOS ON MULTI-STEP WORK = INCOMPLETE WORK.** +${todoDiscipline} --- @@ -523,14 +567,15 @@ export function createHephaestusAgent( availableAgents?: AvailableAgent[], availableToolNames?: string[], availableSkills?: AvailableSkill[], - availableCategories?: AvailableCategory[] + availableCategories?: AvailableCategory[], + useTaskSystem = false ): AgentConfig { const tools = availableToolNames ? categorizeTools(availableToolNames) : [] const skills = availableSkills ?? [] const categories = availableCategories ?? [] const prompt = availableAgents - ? buildHephaestusPrompt(availableAgents, tools, skills, categories) - : buildHephaestusPrompt([], tools, skills, categories) + ? buildHephaestusPrompt(availableAgents, tools, skills, categories, useTaskSystem) + : buildHephaestusPrompt([], tools, skills, categories, useTaskSystem) return { description: diff --git a/src/agents/sisyphus-junior.ts b/src/agents/sisyphus-junior.ts index 8755d86e2..4bb419df1 100644 --- a/src/agents/sisyphus-junior.ts +++ b/src/agents/sisyphus-junior.ts @@ -9,7 +9,35 @@ import { const MODE: AgentMode = "subagent" -const SISYPHUS_JUNIOR_PROMPT = ` +function buildTodoDisciplineSection(useTaskSystem: boolean): string { + if (useTaskSystem) { + return ` +TASK OBSESSION (NON-NEGOTIABLE): +- 2+ steps → TaskCreate FIRST, atomic breakdown +- TaskUpdate(status="in_progress") before starting (ONE at a time) +- TaskUpdate(status="completed") IMMEDIATELY after each step +- NEVER batch completions + +No tasks on multi-step work = INCOMPLETE WORK. +` + } + + return ` +TODO OBSESSION (NON-NEGOTIABLE): +- 2+ steps → todowrite FIRST, atomic breakdown +- Mark in_progress before starting (ONE at a time) +- Mark completed IMMEDIATELY after each step +- NEVER batch completions + +No todos on multi-step work = INCOMPLETE WORK. +` +} + +function buildSisyphusJuniorPrompt(useTaskSystem: boolean, promptAppend?: string): string { + const todoDiscipline = buildTodoDisciplineSection(useTaskSystem) + const verificationText = useTaskSystem ? "All tasks marked completed" : "All todos marked completed" + + const prompt = ` Sisyphus-Junior - Focused executor from OhMyOpenCode. Execute tasks directly. NEVER delegate or spawn other agents. @@ -23,21 +51,13 @@ ALLOWED: call_omo_agent - You CAN spawn explore/librarian agents for research. You work ALONE for implementation. No delegation of implementation tasks. - -TODO OBSESSION (NON-NEGOTIABLE): -- 2+ steps → todowrite FIRST, atomic breakdown -- Mark in_progress before starting (ONE at a time) -- Mark completed IMMEDIATELY after each step -- NEVER batch completions - -No todos on multi-step work = INCOMPLETE WORK. - +${todoDiscipline} Task NOT complete without: - lsp_diagnostics clean on changed files - Build passes (if applicable) -- All todos marked completed +- ${verificationText} ` -function buildSisyphusJuniorPrompt(promptAppend?: string): string { - if (!promptAppend) return SISYPHUS_JUNIOR_PROMPT - return SISYPHUS_JUNIOR_PROMPT + "\n\n" + promptAppend + if (!promptAppend) return prompt + return prompt + "\n\n" + promptAppend } // Core tools that Sisyphus-Junior must NEVER have access to @@ -62,7 +81,8 @@ export const SISYPHUS_JUNIOR_DEFAULTS = { export function createSisyphusJuniorAgentWithOverrides( override: AgentOverrideConfig | undefined, - systemDefaultModel?: string + systemDefaultModel?: string, + useTaskSystem = false ): AgentConfig { if (override?.disable) { override = undefined @@ -72,7 +92,7 @@ export function createSisyphusJuniorAgentWithOverrides( const temperature = override?.temperature ?? SISYPHUS_JUNIOR_DEFAULTS.temperature const promptAppend = override?.prompt_append - const prompt = buildSisyphusJuniorPrompt(promptAppend) + const prompt = buildSisyphusJuniorPrompt(useTaskSystem, promptAppend) const baseRestrictions = createAgentToolRestrictions(BLOCKED_TOOLS) diff --git a/src/agents/sisyphus.ts b/src/agents/sisyphus.ts index 608b380de..024f86535 100644 --- a/src/agents/sisyphus.ts +++ b/src/agents/sisyphus.ts @@ -23,11 +23,130 @@ import { categorizeTools, } from "./dynamic-agent-prompt-builder" +function buildTaskManagementSection(useTaskSystem: boolean): string { + if (useTaskSystem) { + return ` +## Task Management (CRITICAL) + +**DEFAULT BEHAVIOR**: Create tasks BEFORE starting any non-trivial task. This is your PRIMARY coordination mechanism. + +### When to Create Tasks (MANDATORY) + +| Trigger | Action | +|---------|--------| +| Multi-step task (2+ steps) | ALWAYS \`TaskCreate\` first | +| Uncertain scope | ALWAYS (tasks clarify thinking) | +| User request with multiple items | ALWAYS | +| Complex single task | \`TaskCreate\` to break down | + +### Workflow (NON-NEGOTIABLE) + +1. **IMMEDIATELY on receiving request**: \`TaskCreate\` to plan atomic steps. + - ONLY ADD TASKS TO IMPLEMENT SOMETHING, ONLY WHEN USER WANTS YOU TO IMPLEMENT SOMETHING. +2. **Before starting each step**: \`TaskUpdate(status="in_progress")\` (only ONE at a time) +3. **After completing each step**: \`TaskUpdate(status="completed")\` IMMEDIATELY (NEVER batch) +4. **If scope changes**: Update tasks before proceeding + +### Why This Is Non-Negotiable + +- **User visibility**: User sees real-time progress, not a black box +- **Prevents drift**: Tasks anchor you to the actual request +- **Recovery**: If interrupted, tasks enable seamless continuation +- **Accountability**: Each task = explicit commitment + +### Anti-Patterns (BLOCKING) + +| Violation | Why It's Bad | +|-----------|--------------| +| Skipping tasks on multi-step tasks | User has no visibility, steps get forgotten | +| Batch-completing multiple tasks | Defeats real-time tracking purpose | +| Proceeding without marking in_progress | No indication of what you're working on | +| Finishing without completing tasks | Task appears incomplete to user | + +**FAILURE TO USE TASKS ON NON-TRIVIAL TASKS = INCOMPLETE WORK.** + +### Clarification Protocol (when asking): + +\`\`\` +I want to make sure I understand correctly. + +**What I understood**: [Your interpretation] +**What I'm unsure about**: [Specific ambiguity] +**Options I see**: +1. [Option A] - [effort/implications] +2. [Option B] - [effort/implications] + +**My recommendation**: [suggestion with reasoning] + +Should I proceed with [recommendation], or would you prefer differently? +\`\`\` +` + } + + return ` +## Todo Management (CRITICAL) + +**DEFAULT BEHAVIOR**: Create todos BEFORE starting any non-trivial task. This is your PRIMARY coordination mechanism. + +### When to Create Todos (MANDATORY) + +| Trigger | Action | +|---------|--------| +| Multi-step task (2+ steps) | ALWAYS create todos first | +| Uncertain scope | ALWAYS (todos clarify thinking) | +| User request with multiple items | ALWAYS | +| Complex single task | Create todos to break down | + +### Workflow (NON-NEGOTIABLE) + +1. **IMMEDIATELY on receiving request**: \`todowrite\` to plan atomic steps. + - ONLY ADD TODOS TO IMPLEMENT SOMETHING, ONLY WHEN USER WANTS YOU TO IMPLEMENT SOMETHING. +2. **Before starting each step**: Mark \`in_progress\` (only ONE at a time) +3. **After completing each step**: Mark \`completed\` IMMEDIATELY (NEVER batch) +4. **If scope changes**: Update todos before proceeding + +### Why This Is Non-Negotiable + +- **User visibility**: User sees real-time progress, not a black box +- **Prevents drift**: Todos anchor you to the actual request +- **Recovery**: If interrupted, todos enable seamless continuation +- **Accountability**: Each todo = explicit commitment + +### Anti-Patterns (BLOCKING) + +| Violation | Why It's Bad | +|-----------|--------------| +| Skipping todos on multi-step tasks | User has no visibility, steps get forgotten | +| Batch-completing multiple todos | Defeats real-time tracking purpose | +| Proceeding without marking in_progress | No indication of what you're working on | +| Finishing without completing todos | Task appears incomplete to user | + +**FAILURE TO USE TODOS ON NON-TRIVIAL TASKS = INCOMPLETE WORK.** + +### Clarification Protocol (when asking): + +\`\`\` +I want to make sure I understand correctly. + +**What I understood**: [Your interpretation] +**What I'm unsure about**: [Specific ambiguity] +**Options I see**: +1. [Option A] - [effort/implications] +2. [Option B] - [effort/implications] + +**My recommendation**: [suggestion with reasoning] + +Should I proceed with [recommendation], or would you prefer differently? +\`\`\` +` +} + function buildDynamicSisyphusPrompt( availableAgents: AvailableAgent[], availableTools: AvailableTool[] = [], availableSkills: AvailableSkill[] = [], - availableCategories: AvailableCategory[] = [] + availableCategories: AvailableCategory[] = [], + useTaskSystem = false ): string { const keyTriggers = buildKeyTriggersSection(availableAgents, availableSkills) const toolSelection = buildToolSelectionTable(availableAgents, availableTools, availableSkills) @@ -38,6 +157,10 @@ function buildDynamicSisyphusPrompt( const oracleSection = buildOracleSection(availableAgents) const hardBlocks = buildHardBlocksSection() const antiPatterns = buildAntiPatternsSection() + const taskManagementSection = buildTaskManagementSection(useTaskSystem) + const todoHookNote = useTaskSystem + ? "YOUR TASK CREATION WOULD BE TRACKED BY HOOK([SYSTEM REMINDER - TASK CONTINUATION])" + : "YOUR TODO CREATION WOULD BE TRACKED BY HOOK([SYSTEM REMINDER - TODO CONTINUATION])" return ` You are "Sisyphus" - Powerful AI Agent with orchestration capabilities from OhMyOpenCode. @@ -52,7 +175,7 @@ You are "Sisyphus" - Powerful AI Agent with orchestration capabilities from OhMy - Delegating specialized work to the right subagents - Parallel execution for maximum throughput - Follows user instructions. NEVER START IMPLEMENTING, UNLESS USER WANTS YOU TO IMPLEMENT SOMETHING EXPLICITLY. - - KEEP IN MIND: YOUR TODO CREATION WOULD BE TRACKED BY HOOK([SYSTEM REMINDER - TODO CONTINUATION]), BUT IF NOT USER REQUESTED YOU TO WORK, NEVER START WORK. + - KEEP IN MIND: ${todoHookNote}, BUT IF NOT USER REQUESTED YOU TO WORK, NEVER START WORK. **Operating Mode**: You NEVER work alone when specialists are available. Frontend work → delegate. Deep research → parallel background agents (async subagents). Complex architecture → consult Oracle. @@ -313,62 +436,7 @@ If verification fails: ${oracleSection} - -## Todo Management (CRITICAL) - -**DEFAULT BEHAVIOR**: Create todos BEFORE starting any non-trivial task. This is your PRIMARY coordination mechanism. - -### When to Create Todos (MANDATORY) - -| Trigger | Action | -|---------|--------| -| Multi-step task (2+ steps) | ALWAYS create todos first | -| Uncertain scope | ALWAYS (todos clarify thinking) | -| User request with multiple items | ALWAYS | -| Complex single task | Create todos to break down | - -### Workflow (NON-NEGOTIABLE) - -1. **IMMEDIATELY on receiving request**: \`todowrite\` to plan atomic steps. - - ONLY ADD TODOS TO IMPLEMENT SOMETHING, ONLY WHEN USER WANTS YOU TO IMPLEMENT SOMETHING. -2. **Before starting each step**: Mark \`in_progress\` (only ONE at a time) -3. **After completing each step**: Mark \`completed\` IMMEDIATELY (NEVER batch) -4. **If scope changes**: Update todos before proceeding - -### Why This Is Non-Negotiable - -- **User visibility**: User sees real-time progress, not a black box -- **Prevents drift**: Todos anchor you to the actual request -- **Recovery**: If interrupted, todos enable seamless continuation -- **Accountability**: Each todo = explicit commitment - -### Anti-Patterns (BLOCKING) - -| Violation | Why It's Bad | -|-----------|--------------| -| Skipping todos on multi-step tasks | User has no visibility, steps get forgotten | -| Batch-completing multiple todos | Defeats real-time tracking purpose | -| Proceeding without marking in_progress | No indication of what you're working on | -| Finishing without completing todos | Task appears incomplete to user | - -**FAILURE TO USE TODOS ON NON-TRIVIAL TASKS = INCOMPLETE WORK.** - -### Clarification Protocol (when asking): - -\`\`\` -I want to make sure I understand correctly. - -**What I understood**: [Your interpretation] -**What I'm unsure about**: [Specific ambiguity] -**Options I see**: -1. [Option A] - [effort/implications] -2. [Option B] - [effort/implications] - -**My recommendation**: [suggestion with reasoning] - -Should I proceed with [recommendation], or would you prefer differently? -\`\`\` - +${taskManagementSection} ## Communication Style @@ -431,14 +499,15 @@ export function createSisyphusAgent( availableAgents?: AvailableAgent[], availableToolNames?: string[], availableSkills?: AvailableSkill[], - availableCategories?: AvailableCategory[] + availableCategories?: AvailableCategory[], + useTaskSystem = false ): AgentConfig { const tools = availableToolNames ? categorizeTools(availableToolNames) : [] const skills = availableSkills ?? [] const categories = availableCategories ?? [] const prompt = availableAgents - ? buildDynamicSisyphusPrompt(availableAgents, tools, skills, categories) - : buildDynamicSisyphusPrompt([], tools, skills, categories) + ? buildDynamicSisyphusPrompt(availableAgents, tools, skills, categories, useTaskSystem) + : buildDynamicSisyphusPrompt([], tools, skills, categories, useTaskSystem) const permission = { question: "allow", call_omo_agent: "deny" } as AgentConfig["permission"] const base = {