summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDS <[email protected]>2025-12-15 20:59:55 -0500
committerAiden Cline <[email protected]>2025-12-15 20:00:26 -0600
commit72ebaeb8f7e5ac86b9b2d876658ff3fff4638b25 (patch)
tree29cf5f21f251085d2983bf4333fc44b14e8db548
parent0dc62d5dadb75266d1630fc85d0e95a309097f15 (diff)
downloadopencode-72ebaeb8f7e5ac86b9b2d876658ff3fff4638b25.tar.gz
opencode-72ebaeb8f7e5ac86b9b2d876658ff3fff4638b25.zip
fix: rejoin system prompt if experimental plugin hook triggers to preserve caching (#5550)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
-rw-r--r--packages/opencode/src/session/llm.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/opencode/src/session/llm.ts b/packages/opencode/src/session/llm.ts
index f95690420..ce7b60f0a 100644
--- a/packages/opencode/src/session/llm.ts
+++ b/packages/opencode/src/session/llm.ts
@@ -60,11 +60,18 @@ export namespace LLM {
.join("\n"),
)
+ const header = system[0]
const original = clone(system)
await Plugin.trigger("experimental.chat.system.transform", {}, { system })
if (system.length === 0) {
system.push(...original)
}
+ // rejoin to maintain 2-part structure for caching if header unchanged
+ if (system.length > 2 && system[0] === header) {
+ const rest = system.slice(1)
+ system.length = 0
+ system.push(header, rest.join("\n"))
+ }
const params = await Plugin.trigger(
"chat.params",