fix(config): properly handle prompt_append for Prometheus agent (#1271)

- Extract prompt_append from override and append to prompt instead of shallow spread
- Add test verifying prompt_append is appended, not overwriting base prompt
- Fixes #723

Co-authored-by: Gabriel Ečegi <gabriel-ecegi@users.noreply.github.com>
This commit is contained in:
gabriel-ecegi 2026-02-01 11:11:49 +01:00 committed by GitHub
parent 6389da3cd6
commit ffbca5e48e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 3 deletions

View File

@ -395,6 +395,43 @@ describe("Prometheus direct override priority over category", () => {
expect(agents.prometheus).toBeDefined()
expect(agents.prometheus.temperature).toBe(0.1)
})
test("prometheus prompt_append is appended to base prompt", async () => {
// #given - prometheus override with prompt_append
const customInstructions = "## Custom Project Rules\nUse max 2 commits."
const pluginConfig: OhMyOpenCodeConfig = {
sisyphus_agent: {
planner_enabled: true,
},
agents: {
prometheus: {
prompt_append: customInstructions,
},
},
}
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-5",
agent: {},
}
const handler = createConfigHandler({
ctx: { directory: "/tmp" },
pluginConfig,
modelCacheState: {
anthropicContext1MEnabled: false,
modelContextLimitsCache: new Map(),
},
})
// #when
await handler(config)
// #then - prompt_append is appended to base prompt, not overwriting it
const agents = config.agent as Record<string, { prompt?: string }>
expect(agents.prometheus).toBeDefined()
expect(agents.prometheus.prompt).toContain("Prometheus")
expect(agents.prometheus.prompt).toContain(customInstructions)
expect(agents.prometheus.prompt!.endsWith(customInstructions)).toBe(true)
})
})
describe("Deadlock prevention - fetchAvailableModels must not receive client", () => {

View File

@ -301,9 +301,19 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
: {}),
};
agentConfig["prometheus"] = prometheusOverride
? { ...prometheusBase, ...prometheusOverride }
: prometheusBase;
// Properly handle prompt_append for Prometheus
// Extract prompt_append and append it to prompt instead of shallow spread
// Fixes: https://github.com/code-yeongyu/oh-my-opencode/issues/723
if (prometheusOverride) {
const { prompt_append, ...restOverride } = prometheusOverride as Record<string, unknown> & { prompt_append?: string };
const merged = { ...prometheusBase, ...restOverride };
if (prompt_append && merged.prompt) {
merged.prompt = merged.prompt + "\n" + prompt_append;
}
agentConfig["prometheus"] = merged;
} else {
agentConfig["prometheus"] = prometheusBase;
}
}
const filteredConfigAgents = configAgent