Repository navigation
fix(rag): never call an attached document past the 100 cap unattached - #8068
Conversation
A chat with more than 100 attached documents spent minutes indexing every one, each past the 100th pushing an earlier one out of the index, and then answered that a document the user had attached "is not attached". Now the chat loads the first 100 and stops, tells the model the rest are attached but not searched at once, loads one when it is asked about by name, and the bar above the chat tells the user that only 100 are searched at once. Every attach path (Agent UI new and cached agents, the flagship's own loading, a relayed flagship) checks the new RAGSDK.is_full() before indexing another document. query_documents reports how many attached documents it could not reach; query_specific_file resolves a name among them and loads it, evicting one other document. Indexing that does evict now drops the evicted document's stale "indexed" mark so it can be loaded again. The bar above the chat no longer runs under a docked session panel. Closes amd#7446
|
Verdict: Request changes This PR fixes a chat with more than 100 attached documents. It stops loading at the cap instead of spending minutes pushing out earlier documents, and it tells the model that the rest are attached and load when asked for by name. The approach is sound and well tested at 150 documents. Two things need fixing before merge:
Real-world evidenceN/A: no evidence bundle was produced for this run. The verdict rests on static review and on the PR's own test plan. That plan reports 🔍 Technical details🟡
🟡 Doc drift: README / SPEC / SKILL still promise every attached file is indexed (
🟢 The early stop ignores documents still indexing in the background (
Strengths
|
A few long documents fill the index on passages long before 100 files, and the chat then said "at most 100 documents" while the bar above it said nothing. Every message now names both limits, the bar also appears when the chat's passages pass 10,000, and the flagship's README, SPEC, SKILL and API description say what happens past the limit. Test fakes gain is_full.
They drive the Agent UI loader, which the RAG lane installs without.
# Conflicts: # hub/agents/gaia/npm/CHANGELOG.md
Both sides added changelog entries; both are kept.
rtl.visual.ts keeps the PR's past-cap scene and main's cited-documents scene; CHANGELOG keeps both entries.
# Conflicts: # hub/agents/gaia/npm/README.md # hub/agents/gaia/npm/SKILL.md # hub/agents/gaia/npm/SPEC.md # hub/agents/gaia/python/gaia_agent/server.py # hub/agents/gaia/python/openapi.gaia.json # tests/unit/test_relay_flagship_documents.py
# Conflicts: # src/gaia/apps/webui/visual/rtl.visual.ts
A few long documents fill the index on passages long before 100 files, and the chat then told the model and the user about both limits at once while the bar above the chat guessed from the total. Each message now names the one limit reached: the model note, the Agent UI indexing step, the relayed flagship's index_documents step, and the bar, which walks the documents in the order they load. A long document that pushes one out to fit marks the index full, so loading stops there instead of pushing another out on every later turn, and the one pushed out is counted as not loaded.
When the last attached document was the one that pushed an earlier one out to fit, no later pass saw the index full: the Agent UI step said every document was indexed with no note, and the relayed flagship listed all of them as loaded. Both now work out what is not loaded after the loop, name those documents in the step, and mark the one pushed out.
## Summary A Stop that lands just after an indexing load pushes a document out now reports that document as pushed out, keeps it out of the never-attempted stop count, and, when the index is full, stops promising it will load next turn. The Agent UI and the sidecar relay use the same accounting; the Agent UI explains the full-index limit once. ## Why Stopping indexing on a turn that evicted a document showed the document as loaded and promised the rest would load next turn. The index was full, so those documents could not load until the agent was asked about one by name. The model was already told the truth; only the step the user sees was wrong. This is most likely when loading is slow, which is when users press Stop. Follow-up to amd#8068. ## Linked issue Closes amd#8207 ## Changes - Agent UI (`src/gaia/ui/_chat_helpers.py`): on a stopped pass where a load evicted a document, compute the missed documents only from the loads attempted before the stop. The pushed-out document is named and marked in the step, while the stop count still covers only the documents never attempted. The full-index explanation is added once: the stop sentence omits it when the pushed-out document summary already carries it. - Relay (`hub/agents/gaia/python/gaia_agent/server.py`): apply the same accounting using the position recorded at cancellation. When the index is full, rewrite the stop line with `index_limit` so it says the documents load only when asked about by name. The pushed-out document stays granted, so `query_specific_file` can still load it by name. - Tests (`tests/unit/chat/ui/test_attached_past_cap.py`): one regression per loop. Both use four 10-passage books in a 25-passage index and set cancellation on the eviction result, so the third load pushes out `book_0.txt` while `book_3.txt` is never attempted. The Agent UI regression also asserts that the 25-passage explanation appears exactly once. ## Test plan - [x] `PYTHONPATH=src:hub/agents/gaia/python python -m pytest -q tests/unit/chat/ui/test_attached_past_cap.py -k 'stop_right_after_a_push_out'`: 2 passed in 0.68s after the wording cleanup. - [x] `PYTHONPATH=src:hub/agents/gaia/python python -m pytest -q tests/unit/chat/ui/test_attached_past_cap.py`: 17 passed in 2.73s after the wording cleanup. - [x] `ruff check src/gaia/ui/_chat_helpers.py tests/unit/chat/ui/test_attached_past_cap.py`: all checks passed after the wording cleanup. - [x] Wider focused run over the attachment, indexing, and relay suites, including `tests/unit/test_relay_flagship_documents.py`, `hub/agents/gaia/python/tests/test_server_documents.py`, and `tests/unit/chat/ui/test_index_progress.py`: 175 passed in 35.55s before the wording cleanup. - [x] `python util/lint.py --all` with `PYTHONPATH` at the worktree: all checks pass except two pre-existing Pylint E1120 errors in untouched `src/gaia/utils/awake_clock.py:47` and `src/gaia/utils/terminal.py:109`. This run was before the wording cleanup; the follow-up `ruff check` above covers both touched files. Black, isort, flake8, Bandit, and Pylint on the three changed files were clean; the tool-description check passes all 118 schemas. - [ ] Full `pytest tests/unit/` was not run locally; CI runs it. - [ ] Reviewer: in the Agent UI, attach four long books, stop as the third loads, and confirm `book_0.txt` is reported as pushed out, the 25-passage explanation appears once, and the step no longer promises next-turn loading. ## Evidence - [ ] **Agent exposed in the Agent UI** (Chat, Email, …): no live browser session was run in this environment, so there is no screenshot. The step output is asserted by `test_a_stop_right_after_a_push_out_reports_the_pushed_out_document`: the step reads `Stopped: 1 of 4 document(s) not loaded. 1 more not loaded: the attached documents are long, and the search index holds at most 25 passages at once. Not loaded: book_0.txt. Ask about one of them by name to search it.` The 25-passage explanation appears once. The old line promised next-turn loading and omitted the pushed-out marker. - [ ] **MCP tools / servers**: N/A. No MCP surface changed. - [ ] **CLI**: N/A. No CLI command changed. - [ ] **HTTP API / REST**: N/A for live evidence. The relay path is reached through `/query`, but no live request was run; the regression calls `_index_attached_documents` directly with the real RAG index and asserts the stop line, the marked document, and the retained path grant. ## Checklist - [x] I have linked a GitHub issue above (`Closes #N` / `Fixes #N` / `Refs #N`). - [x] I have described **why** this change is being made, not just what changed. - [ ] I have run linting and tests locally (`python util/lint.py --all`, `pytest tests/unit/`). Linting was run with two pre-existing Pylint errors outside this diff; focused pytest suites passed, but the full `tests/unit/` suite was not run locally. - [ ] I have attached **real-world evidence matched to the surface I changed** (see Evidence above), or marked each surface N/A. The Agent UI surface is applicable but no live browser screenshot was captured; the other surfaces are N/A. - [ ] I have updated documentation if user-visible behavior changed (see [CONTRIBUTING.md](../CONTRIBUTING.md)). No docs update was needed: no documentation describes this indexing-step wording. --------- Signed-off-by: Niladri Das <[email protected]>
Before: a chat with more than 100 attached documents (one test attached 1,500) spent about ten minutes indexing every file, each one past the 100th pushing an earlier one out, and then answered that a document the user had attached "is not attached". After: the chat loads documents up to its limit (100 documents or 10,000 passages, unchanged) and stops, the agent is told the rest are attached but not searched at once and never denies them, asking about one by name loads it, and the bar above the chat tells the user not all their documents are searched at once. Past the limit, the first-attached documents are the ones searched, where before the last-loaded ones were.
Closes #7446
Test plan
main, pass here.test:rtlscene in both languages (browser preview), screenshots read. It caught the bar running under the docked session panel in Arabic, fixed here.tscpass; the document, citation and attachmenttest:rtlscenes pass (the full suite timed out on a loaded machine, so CI's run is the full check)🔍 Technical details
RAGSDK.is_full(): at the file or chunk cap. Checked before each attach-time index in_index_rag_with_progress, the non-streaming cache hit,ChatAgent._index_documents, the session-restore loop and the relayed flagship's_index_attached_documents.attached_documents(the chat's whole list).attached_not_loadedis that list minus what the index holds or is still indexing. The per-turn[Indexed documents]context adds a not-searched line with the count and up to 30 names;query_documentsaddsattached_not_searchedand the same instruction;query_specific_fileresolves a name among them before looking on disk._forget_evictednow runs on every attach-time index, so an evicted document is no longer marked indexed forever.width: 100%ignored the docked panel'smargin-inline-end, so in Arabic the new notice was cut off under the panel; the bar now takes its width from the layout.SEARCHED_AT_ONCEin the web UI is pinned toRAGConfig.max_indexed_filesby a Python drift test.query_documents/query_specific_file. Eval categories to watch:rag_quality,real_world,captured(the retrieval lane) andcontext_retention.