Back Home

GitHub Repo

Dify Community Proposes Chinese Delimiter Fix for Encoding Error in RAG Chunking

A Dify patch proposal submitted on November 4 addresses non-ASCII fixed delimiters, such as the Chinese full stop, being converted into garbled text. The proposal has not been merged. A short reproduction case is public, but it does not establish that all Chinese documents fail to be chunked.

The original uploader was Ggia at Greek Wikipedia. · CC BY-SA 2.5 · Image source
zh-Hant

On November 4, the Dify community submitted patch proposal #45535, reporting that the initialization process for RAG fixed delimiters corrupts non-ASCII characters. The report uses a self-hosted environment with source code labeled 1.18.0 as an example: after specifying the Chinese full stop “。”, three short sentences remained together in a single chunk. As of the time of review, the proposal was still open and had not received maintainer approval or been merged. Issue report

The issue lies in delimiter escape handling. The code originally used unicode_escape to convert a user-entered backslash followed by n into an actual newline. But the same processing was also applied to directly entered Unicode characters, turning the Chinese full stop into a different sequence of characters that could not match the original text. The author’s proposed change is to use isascii() first, decoding only ASCII delimiters and preserving all others as entered. It also adds tests for Chinese delimiters and existing newline behavior. Patch proposal

The scope of the impact should be kept narrow. An automated response in the issue thread says text exceeding the length threshold may still enter recursive splitting, so long documents could mask the error. The public example supports the conclusion that fixed delimiters fail; it does not show that Chinese chunking as a whole is broken. The response also notes that if a delimiter contains both Unicode characters and escape sequences, skipping decoding for the entire string would leave those sequences unexpanded. Reviewers still need to confirm this semantic boundary. Issue discussion

For Chinese knowledge bases, chunk boundaries determine which content is retrieved together and sent to the model. Dify’s official documentation says that General mode returns matching chunks directly, while Parent-child mode matches child chunks and returns parent chunks for context. A mismatch between configured and actual delimiter behavior could therefore change retrieval granularity. This is an engineering risk inference; no public recall or answer-quality data currently quantifies the impact. Official chunking documentation

Engineering teams can first check actual segmentation with short Chinese text below the length threshold, then test long documents, emoji, and mixed escape sequences, verifying chunk content and boundaries. They should track maintainer review and inclusion in an official release, then compare segmentation results for existing indexes after the fix to decide whether documents need to be reprocessed.

Sources

  1. Dify PR #45536:選用式串流輸出阻擋審查草案
  2. Dify App Toolkit:內容審查功能
  3. AI Guardrails:與 Dify 平台整合
  4. Dify PR #45535:保留非 ASCII 固定分隔符
  5. Dify Issue #45532:固定分隔符的 Unicode 解碼問題
  6. Configure the Chunk Settings