Skip to content

fix: dropped generation-prompt text in JinjaTemplateChatWrapper - #635

Open
JoshuaWise wants to merge 1 commit into
withcatai:masterfrom
JoshuaWise:master
Open

fix: dropped generation-prompt text in JinjaTemplateChatWrapper#635
JoshuaWise wants to merge 1 commit into
withcatai:masterfrom
JoshuaWise:master

Conversation

@JoshuaWise

@JoshuaWise JoshuaWise commented Aug 3, 2026

Copy link
Copy Markdown

Description of change

JinjaTemplateChatWrapper was discarding text in the template's generation prompt that comes after the assistant role header. Any static text the template emits between the role header and the model's content -- most importantly a pre-filled reasoning tag like <think> was silently dropped. This PR fixes that behavior, enabling many templates that rely on pre-filling a <think> tag to force the model into reasoning mode, or <think></think> to suppress it.

Fixes #634

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply eslint formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits and pull request title follow conventions explained in pull request guidelines (PRs that do not follow this convention will not be merged)

@giladgd

giladgd commented Aug 4, 2026

Copy link
Copy Markdown
Member

Thanks for the PR!
I noticed it just now after I pushed a fix for the issue you opened (#636)
I'll take a look at it now and see whether your solution is better

)
],
...(
noPrefixTrigger != null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure that we don't force-open a thought segment on every render, we should only do it when the model response is empty because we're just starting to generate it.
The rendering also happens after function calls are done (when the results are being put in the context), after context shifts, and some other edge cases, so we shouldn't break those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: JinjaTemplateChatWrapper drops generation-prompt text after the assistant header

2 participants