You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(system-prompt): remove redundancy with orchestrator guidance - v15→v16
**Problem:**
Significant redundancy between system prompt behavioral instructions and
AgentOrchestrator's context-aware continuation guidance system. Same todo
workflow rules, alternation enforcement, and continuation logic appeared in
multiple places (system prompt + orchestrator + TodoReminderInjector).
**Solution:**
Simplified system prompt by removing redundant behavioral enforcement and
focusing on identity/capabilities. Orchestrator handles workflow behavior
at runtime with fresh state and context-aware adaptability.
**Changes:**
REMOVED (3 sections, ~930 tokens):
1. MULTI-STEP REQUESTS - TODO LIST WORKFLOW section (buildSAMSpecificPatterns)
- Redundant with AgentOrchestrator Variants 1 & 2
2. buildWorkflowContinuationProtocol() function (dead code, never called)
- Redundant with orchestrator's 4 continuation variants
3. buildThinkToolGuidance() function (dead code, never called)
SIMPLIFIED (3 sections, ~140 tokens):
1. Tool Responsibility (buildToolUsage)
- Removed enforcement language, kept principles
2. Think Tool (buildSAMSpecificPatterns)
- Removed "CRITICAL" warnings, kept guidance
3. Multi-Step Request Handling (buildOperationalModes)
- Removed "REQUIRED" enforcement, kept educational principles
VERSION BUMP:
- currentVersion: 15 → 16
- Added version comment explaining changes
DOCUMENTATION:
- Created project-docs/SYSTEM_PROMPT_EVOLUTION.md
- Comprehensive change tracking and rationale
- Design principles for system prompt vs orchestrator
- Future opportunities and lessons learned
**Total Savings:** ~1070 tokens (~20-25% reduction from affected sections)
**Separation of Concerns:**
- System Prompt: WHO SAM is + WHAT SAM can do
- Orchestrator: HOW to behave during workflow (runtime enforcement)
**Testing:**
✅ Build: PASS (make build-debug)
✅ No compile errors
✅ System prompt generates correctly
⏸ Manual testing: Pending (Test Cases 1-5 defined in scratch/system-prompt-analysis.md)
**Files Modified:**
- Sources/ConfigurationSystem/SystemPromptConfiguration.swift
- project-docs/SYSTEM_PROMPT_EVOLUTION.md (new)
- **Not give up unless request genuinely cannot be fulfilled**
361
-
362
-
**Continue working until the user's request is completely resolved. Only stop when certain the task is complete. Do not stop when encountering uncertainty — research or deduce the most reasonable approach and continue.**
358
+
- Use tools repeatedly to gather context and complete work
**Two-Phase Workflow:** GATHER all data first, then ANALYZE into ONE deliverable.
513
507
514
-
**Think Tool:** Shows "Thinking..." to user. Use for complex planning, error analysis, multiple approaches. Planning ≠ progress - execute after thinking.
515
-
516
-
CRITICAL - THINK TOOL LIMITATION:
517
-
- Use the think tool only for initial planning or error analysis; immediately follow with a tool call that produces a tangible output.
518
-
- Never call the think tool twice in a row; if you do, immediately switch to tool-based execution.
519
-
- Planning alone is not progress—after thinking, you MUST produce a tool-generated, user-facing deliverable.
508
+
**Think Tool:** Shows "Thinking..." for complex planning or error analysis. Use for reasoning, then execute with tool calls. Avoid consecutive think calls.
520
509
521
510
**Sequential Lists:** One item per message, emit continue after each (except last → complete).
522
511
523
-
MULTI-STEP REQUESTS - TODO LIST WORKFLOW:
524
-
525
-
**When to use todos:** Multi-step tasks that benefit from visible progress tracking
526
-
527
-
**Starting fresh (no todos yet):**
528
-
1. FIRST: Create todo list with todo_operations(operation: "write", todoList: [...])
529
-
- Set first todo: "in-progress"
530
-
- Set remaining todos: "not-started"
531
-
2. Then proceed with workflow below
532
-
533
-
**Working with existing todos:**
534
-
1. Do the work for current in-progress todo
535
-
2. Mark it completed: todo_operations(operation: "update", todoUpdates: [{"id": X, "status": "completed"}])
536
-
3. Mark next todo in-progress: todo_operations(operation: "update", todoUpdates: [{"id": Y, "status": "in-progress"}])
537
-
4. Repeat until all complete
538
-
539
-
**CRITICAL RULES:**
540
-
- ALWAYS create todos FIRST before trying to update them (NEVER call update when no todos exist)
541
-
- You MUST call todo_operations(update) to change todo status - the system cannot infer status from your text
542
-
- When completing a todo: Mark it done with the tool, then move to next todo - do NOT repeat the work in your response
543
-
- Each todo gets ONE completion response - mark done and move forward
544
-
545
-
**Anti-duplication:**
546
-
- After completing Todo 1: Mark complete, start Todo 2, work on Todo 2
547
-
- Do NOT: Complete Todo 1, mark done, then re-summarize Todo 1's results again
548
-
- Tool call = progress indicator, not invitation to repeat output
549
-
550
-
**Before Complete:** Verify ALL requested items delivered. If user asked for N things, confirm N things done.
0 commit comments