Repository navigation
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
ashhart
force-pushed
the
lead/assistant-prefill
branch
4 times, most recently
from
November 23, 2026 14:11
b4af3a9 to
c694798
Compare
…sages' prefill does, instead of opening a new turn.
…g: chat_template_kwargs.enable_thinking or thinking
A final assistant message whose content is only whitespace renders no text in the continued turn: on Qwen 3.8 and GLM-5.3 the template strips it, pyLstrip is empty and both endsWith checks pass (a lone newline also passes the first, after the think close). The reply then generates without that text. Refuse it with the same trailing-whitespace message the Messages route returns, before either cut() check. Tokens on valid continuations are unchanged.
ashhart
force-pushed
the
lead/assistant-prefill
branch
from
November 23, 2026 20:36
c694798 to
93ed612
Compare
This branch has not been deployed
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.
Anthropic's Messages API treats a final assistant message as the start of the reply ("prefill"): the model continues it, so a client can force JSON with
{or begin an answer's first words. TensorFold opened a new turn after that message instead. This continues it on/v1/messages, and on/v1/chat/completionsbehind thecontinue_final_messageflag vLLM-compatible clients send.What this changes
/v1/messages: when the last message is the assistant's, the reply continues it.contentholds only the continuation, andusage.input_tokensandcount_tokenscount the prefill as input.anthropic/refuse-mid-system, ends that way. Its input drops from 21 tokens to 16 (checked by hand) and its request-log line carries the flag./v1/chat/completions: opt-in with"continue_final_message": true."add_generation_prompt": falseis accepted beside it, andtrueis refused. Without the flag nothing changes.The prompt:
Thinking:
chat_template_kwargs.enable_thinking: true,thinkingon, or areasoning_effortother thannone. On Messages it meansthinkingenabled or adaptive.enable_thinking: false: thinking-off prompt, plain content, and the samehistory_len, warm pass and prompt-cache prompt. A client that sends a trailing assistant message to a thinking model without asking for thinking gets its continuation, not a new 400.Refused with a 400 naming the reason:
Ordinary request otherwise: drafts stay on, structured output constrains the continuation from its first token,
history_lenis the conversation before the continued message, and the next turn's warm pass treats prefill and reply as one assistant message. Cortheon skips continued requests.Issue: n/a. This came from the 16 Nov check of competitor gap docs against main (continuing a trailing assistant message is listed for colibri, and it's Anthropic's documented prefill); no issue or PR covered it.
Stacked on: main.
atc overlap --json: to run after review. Known text conflicts, for whichever lands later:chat.zig'sInputfields with server: /v1/completions takes suffix, a fill-in-the-middle prompt from the tokenizer's own FIM tokens #3528 (code infill);cortheon.zigwith server: POST /v1/responses/input_tokens counts the prompt POST /v1/responses would prefill, generating nothing #3537, which factorsbegin's checks intotakes;golden/cases.jsonwith both. Rerunfreeze_cases.pyafter mergingcorpus.py.openai.zigis at 600 lines here and its line-count arithmetic with server: /v1/completions takes echo, the prompt's text and legacy logprobs ahead of an unchanged reply #3526 works out to 600.Checks on this head
tools/pr_check.py: 0 errors, 1 advisory warning, the PR number).zig build test-prefill-host(new): 32/33 with 1 skip (the real-tokenizer test) withoutTF_TOKENIZER_DIRS. With it set to the published Qwen3.8-27B snapshot, 33/33: 21 prompt tokens, the last 3 the message's own, after 11 of history. The real-tokenizer check was also run on Nemotron 3.5 Lightning and Qwen3.5-0.8B.zig build test-server-cpu: 1488/1498 (10 skipped).zig build test-golden: 335/348 equal, 0 unexpected (main's 13 known differences); security 55/55. The 12 prefill goldens run in their own server step.zig build test-thinking-request-host test-prompt-interior-host: pass.zig build server-cpuandzig build native -Dcpu=apple_m1build.zig fmt --checkandgit diff --checkare clean./tokenize, Responses and Ollama don't take the flag.Receipt
n/a for speed: a continued request is an ordinary prompt through the usual lane rounds. Its prompt is new by design, and every other request's prompt is unchanged (goldens). A device run on a served checkpoint is the follow-up.
Checklist
The title and description match the head commit.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds.
Synthena (Ash's Agent)