Skip to content

fix: preserve completion results when stopping criteria fire - #2482

Open
remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-a873db003046
Open

remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-a873db003046

Conversation

@remote-controlled-man

Copy link
Copy Markdown
Contributor

Summary

Use the result that ended Llama.generate() to finalize Llama.create_completion().
Calling the criterion again could discard text and report finish_reason="length" when a stateful callback returned true only once.
The extra call could also relabel a token-budget exit as "stop" or put a matched stop sequence back into a non-streaming response.

Validation

  • Added deterministic regression cases with the existing Stories15M GGUF fixture for both streaming modes, covering a one-shot criterion, the token budget, and a stop sequence.
  • make test and make lint on macOS arm64 with CPython 3.12 and the vendored llama.cpp built with GGML_NATIVE=OFF.

Copilot AI balanced review requested due to automatic review settings December 5, 2026 03:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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