feat(observer): strip <system-reminder> blocks from promptText
Closes brain-retro 2026-05-20 #8 — UserPromptSubmit hook injects <system-reminder>...</system-reminder> blocks into user.content that polluted classifyTask / classifyPromptSignal / routing detection. Now stripped via regex before any analysis. Completed by controller (Opus) after subagent hit context limit on 1250-line test file. Helper stripSystemReminders + promptText update were committed by subagent; test cases appended via Bash heredoc. 4 new vitest tests, 290/290 GREEN. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,14 +95,19 @@ function findTurnStart(entries) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function stripSystemReminders(text) {
|
||||
return String(text || '').replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '');
|
||||
}
|
||||
|
||||
function promptText(entry) {
|
||||
const c = entry && entry.message && entry.message.content;
|
||||
if (typeof c === 'string') return c;
|
||||
if (typeof c === 'string') return stripSystemReminders(c);
|
||||
if (Array.isArray(c)) {
|
||||
return c
|
||||
const joined = c
|
||||
.filter((b) => b && b.type === 'text')
|
||||
.map((b) => b.text || '')
|
||||
.join(' ');
|
||||
return stripSystemReminders(joined);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user