(patterns: FailurePattern[], topK = 5)
| 104 | |
| 105 | /** Build the system-prompt block from confirmed patterns (top-K). Empty when none. */ |
| 106 | export function buildLessonsBlock(patterns: FailurePattern[], topK = 5): string { |
| 107 | if (patterns.length === 0) return ''; |
| 108 | const lines = ['# Learned cautions (from your own repeated failures)', '', |
| 109 | 'These mistakes have recurred across past tasks. Avoid repeating them:', '']; |
| 110 | for (const p of patterns.slice(0, topK)) lines.push(`- ${buildLesson(p)}`); |
| 111 | return lines.join('\n'); |
| 112 | } |
| 113 | |
| 114 | // ── I/O ────────────────────────────────────────────────────────────────────── |
| 115 |
no test coverage detected