Skip to content

common : fix common_chat_peg_parse for incomplete utf-8 sequence tail#19992

Open
akreal wants to merge 1 commit intoggml-org:masterfrom
akreal:strip_incomplete_utf8_tail
Open

common : fix common_chat_peg_parse for incomplete utf-8 sequence tail#19992
akreal wants to merge 1 commit intoggml-org:masterfrom
akreal:strip_incomplete_utf8_tail

Conversation

@akreal
Copy link
Copy Markdown

@akreal akreal commented Feb 28, 2026

Sometimes I experience an issue with mistralai/Ministral-3-3B-Instruct-2512-GGUF:Q8_0 when it hits maximum generated tokens and leaves an incomplete UTF-8 sequence in the end of message (e.g. token IDs 1226 and 1156). This message then causes common_chat_peg_parse to fail with Failed to parse input at pos 0 error.

Claude Sonnet 4.6 was used to analyze the problem and to generate the code. Everything was manually reviewed and tested.

@akreal akreal requested a review from ggerganov as a code owner February 28, 2026 17:36
@github-actions github-actions bot added the testing Everything test related label Feb 28, 2026
@akreal akreal force-pushed the strip_incomplete_utf8_tail branch from 2203f50 to 1f03175 Compare March 2, 2026 06:39
@akreal
Copy link
Copy Markdown
Author

akreal commented Mar 2, 2026

After more experiments it appeared that invalid UTF-8 sequence can appear also in the middle of string, so now the fix handles both mid-string and end-string conditions. But I am not sure if this is the correct place to do this.

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

Labels

testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant