Skip to content

Fix knowledge loss before oversized sentences - #7

Merged
AliZakaee merged 1 commit into
mainfrom
automation/maintenance-20260812-early-evening-preserve-kb-prefix
Aug 12, 2026
Merged

AliZakaee merged 1 commit into
mainfrom
automation/maintenance-20260812-early-evening-preserve-kb-prefix

Conversation

@AliZakaee

Copy link
Copy Markdown
Owner

Summary

  • preserve the buffered prefix when knowledge-base chunking encounters an oversized sentence
  • cap overlap to the remaining chunk capacity so every stored chunk stays within CHUNK_SIZE
  • add a regression test covering the mixed short/oversized-sentence path end to end

Why this is meaningful

Both pasted notes and uploaded documents flow through _chunk_text before their content is embedded and stored. Previously, a short fact immediately before a sentence longer than 800 characters was silently discarded, so retrieval and generated replies could never use it. The fix prevents that data loss while retaining the existing chunk order, overlap behavior where capacity permits, retrieval contract, and public interfaces.

Validation

  • Baseline: .venv/bin/python -m pytest — 282 passed
  • Targeted: .venv/bin/python -m pytest tests/unit/services/test_kb_service.py — 19 passed
  • Post-change full suite: .venv/bin/python -m pytest — 283 passed
  • Syntax: .venv/bin/python -m compileall -q . -x '/.venv/' — passed
  • Whitespace: git diff --check — passed
  • Reproduction: the mixed input now produces chunk lengths [25, 800, 176], retains the prefix, and keeps every chunk at or below 800 characters

Risk and rollback

Risk is low and localized to knowledge-base chunk construction. Inputs without the mixed short/oversized pattern keep their prior behavior; overlap is reduced only when the next piece would otherwise exceed the configured chunk size. Roll back by reverting the single feature commit.

Prepared with automated assistance by EQ for AliZakaee.

@AliZakaee
AliZakaee merged commit 4bba75e into main Aug 12, 2026
7 checks passed
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.

1 participant