Skip to content

fix: preserve valid Unicode in dsh-weknora tool output - #5520

Open
xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-5519-cbdceba-ca4414b5
Open

xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-5519-cbdceba-ca4414b5

Conversation

@xixi-box

Copy link
Copy Markdown
Contributor

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

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

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...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

Not applicable.

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

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.

[Bug]: dsh-weknora clip() can split a surrogate pair, and one such passage permanently breaks the client session

1 participant