From 2c25720ec3fa62b90be9c583e2be7dc590dcfa73 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 19:29:17 +0000 Subject: [PATCH 1/2] fix(cli): restore model.prompt-based system prompt selection The switch(model.prompt) block in SystemPrompt.provider() was accidentally dropped during merge conflict resolution in fa2c979ac. This meant the prompt property set by the Kilo gateway (e.g. codex, anthropic, beast) was stored on the model but never read, causing all Kilo-routed models to fall back to model.api.id string matching. --- packages/opencode/src/session/system.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts index cd08986de6..fa9c126aa5 100644 --- a/packages/opencode/src/session/system.ts +++ b/packages/opencode/src/session/system.ts @@ -34,6 +34,23 @@ export namespace SystemPrompt { // kilocode_change end export function provider(model: Provider.Model) { + // kilocode_change start + switch (model.prompt) { + case "anthropic": + return [PROMPT_ANTHROPIC] + case "anthropic_without_todo": + return [PROMPT_DEFAULT] + case "beast": + return [PROMPT_BEAST] + case "codex": + return [PROMPT_CODEX] + case "gemini": + return [PROMPT_GEMINI] + case "trinity": + return [PROMPT_TRINITY] + } + // kilocode_change end + if (model.api.id.includes("gpt-4") || model.api.id.includes("o1") || model.api.id.includes("o3")) return [PROMPT_BEAST] if (model.api.id.includes("gpt")) { From a7478fc3f97f6d8c0dc171aebd02864839ef4c91 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 19:44:45 +0000 Subject: [PATCH 2/2] test(cli): add tests for model.prompt-based system prompt selection Verifies that SystemPrompt.provider() respects the prompt property set by the Kilo gateway, and that it takes precedence over the model.api.id-based heuristic fallback. --- .../test/kilocode/system-prompt.test.ts | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 packages/opencode/test/kilocode/system-prompt.test.ts diff --git a/packages/opencode/test/kilocode/system-prompt.test.ts b/packages/opencode/test/kilocode/system-prompt.test.ts new file mode 100644 index 0000000000..69b4b2ac1a --- /dev/null +++ b/packages/opencode/test/kilocode/system-prompt.test.ts @@ -0,0 +1,70 @@ +import { describe, expect, test } from "bun:test" +import { SystemPrompt } from "../../src/session/system" +import { ProviderTest } from "../fake/provider" + +import PROMPT_ANTHROPIC from "../../src/session/prompt/anthropic.txt" +import PROMPT_DEFAULT from "../../src/session/prompt/default.txt" +import PROMPT_BEAST from "../../src/session/prompt/beast.txt" +import PROMPT_CODEX from "../../src/session/prompt/codex.txt" +import PROMPT_GEMINI from "../../src/session/prompt/gemini.txt" +import PROMPT_TRINITY from "../../src/session/prompt/trinity.txt" + +describe("SystemPrompt.provider", () => { + describe("model.prompt override", () => { + test("anthropic prompt is selected when model.prompt is 'anthropic'", () => { + const model = ProviderTest.model({ prompt: "anthropic" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_ANTHROPIC]) + }) + + test("default prompt is selected when model.prompt is 'anthropic_without_todo'", () => { + const model = ProviderTest.model({ prompt: "anthropic_without_todo" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_DEFAULT]) + }) + + test("beast prompt is selected when model.prompt is 'beast'", () => { + const model = ProviderTest.model({ prompt: "beast" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_BEAST]) + }) + + test("codex prompt is selected when model.prompt is 'codex'", () => { + const model = ProviderTest.model({ prompt: "codex" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_CODEX]) + }) + + test("gemini prompt is selected when model.prompt is 'gemini'", () => { + const model = ProviderTest.model({ prompt: "gemini" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_GEMINI]) + }) + + test("trinity prompt is selected when model.prompt is 'trinity'", () => { + const model = ProviderTest.model({ prompt: "trinity" }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_TRINITY]) + }) + + test("model.prompt takes precedence over model.api.id heuristic", () => { + // A model whose api.id contains "claude" (which would match anthropic via heuristic) + // but has prompt set to "beast" — prompt should win + const model = ProviderTest.model({ + prompt: "beast", + api: { id: "anthropic/claude-4-opus", url: "https://example.com", npm: "@ai-sdk/anthropic" }, + }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_BEAST]) + }) + + test("model.api.id heuristic is used when model.prompt is undefined", () => { + const model = ProviderTest.model({ + prompt: undefined, + api: { id: "anthropic/claude-4-opus", url: "https://example.com", npm: "@ai-sdk/anthropic" }, + }) + const result = SystemPrompt.provider(model) + expect(result).toEqual([PROMPT_ANTHROPIC]) + }) + }) +})