Skip to content

fix(kosong): sanitize surrogates before Kimi requests#2334

Open
he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/sanitize-surrogates-before-kimi-request
Open

fix(kosong): sanitize surrogates before Kimi requests#2334
he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/sanitize-surrogates-before-kimi-request

Conversation

@he-yufeng
Copy link
Copy Markdown

@he-yufeng he-yufeng commented May 20, 2026

Summary

  • sanitize lone UTF-16 surrogate code units before sending Kimi chat-completion requests
  • cover system prompts and converted message payloads, including history text and tool-call arguments
  • add a regression test that JSON-encodes the outgoing request with ensure_ascii=False

Fixes #2320

To verify

  • uv run pytest packages/kosong/tests/test_chat_provider.py -q -p no:cacheprovider
  • uv run --package kosong --group dev pytest packages/kosong/tests -q -p no:cacheprovider
  • uv run --package kosong --group dev ruff check packages\kosong\src\kosong\chat_provider\kimi.py packages\kosong\tests\test_chat_provider.py
  • uv run --package kosong --group dev pyright packages\kosong\src\kosong\chat_provider\kimi.py packages\kosong\tests\test_chat_provider.py
  • git diff --check

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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.

An error seems caused by the ✨ emoji.

1 participant