From c2ccb45888932d38ff258e17d2238ad9563fe35a Mon Sep 17 00:00:00 2001 From: kagura-agent Date: Sun, 28 Jun 2026 08:19:34 +0800 Subject: [PATCH] fix(llm): collapse system messages when plugin appends a single entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The post-hook collapse condition checked `system.length > 2` but the initial system array always has length 1 (all prompts are joined before the plugin trigger). When a plugin pushes exactly one entry the array becomes length 2, which does not satisfy `2 > 2`, so no collapse fires and two separate {role: "system"} messages are sent — breaking OpenAI-compatible providers. Change the threshold to `> 1` so the collapse fires whenever a plugin appends anything. Closes #34243 --- packages/opencode/src/session/llm/request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/session/llm/request.ts b/packages/opencode/src/session/llm/request.ts index 4f93411107df..f543d8274fd6 100644 --- a/packages/opencode/src/session/llm/request.ts +++ b/packages/opencode/src/session/llm/request.ts @@ -71,7 +71,7 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre { sessionID: input.sessionID, model: input.model }, { system }, ) - if (system.length > 2 && system[0] === header) { + if (system.length > 1 && system[0] === header) { const rest = system.slice(1) system.length = 0 system.push(header, rest.join("\n"))