Files
oh-my-opencode/src/plugin/system-transform.ts
T
herjarsa dc2e082ac9 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 }).
2026-05-19 18:53:24 +02:00

33 lines
1.4 KiB
TypeScript

import type { DefaultModeConfig } from "../config/schema/default-mode"
const ULTRAWORK_MODE_TAG = "<ultrawork-mode>"
export function createSystemTransformHandler(
defaultMode?: DefaultModeConfig,
getUltraworkMessage?: (agentName?: string, modelID?: string) => string,
): (
input: { sessionID?: string; model: { id: string; providerID: string; [key: string]: unknown } },
output: { system: string[] },
) => Promise<void> {
return async (input, output): Promise<void> => {
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
// (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
const modelID = input.model?.id
const ultraworkMessage = getUltraworkMessage("sisyphus", modelID)
if (!ultraworkMessage) return
output.system.push(ultraworkMessage)
}
}