Skip to content

Add history_adapters chat-template option to keep SR control tokens - #154

Open
noaakl wants to merge 1 commit into
mainfrom
feature/sr-history-control-tokens
Open

noaakl wants to merge 1 commit into
mainfrom
feature/sr-history-control-tokens

Conversation

@noaakl

@noaakl noaakl commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Add history_adapters option to keep SR control tokens in history

Text callers re-render history without control tokens, so a past SR turn
shows its site token instead of the control token that was sent. The ids
stop matching and the prefix cache misses from that point on.

history_adapters lists the adapter behind each assistant message, and the
chat template puts each control token back in place of the site token.
Works for both the Granite 4.1 and 4.2 chat templates.

…n history

Text-based multi-turn callers re-render history without control tokens, so
an SR turn's header renders its site token instead of the control token that
was sent and the prefix cache misses from there on. history_adapters (one
entry per assistant message) restores them in place of the site token, for
both the 4.1 role-marker and 4.2 ChatML templates. Adds tests and documents
the option and the caller rules it needs in SR_ARCHITECTURE.md.

Signed-off-by: noaa <noaa.kless@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

2 participants