mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3780
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1966
Author: @MistyMoonR
Created: 10/11/2026
Status: ❌ Closed
Base:
main← Head:fix-1950-continue-final-assistant📝 Commits (1)
49da143serve: continue a final assistant message instead of restating it (#1950)📊 Changes
2 files changed (+128 additions, -3 deletions)
View changed files
📝
serve/server.py(+23 -3)📝
serve/test_server.py(+105 -0)📄 Description
Fixes #1950.
A request whose last message is an assistant one (the Anthropic API's prefill, and OpenAI clients that do the same) used to get a prompt that closed that turn and opened a fresh one, so the model wrote a new reply that restated the prefill from the top. A stop string then matched the prefill's own text inside that restatement and ended the reply with finish=stop after ~35 characters. Reproduced with the reporter's exact request on Linux as well (the issue is Windows 0.1.42; our box is 2x RTX 4090, v0.1.42 and v0.1.43): the 35-character stub with
stop: ["\ndef"], the full body without the stop list.The template is unchanged and is the same in 0.1.39 (where the reporter says it did not truncate); the prompt shape is the bug, and whether the restatement reaches a stop string varies with the build's numerics. A client that prefills the assistant turn is asking for a continuation, so the prompt should end inside that turn.
The fix (serve layer only):
Service.continues_final(): true when the last message is an assistant one with plain, non-empty text and no tool calls;"effort_position": "end"configs keep their own prompt shape.encode_promptrenders the template without its generation prompt and leaves the turn's closing<|im_end|>off, so the prompt ends with the text to continue, inside the assistant's turn.What does not change (tested): a request whose last message is a user turn, a final assistant message with tool calls, or whitespace-only text gets the exact old prompt; a stop string still cuts the model's own text the moment the model writes it;
StopMatcheris untouched (a stop string still never runs across a tool call or thinking).Verified:
FinalAssistantContinuation, byte tokenizer, so the stop strings are split across tokens): the prompt ends with the prefill inside the turn; a stop string in the prefill never ends the reply; a stop string in the continuation still cuts it; the old shapes are unchanged; the Anthropic route continues too. Full serve suite: 712 OK (11 skipped) on 0.1.43 with this patch; the tree without it runs 706.\ndef; promptfoo suite 6/6; no reasoning recoveries.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.