Skip to content

Commit d7849ca

Browse files
fix(cache): add splitSystemPrompt provider option to opt out of system block split
1 parent a507a01 commit d7849ca

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

  • packages/opencode/src/session

packages/opencode/src/session/llm.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,17 @@ export namespace LLM {
7070

7171
const prompt = input.agent.prompt ? [input.agent.prompt] : isOpenaiOauth ? [] : SystemPrompt.provider(input.model)
7272
const split = input.systemSplit ?? input.system.length
73-
const system = [
74-
// block 1: provider/agent prompt + global instructions (stable across repos)
75-
[...prompt, ...input.system.slice(0, split)].filter(Boolean).join("\n"),
76-
// block 2: env + project instructions + any custom prompt from last user message (dynamic)
77-
[...input.system.slice(split), ...(input.user.system ? [input.user.system] : [])].filter(Boolean).join("\n"),
78-
].filter(Boolean)
73+
const shouldSplit = provider.options?.["splitSystemPrompt"] !== false
74+
const system = shouldSplit
75+
? [
76+
// block 1: provider/agent prompt + global instructions (stable across repos)
77+
[...prompt, ...input.system.slice(0, split)].filter(Boolean).join("\n"),
78+
// block 2: env + project instructions + any custom prompt from last user message (dynamic)
79+
[...input.system.slice(split), ...(input.user.system ? [input.user.system] : [])].filter(Boolean).join("\n"),
80+
].filter(Boolean)
81+
: [
82+
[...prompt, ...input.system, ...(input.user.system ? [input.user.system] : [])].filter(Boolean).join("\n"),
83+
].filter(Boolean)
7984

8085
const header = system[0]
8186
await Plugin.trigger(
@@ -84,7 +89,7 @@ export namespace LLM {
8489
{ system },
8590
)
8691
// rejoin to maintain 2-part structure for caching if header unchanged
87-
if (system.length > 2 && system[0] === header) {
92+
if (shouldSplit && system.length > 2 && system[0] === header) {
8893
const rest = system.slice(1)
8994
system.length = 0
9095
system.push(header, rest.join("\n"))

0 commit comments

Comments
 (0)