| name | completion-marker-enforcement |
| description | Protocol enforcement and validation patterns for completion marker output. Use when marking tasks complete to ensure 100% protocol compliance. Provides validation patterns, system-level workarounds, and recovery strategies for completion marker protocol violations. |
Completion Marker Protocol Enforcement
Protocol enforcement and validation patterns to ensure 100% compliance with completion marker requirements. Prevents orchestrator detection failures and parsing issues.
Overview
Problem: Despite explicit instructions, completion markers are streamed character-by-character in 100% of analyzed tasks, causing protocol violations.
Solution: Strict protocol enforcement with validation patterns, system-level workarounds, and recovery strategies.
Impact: 100% protocol compliance, eliminates parsing issues, reduces token waste (23 tokens → 1 token)
Protocol Requirements
The Completion Marker Protocol
Required Format: <ralph>COMPLETE</ralph>
Required Behavior:
- Output as SINGLE, COMPLETE, ATOMIC STRING
- Output in ONE response (not split across responses)
- Output in assistant response text (not shell commands)
- Output at end of response (after all verification)
- NO streaming (character-by-character output is FORBIDDEN)
Why Protocol Matters
Orchestrator Detection:
- Orchestrator scans for complete marker pattern
- Streaming causes detection failures
- Partial tokens don't match detection pattern
- Multiple tokens confuse detection logic
Token Efficiency:
- Atomic output: 1 token
- Streaming output: 4-23 tokens
- Waste: 22 tokens per completion
Reliability:
- Atomic output: 100% detection rate
- Streaming output: 0-50% detection rate (varies by system)
Validation Patterns
Pattern 1: Pre-Output Validation
Before outputting marker, validate:
## Pre-Output Validation
1. **Marker String Ready**:
- Complete string: "<ralph>COMPLETE</ralph>"
- Not partial: "<ralph" or "COMPLETE" or "</ralph>"
- Format correct: No typos or missing characters
2. **Output Method Valid**:
- Will output in assistant response text ✅
- Will NOT use shell echo command ❌
- Will NOT use tool output ❌
3. **Output Structure Valid**:
- Marker will be at end of response ✅
- No tool calls after marker ✅
- No cleanup operations after marker ✅
4. **Atomic Output Guaranteed**:
- Complete marker is buffered ✅
- No streaming will occur ✅
- Single token output ✅
5. **All Operations Complete**:
- No pending tool calls ✅
- All verification complete ✅
- All success criteria met ✅
Pattern 2: Response Structure Validation
Correct Response Structure:
## Task Complete
All functionality has been implemented and verified.
- [x] TypeScript compilation passes
- [x] Browser testing completed
- [x] All success criteria met
<ralph>COMPLETE</ralph>
Incorrect Response Structures:
# ❌ WRONG: Marker split across lines
<ralph
>COMPLETE
</ralph>
# ❌ WRONG: Marker with intermediate text
<ralph>COMPLETE</ralph>
# Additional cleanup operations
# ❌ WRONG: Marker in code block
COMPLETE
# ❌ WRONG: Marker before verification
<ralph>COMPLETE</ralph>
# Verification details...
Pattern 3: Atomic Output Guarantee
Ensure atomic output:
-
Buffer Complete Marker:
const marker = "<ralph>COMPLETE</ralph>";
// Marker is complete, not partial
-
Verify Buffer Completeness:
if (marker === "<ralph>COMPLETE</ralph>" && marker.length === 24) {
// Marker is complete
}
-
Output Atomically:
// Output complete marker in single operation
{marker}
System-Level Workarounds
Workaround 1: Minimal Context Pattern
When streaming risk is high, use minimal context:
Complete. <ralph>COMPLETE</ralph>
Why This Works:
- Minimal text reduces token boundary issues
- Short context before marker
- Lower chance of streaming
Workaround 2: Single-Line Pattern
Place marker on same line as completion text:
All tasks complete. <ralph>COMPLETE</ralph>
Why This Works:
- Single line reduces line break issues
- Immediate marker placement
- Reduced streaming risk
Workaround 3: Force Atomic Output
Use explicit atomic output pattern:
## Completion
Task complete. Marker: <ralph>COMPLETE</ralph>
Why This Works:
- Explicit marker placement
- Clear completion signal
- Reduced ambiguity
Workaround 4: Separate Response
If previous response had issues, use separate response:
# Response 1: Verification
All verification complete. All success criteria met.
# Response 2: Marker only
<ralph>COMPLETE</ralph>
Why This Works:
- Isolates marker from other content
- Reduces streaming risk
- Clear separation
Common Failure Modes
Failure Mode 1: Character-by-Character Streaming
Symptom: Marker appears as multiple tokens:
<
ral
ph
>COMPLETE</ralph>
Cause: System streams output token-by-token
Prevention:
- Use minimal context before marker
- Buffer complete marker before output
- Use single-line pattern
Recovery:
- Output marker again in next response
- Use minimal context pattern
- Verify orchestrator detection
Failure Mode 2: Incremental Output
Symptom: Marker split across multiple lines:
<ralph
>COMPLETE
</ralph>
Cause: Line breaks in marker output
Prevention:
- Keep marker on single line
- Use minimal context
- Avoid code blocks before marker
Recovery:
- Re-output marker in single line
- Use single-line pattern
- Verify detection
Failure Mode 3: Shell Command Usage
Symptom: Marker in shell output:
echo "<ralph>COMPLETE</ralph>"
Cause: Using shell commands instead of assistant response
Prevention:
- Always output in assistant response text
- Never use echo or shell commands
- Include marker in markdown response
Recovery:
- Output marker in assistant response
- Not in shell command output
- Verify orchestrator can see it
Failure Mode 4: Tool Call After Marker
Symptom: Tool calls occur after marker output
Cause: Marker output before operations complete
Prevention:
- Complete all tool calls first
- Verify all operations done
- Then output marker
Recovery:
- Complete remaining operations
- Re-output marker after completion
- Verify no pending operations
Recovery Strategies
Strategy 1: Immediate Re-Output
If streaming detected, re-output immediately:
# Previous response had streaming issue
# Re-outputting marker atomically:
<ralph>COMPLETE</ralph>
Strategy 2: Verification and Re-Output
Verify task completion, then re-output:
## Verification Complete
All tasks verified complete. Re-outputting marker:
<ralph>COMPLETE</ralph>
Strategy 3: Minimal Marker Response
Use minimal response with just marker:
<ralph>COMPLETE</ralph>
When to Use:
- Previous response had issues
- Need to ensure atomic output
- Verification already complete
Validation Checklist
Before outputting marker, verify:
Only after ALL items checked, output marker.
Best Practices
- Always buffer complete marker before outputting
- Use minimal context before marker to reduce streaming risk
- Place marker at end of response after all verification
- Never use shell commands for marker output
- Verify atomic output using validation patterns
- Use workarounds when streaming risk is high
- Recover immediately if streaming detected
- Document issues in progress.txt if streaming occurs
Integration with Other Skills
- completion-marker-optimization: Uses this skill for enforcement patterns
- task-verification-workflow: Validates marker output before completion
- pre-implementation-check: Ensures marker protocol compliance
Related Skills
completion-marker-optimization - Optimization patterns
task-verification-workflow - Verification before marker
pre-implementation-check - Pre-task validation
Remember
- Protocol is critical: 100% compliance required
- Atomic output: Single token, not streamed
- Validation first: Check all requirements before output
- Use workarounds: When streaming risk is high
- Recover immediately: If streaming detected
- Document issues: If protocol violations occur