Repository navigation
Conversation
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
This branch has not been deployed
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 #5519
Description
Passage clipping could split an astral character at the UTF-16 budget and leave a lone surrogate in session history, causing later model requests to fail. Error snippets had the same slicing problem, and malformed backend titles could reach rendered tool output unchanged.
Normalize lone surrogates to U+FFFD, back up the clipping boundary when it would split a valid pair, reuse clipping for error snippets, and sanitize rendered text and API error messages. Valid pairs, UTF-16 budgets, ellipsis markers, and truncation flags are preserved. The sanitizer uses Unicode-aware regular expressions compatible with the existing Node and TypeScript targets; no dependencies or runtime requirements change.
Type of Change
Related Issue
Fixes #5519
Testing
Tests:
node --test --test-reporter=junit --test-reporter-destination=osscout-regression.xml packages/dsh-weknora/test/render.test.mjs(fails on base; passes with this patch).Regression coverage:
packages/dsh-weknora/test/client.test.mjs,packages/dsh-weknora/test/render.test.mjs,packages/dsh-weknora/test/tools.test.mjs.Scope excludes the Go contract suite (API contracts are unchanged), real dsh end-to-end installation, and unrelated full-repository checks.
Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)Screenshots / Recordings
Not applicable.