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>
This commit is contained in:
DS 2025-12-15 20:59:55 -05:00 committed by Aiden Cline
parent 0dc62d5dad
commit 72ebaeb8f7

View file

@ -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",