Chunked text processing silently drops the end of long texts
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start with ChunkService::chunkSplitPrompt() and trace how its paragraph, sentence, and word split patterns handle text that lacks a trailing separator. The issue reports that the author is preparing a fix with unit tests for all three split levels and fall-through behavior. Done means concatenating the chunks reproduces the full input, including its final text.
索引モデルが issue の本文から書いたものです。
説明
Which version of integration_openai are you using?
main (6.0.0-dev), the bug exists in released versions as well
Which version of Nextcloud are you using?
stable35
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
not relevant
Describe the Bug
When a text is long enough to be split into chunks, the end of the text can be silently dropped before anything is sent to the AI service. The truncated output looks successful, part of the source text is just missing.
ChunkService::chunkSplitPrompt() splits by paragraph, then by sentence, then by word, using patterns anchored on a trailing separator (\n, [!.?\n], \W). Each level returns as soon as it produces at least one chunk. Whatever part of the text does not end with that level's separator is never matched, and it is not passed down to the finer levels either, so it is lost:
input: "aaaa bbbb cccc\ndddd eeee ffff\ngggg hhhh" (maxChars = 20)
chunks: "aaaa bbbb cccc\n" + "dddd eeee ffff\n"
-> "gggg hhhh" never appears in any chunk
The same loss happens one level down when the text does not end with sentence punctuation, and one level further down for the last word of a text ending with a word character.
The affected call sites include translation, summary, proofread, context write, topics, reformat, improve, reformulate and change tone. Translation is the easiest to hit in practice: with the default configuration it chunks at min(chunk_size, max_tokens) * 3 ≈ 3000 characters, so translating a few paragraphs is enough. A translated document can simply miss its ending.
Expected Behavior
Every chunk contains a part of the input and concatenating the chunks gives back the full input, whatever characters the text ends with. The split should fall through to the finer level for the unmatched tail instead of dropping it.
To Reproduce
Reproduced end to end on a live Nextcloud 35.0.3 instance with the translation task, using a local mock provider that echoes back exactly what it receives. A 3491-character input whose final line has no trailing newline:
- input sent to translation: 3491 characters
- concatenated text actually received by the provider: 3441 characters
- the entire final line (50 characters) never reached the provider
A control input identical but ending with a newline went through without any loss (3492 characters in, 3492 out), confirming that the loss depends on the trailing separator.
The split logic itself is deterministic and runs entirely before the API call, so it can also be demonstrated without a provider:
$maxChars = 20;
$prompt = "aaaa bbbb cccc\ndddd eeee ffff\ngggg hhhh";
preg_match_all("/.{1,{$maxChars}}\n/su", $prompt, $chunks);
// implode('', $chunks[0]) is 30 chars long, the input is 39:
// the tail after the last newline is missing from the chunks
I am preparing a fix with unit tests covering the three split levels and the fall-through behaviour.
Assisted by Devin:SWE-2.1
- 主要言語
- PHP
- スター
- 78
- フォーク
- 42
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/integration_openai のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/integration_openai#480 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nextcloud/integration_openai#477 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
nextcloud/integration_openai#471 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Vllm rejecting requests that have empty tools list対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/integration_openai#448 · コメント 3 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Solve 2 transcription problems: Video input and big input対応中かも @danafon が 1 日前に担当しました。 オープンbug enhancement priority: high
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
nextcloud/integration_openai#472 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
nextcloud/integration_openai の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
Automattic/static-site-importer#3462 ·
メンテナーはふだん 1 日以内に返信
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.phpオープンenhancement feature: settings good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
roundcube/roundcubemail#10468 ·
メンテナーはふだん 1 日以内に返信
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
omeka/plugin-Contribution#84 ·