Repository navigation
fix(openai-live): chunk Chinese and Japanese context appends at sentence endings - #6413
Merged
aconchillo merged 4 commits intoNov 3, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
aconchillo
approved these changes
Nov 3, 2026
Contributor
|
LGTM! Thank you! |
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.
Fixes #6412
Summary
_chunk_text()(used byOpenAILiveLLMService._send_context_append()to split long delegation output intosession.commentary.append/session.thinking.appendevents) only treated ASCII.!?followed by whitespace as a sentence boundary. Chinese and Japanese end sentences with。!?and no space, so a CJK result became one long "sentence" that_split_at_token_limit()cut wherever the budget ran out, i.e. mid-sentence:_chunk_text(cjk_text, 100)chunks ended with测试句,一个测,这是一,か?这, …_chunk_text("First sentence. 第二句话。Third sentence.", 6)→['First sentence.', '第二句话。Thir', 'd sentence.']。/!/?, and the mixed example gives['First sentence.', '第二句话。', 'Third sentence.']Changes:
_SENTENCE_BOUNDARYalso splits after full-width。!?, with no whitespace required."".join(chunks)reproduces CJK text unchanged.Latin-script behaviour is unchanged; the existing chunking tests pass as-is.
Tests
test_chunk_text_breaks_cjk_at_full_width_sentence_endingsandtest_chunk_text_keeps_spaces_between_latin_sentences_next_to_cjktotests/test_openai_live_service.py; both fail onmainand pass with the fix.changelog/6413.fixed.md.uv run pytest tests/test_openai_live_service.py→ 50 passed (also verified with the change applied on currentmain);ruff check/ruff format --checkclean.