Skip to content

Commit 9097d37

Browse files
committed
fix(system-prompt): restore todo workflow section - agents need explicit guidance
**Problem:** After removing MULTI-STEP REQUESTS - TODO LIST WORKFLOW section as redundant with orchestrator, user testing revealed agents no longer followed correct todo workflow sequence. While orchestrator provides runtime reminders, agents rely on the static instructions as educational foundation. **Solution:** Reverted todo workflow section removal. Agents need both: 1. Static instructions (system prompt) - educational foundation & reference 2. Runtime reminders (orchestrator) - reinforcement during execution **Changes:** ✅ RESTORED: MULTI-STEP REQUESTS - TODO LIST WORKFLOW section ✅ KEPT: Dead code removals (buildWorkflowContinuationProtocol, buildThinkToolGuidance) ✅ KEPT: Simplifications (tool responsibility, think tool, multi-step handling) ✅ UPDATED: Version comment to reflect lesson learned ✅ UPDATED: SYSTEM_PROMPT_EVOLUTION.md with reversion rationale **Lesson Learned:** Runtime enforcement supplements but does NOT replace static educational guidance. Even with perfect runtime reminders, agents need reference documentation in the base prompt for workflow understanding. **Token Impact:** - Original estimate: ~1150 token savings - After reversion: ~720 token savings (~15% reduction) - Restored: ~430 tokens (todo workflow section) **Testing:** ✅ Build: PASS ✅ User validation: Agents now follow correct workflow sequence
1 parent 111e1e5 commit 9097d37

2 files changed

Lines changed: 55 additions & 27 deletions

File tree

Sources/ConfigurationSystem/SystemPromptConfiguration.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public struct SystemPromptConfiguration: Codable, Identifiable, Hashable, Sendab
5757
public var autoEnableDynamicIterations: Bool
5858

5959
/// Current version of the prompt system (increment when making breaking changes).
60-
/// Version 16: Removed redundant behavioral instructions now handled by AgentOrchestrator's
61-
/// context-aware continuation guidance system. System prompt now focuses on identity and
62-
/// capabilities; orchestrator handles workflow enforcement at runtime.
60+
/// Version 16: Simplified verbose sections (tool responsibility, think tool, multi-step handling).
61+
/// Removed dead code (buildWorkflowContinuationProtocol, buildThinkToolGuidance).
62+
/// NOTE: Kept todo workflow instructions - agents need explicit guidance despite orchestrator.
6363
public static let currentVersion = 16
6464

6565
public init(
@@ -509,6 +509,36 @@ private static func buildSAMSpecificPatterns() -> String {
509509
510510
**Sequential Lists:** One item per message, emit continue after each (except last → complete).
511511
512+
MULTI-STEP REQUESTS - TODO LIST WORKFLOW:
513+
514+
**When to use todos:** Multi-step tasks that benefit from visible progress tracking
515+
516+
**Starting fresh (no todos yet):**
517+
1. FIRST: Create todo list with todo_operations(operation: "write", todoList: [...])
518+
- Set first todo: "in-progress"
519+
- Set remaining todos: "not-started"
520+
2. Then proceed with workflow below
521+
522+
**Working with existing todos:**
523+
1. Do the work for current in-progress todo
524+
2. Mark it completed: todo_operations(operation: "update", todoUpdates: [{"id": X, "status": "completed"}])
525+
3. Mark next todo in-progress: todo_operations(operation: "update", todoUpdates: [{"id": Y, "status": "in-progress"}])
526+
4. Repeat until all complete
527+
528+
**CRITICAL RULES:**
529+
- ALWAYS create todos FIRST before trying to update them (NEVER call update when no todos exist)
530+
- You MUST call todo_operations(update) to change todo status - the system cannot infer status from your text
531+
- When completing a todo: Mark it done with the tool, then move to next todo - do NOT repeat the work in your response
532+
- Each todo gets ONE completion response - mark done and move forward
533+
534+
**Anti-duplication:**
535+
- After completing Todo 1: Mark complete, start Todo 2, work on Todo 2
536+
- Do NOT: Complete Todo 1, mark done, then re-summarize Todo 1's results again
537+
- Tool call = progress indicator, not invitation to repeat output
538+
539+
**Before Complete:** Verify ALL requested items delivered. If user asked for N things, confirm N things done.
540+
541+
512542
## Data Visualization Protocol (CRITICAL)
513543
514544
**Mermaid Diagram Types:** flowchart, sequenceDiagram, classDiagram, stateDiagram, erDiagram, gantt, pie, bar, journey, mindmap, timeline, quadrantChart, requirementDiagram, gitGraph, xychart-beta (bar/line charts).

project-docs/SYSTEM_PROMPT_EVOLUTION.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,32 @@
88

99
### Version 16 (January 4, 2026)
1010

11-
**Change:** Removed redundant behavioral instructions now handled by AgentOrchestrator
11+
**Change:** Simplified verbose sections, removed dead code
1212

1313
**Rationale:**
14-
The AgentOrchestrator now provides intelligent, context-aware continuation guidance at runtime through:
15-
1. 4 adaptive guidance variants based on (todos exist × tools used last iteration)
16-
2. TodoReminderInjector for todo-specific workflow reminders
17-
3. Fresh todo state reads before every workflow decision
14+
Initial plan was to remove todo workflow instructions as redundant with AgentOrchestrator.
15+
**However, testing revealed agents need explicit todo workflow guidance in system prompt.**
16+
While orchestrator provides runtime reminders, the static instructions serve as educational
17+
foundation that agents rely on. Reverted todo workflow section after user testing.
1818

19-
This makes static behavioral instructions in the system prompt redundant. The system prompt should define WHO SAM is and WHAT SAM can do; the orchestrator handles HOW to behave during workflow execution.
19+
**Final Changes:**
2020

21-
**Removals:**
21+
**KEPT (After Reversion):**
2222
1. **MULTI-STEP REQUESTS - TODO LIST WORKFLOW section** (buildSAMSpecificPatterns)
23-
- Entire todo workflow instructions removed (~350 tokens)
24-
- **Why:** AgentOrchestrator Variants 1 & 2 provide identical workflow guidance at runtime
25-
- **Coverage:** Orchestrator enforces "mark in-progress → do work → mark completed" every iteration
23+
- **Initially removed** as redundant with AgentOrchestrator
24+
- **REVERTED** after user testing showed agents need explicit guidance
25+
- **Lesson:** Runtime reminders supplement but don't replace educational foundation
26+
- Static instructions serve as reference agents rely on for workflow understanding
2627

27-
2. **buildWorkflowContinuationProtocol() function** (dead code)
28+
**REMOVED (Dead Code):**
29+
1. **buildWorkflowContinuationProtocol() function**
2830
- Entire function removed (~500 tokens)
2931
- **Why:** Never called, redundant with orchestrator's 4 continuation variants
30-
- **Coverage:** Orchestrator provides context-aware guidance for WITH/WITHOUT todos scenarios
3132

32-
3. **buildThinkToolGuidance() function** (dead code)
33+
2. **buildThinkToolGuidance() function**
3334
- Entire function removed (~80 tokens)
3435
- **Why:** Never called, guidance already in buildSAMSpecificPatterns
3536

36-
4. **Anti-duplication guidance** (buildSAMSpecificPatterns)
37-
- Removed duplicate output warnings (~80 tokens)
38-
- **Why:** TodoReminderInjector enforces "DO NOT repeat the work"
39-
- **Coverage:** Runtime reminder system handles this
40-
4137
**Simplifications:**
4238

4339
1. **Tool Responsibility** (buildToolUsage)
@@ -58,7 +54,8 @@ This makes static behavioral instructions in the system prompt redundant. The sy
5854
- **Why:** Educational value remains, but enforcement language removed
5955
- **Token Savings:** ~40 tokens
6056

61-
**Total Token Savings:** ~1150 tokens (~20-25% reduction from affected sections)
57+
**Total Token Savings:** ~720 tokens (~15% reduction from affected sections)
58+
**Note:** Original estimate was ~1150 tokens, but todo workflow section was reverted (~430 tokens restored)
6259

6360
**What Remains (Preserved Components):**
6461
- ✅ Core Identity (WHO SAM is)
@@ -74,18 +71,19 @@ This makes static behavioral instructions in the system prompt redundant. The sy
7471
- ✅ Dynamic Iterations (iteration monitoring, only when enabled)
7572
- ✅ Two-Phase Workflow (pattern recommendation)
7673
- ✅ Sequential Lists (pattern guidance)
74+
-**Todo Workflow Instructions (KEPT after reversion)**
7775

7876
**Behavioral Impact:**
79-
- **No loss of functionality** - Orchestrator enforces all removed instructions at runtime
80-
- **Better separation of concerns** - Static prompt = identity/capabilities, Runtime guidance = workflow behavior
81-
- **More maintainable** - Single source of truth for behavioral rules (orchestrator)
82-
- **Context-aware** - Orchestrator adapts guidance based on current workflow state
77+
- **Todo workflow preserved** - Agents need explicit static guidance despite runtime reminders
78+
- **Dead code removed** - Cleaner codebase
79+
- **Verbose sections simplified** - Clearer, more concise
80+
- **No breaking changes** - All functionality intact
8381

8482
**Testing Results:**
8583
- ✅ Build: PASS (`make build-debug`)
8684
- ✅ No compile errors
8785
- ✅ System prompt generates correctly
88-
- Manual testing pending (Test Cases 1-5 from analysis document)
86+
- ✅ User testing: Agents work correctly with todo workflow restored
8987

9088
**Files Modified:**
9189
- `Sources/ConfigurationSystem/SystemPromptConfiguration.swift`

0 commit comments

Comments
 (0)