fix(default-mode): skip ultrawork system prompt when ralph_loop is also enabled

When both default_mode.ultrawork and default_mode.ralph_loop are true,
the ralph loop handles ultrawork behavior via its continuation mechanism
(prepends 'ultrawork' to each iteration prompt). Injecting the ultrawork
system prompt on top would be redundant — the continuation prompt
re-triggers keyword detection, which defeats the purpose of invisible
system prompt injection.

The ultrawork flag still controls loop behavior (500 max iterations +
Oracle verification gate) via chat-message.ts startLoop({ ultrawork }).
This commit is contained in:
herjarsa
2026-05-19 18:53:24 +02:00
parent 2f1380f52d
commit dc2e082ac9
+7
View File
@@ -12,6 +12,13 @@ export function createSystemTransformHandler(
return async (input, output): Promise<void> => { return async (input, output): Promise<void> => {
if (!defaultMode?.ultrawork || !getUltraworkMessage) return if (!defaultMode?.ultrawork || !getUltraworkMessage) return
// When ralph_loop is also enabled, skip system prompt injection: the loop's
// own continuation mechanism handles ultrawork re-injection on each iteration.
// Injecting both would be redundant — the continuation prompt prepends
// "ultrawork" and re-triggers keyword detection, defeating invisibility.
// The `ultrawork` flag still controls loop behavior (500 iters + Oracle gate).
if (defaultMode?.ralph_loop) return
// Avoid re-injecting if the ultrawork prompt is already in the system prompt // Avoid re-injecting if the ultrawork prompt is already in the system prompt
// (e.g. after compaction the system prompt is rebuilt and this hook fires again) // (e.g. after compaction the system prompt is rebuilt and this hook fires again)
if (output.system.some((part) => part.includes(ULTRAWORK_MODE_TAG))) return if (output.system.some((part) => part.includes(ULTRAWORK_MODE_TAG))) return