Skip to content

fix(rag): an overlap of 0 repeats nothing between chunks - #8382

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/rag-zero-overlap
Nov 17, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/rag-zero-overlap

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

With chunk overlap set to 0, every chunk carried almost all of the text before it, so chunks grew far past the chunk size and the same sentences were indexed many times. An overlap of 0 now repeats nothing.

Closes #8381

Test plan

  • python -m pytest tests/unit/rag/test_unspaced_and_rtl_text.py -k no_overlap passes (it fails on main)
  • python -m pytest tests/unit/rag tests/unit/chat/ui/test_attached_past_cap.py passes

With chunk_overlap=0 each chunk carried almost all the text before it, so chunks grew far past the chunk size and sentences were indexed many times over. last_tokens(text, 0) took text[-0:], which is the whole string; it now returns nothing.

Closes amd#8381
@github-actions github-actions Bot added rag RAG system changes tests Test changes performance Performance-critical changes labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

Setting chunk overlap to 0 made every chunk carry almost all the text before it, because asking for "the last 0 tokens" returned the whole text. This PR makes it return nothing. The fix is correct, and nothing blocks the merge.

Real-world evidence

N/A. No evidence bundle was produced for this PR, and it changes an internal RAG helper with no CLI, API or UI surface of its own. The verdict rests on static review. pytest isn't installed on this review runner, so I couldn't run the new test here; CI's unit lane covers it.

🔍 Technical details

Issues found: none blocking.

  • Root cause confirmed: in last_tokens, target_chars = 0 * 4 = 0, so text[-0:] returned the full string. The early return fixes both heuristic callers in src/gaia/rag/sdk.py:
    • The sentence branch (~3516) now resets current_chunk to [] and current_size = overlap_tokens = 0.
    • The paragraph branch (~3549) recomputes the size from an empty list.
  • Sibling path checked: the LLM chunking path (_llm_based_chunking, ~2644) uses overlap * 4 chars and never calls last_tokens. Overlap 0 already worked there.
  • Docs drift: nothing documents the old behaviour, so no docs need changing.
  • 🟢 Pre-existing and out of scope: when the overlap is non-zero, the sentence branch sets current_size = overlap_tokens instead of measuring the trimmed text. That is a small mismatch the paragraph branch avoids.

Strengths

  • A minimal guard at the shared helper fixes every caller at once.
  • The regression test checks the real invariant (each sentence lands in exactly one chunk) across 200 sentences, not just the helper's return value.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 17, 2026
Merged via the queue into amd:main with commit 49e7dfa Nov 17, 2026
39 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rag-zero-overlap branch November 17, 2026 17:26
@kovtcharov-amd kovtcharov-amd mentioned this pull request Nov 17, 2026
kovtcharov-amd added a commit that referenced this pull request Nov 17, 2026
# GAIA v0.26.1 Release Notes

## Summary

- Changing the model server, connectors or skills in Settings now takes
effect in chats that are already open, including the terminal UI.
- "Am I free?" no longer says yes when an Outlook meeting's time can't
be read.
- A chat on a cloud model is no longer offered a large local download.
- After an agent crash, the next message gets a fresh answer instead of
the old one continued.
- 11 PRs merged since v0.26.0.

## What's New

- **Settings reach open chats** — a model server, connector or skill
change applies on the chat's next message, in the Agent UI and the
terminal UI. The terminal UI and `gaia -p` now offer only the MCP
servers turned on for GAIA. (PRs
[#8389](#8389),
[#8394](#8394),
[#8399](#8399),
[#8400](#8400))

## Bug Fixes

- **Outlook availability is no longer guessed** — a meeting whose time
can't be read is reported instead of skipped, and Outlook times parse on
Python 3.10. (PR [#8267](#8267))
- **No unwanted local download on a cloud model** — Settings › Manage
downloads leaves the local chat model unticked while chat runs on a
cloud model. (PR [#8086](#8086))
- **A reply cut short by a crash isn't continued** — the next message is
answered fresh. (PR [#8391](#8391))
- **A command's timeout never outlasts the turn's time limit.** (PR
[#8424](#8424))
- **An MCP connector shows Connected only after a check has started
it.** (PR [#8434](#8434))
- **A document overlap of 0 repeats nothing between chunks.** (PR
[#8382](#8382))
- **Closing the resource strip says how to bring it back.** (PR
[#8432](#8432))
- **A release candidate names its own pre-release as the agent's
source.** (PR [#8433](#8433))
- **The "GAIA doesn't run this model server" line is translated in
Arabic.** (PR [#8435](#8435))
- **Relay tests run against fake agents that match the real one.** (PR
[#8393](#8393))

## Full Changelog

**11 PRs** since v0.26.0. The PR links above are the changelog.

Full Changelog:
[v0.26.0...v0.26.1](v0.26.0...v0.26.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance-critical changes rag RAG system changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(rag): chunk overlap of 0 repeats nearly the whole document in every chunk

2 participants