fix: merge adaptive guidance into existing system prompt - #21
Open
zoomdbz wants to merge 1 commit into
Open
Conversation
The experimental.chat.system.transform hook appended its guidance with system.push(...), creating a second system message. Strict chat templates require exactly one system message at the start of the conversation and fail to render otherwise (e.g. llama.cpp: "System message must be at the beginning."), breaking template rendering before inference starts. Merge the guidance into the first existing system prompt instead, and only inject a standalone entry when no system prompt exists yet. Automatic reasoning-effort switching via set_reasoning_effort is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Some strict chat templates require the system prompt to appear only at the very beginning of the conversation. The plugin's
experimental.chat.system.transformhook appended its adaptive-thinking guidance withsystem.push(...), which adds a second system message. Against those templates that fails to render before inference even starts. For example, a local llama.cpp provider raisesJinja Exception: System message must be at the beginning.Fix
Merge the adaptive-thinking guidance into the existing first system entry rather than pushing a new one. When no system prompt exists yet, the guidance is still injected on its own, so behavior is unchanged for templates that allow it.
This is provider- and model-agnostic: it is compatibility with strict chat templates in general, not a workaround for one model.
Automatic reasoning-effort switching (
set_reasoning_effort, temporary vs persistent variants,session.idlereset, current-variant reporting) is unchanged.Tests
Added coverage in
src/index.test.ts(19 passing):Validation
pnpm format:check,pnpm lint,pnpm typecheck,pnpm test(19/19),pnpm buildall pass.