Repository navigation
fix(rag): keep the RAG cache in ~/.gaia/cache/rag and clear only its files - #4260
Conversation
…files Running /clear-cache in `gaia chat` from your home directory deleted all of ~/.gaia (memory, connector state, installed agents, models), and every other run left a stray .gaia/ folder in the working directory. The RAG cache now defaults to <GAIA_CONFIG_DIR>/cache/rag, clearing removes only the files the cache wrote, and it refuses to clear $HOME or the GAIA home dir. The chat app's /clear-cache now calls RAGSDK.clear_cache() instead of its own rmtree, so the guard has one owner. Fixes amd#4194
|
Verdict: Approve with suggestions This fixes a genuinely destructive bug: clearing the document cache from your home folder wiped the whole Two things worth a look before merge, neither blocking:
Also worth calling out for users: the "export document text" feature writes its markdown into the cache folder by default, so those exports quietly move from the working directory into the hidden home cache — and a later cache clear removes them. Worth one line in the changelog. Real-world evidenceNo The one gap is the author's own unchecked box — 🔍 Technical details🟢 MinorConcurrent clears can raise an unhandled The default cache dir moved from a per-cwd HMAC key path doesn't follow
Extracted-markdown exports relocate silently (
Verification performed
Strengths
|
) Document and image extraction failed whenever the model wrote a placeholder such as `{field}` before its JSON answer: the parser only tried the first `{`, gave up, and the extraction raised "did not parse". It now moves past an invalid span and finds the real JSON. It still never looks inside a broken object, so truncated or malformed output returns nothing instead of a misleading fragment. Also adds table tests for the JSON parser behind every VLM extraction path, and tests that pin the Stable Diffusion prompt text to the real per-model defaults so the size, steps, and CFG the model is told to use can't drift from them. Covers the parser and SD-prompt parts of amd#4257. Chunking and cache-clearing are in amd#4262 and amd#4260. `deltas_cli`, `code_bench_fixtures`, and the TUI flag wiring already had tests. `talk/app.py` is left out because it needs a design decision (see the issue). ## Test plan - [x] `python -m pytest tests/unit/test_parsing.py`: 2 placeholder cases fail on `main`, 13/13 pass with the fix - [x] `python -m pytest tests/unit/test_parsing.py tests/unit/test_sd_prompts.py tests/unit/test_file_watcher.py tests/unit/test_structured_vlm_extraction.py tests/unit/test_vlm_extraction_failures.py tests/unit/test_sd_mixin.py tests/unit/test_sd_error_messages.py hub/agents/gaia/python/tests/test_sd_tools_do_not_rewrite_the_prompt.py`: 176 passed, 3 skipped - [x] black, isort, and pylint (errors-only, CI config) are clean on the changed files - [x] `python util/check_test_lane_coverage.py` does not flag either new file (the `pytest tests/unit/` lane runs them) Part of amd#4257 Co-authored-by: Kalin Ovtcharov <[email protected]>
…imports (amd#4360) About 6,700 lines of code had no caller. One file couldn't even be imported, yet CLAUDE.md still listed it as "Shell integration". The dead code kept stale behaviour looking alive, like `rag/demo.py` printing `gaia rag` commands that don't exist, and it cost reviewers time. This PR deletes six of the items from amd#4243. It also adds a test that imports every module under `src/gaia`, so an unimportable file now fails CI instead of lingering. The test fails on current `main`: it flags `shell/prompt.py` and the three uncollected mic scripts. Left for a maintainer decision: - `src/gaia/eval/model_comparison.py`: it has no caller, but amd#3741 merged it yesterday as a library building block, with CLI wiring planned as a follow-up. - `governance/`, `talk/app.py` (amd#4333) and the webui AgentManager panel (amd#4330) were excluded. `docs/plans/cpp-framework-parity.md` still calls the C++ plan resolver dead code to resolve. I left it alone because amd#3812 deletes that file. <details> <summary>🔍 Technical details</summary> - Deleted: `src/gaia/shell/`, `rag/demo.py`, `rag/app.py` + `rag_main` export, `audio/tests/*.py`, `eval/longthread_quality.py` + its test and fixture, `hub/agents/email/node/`, `Agent::resolvePlanParameters` (+ decl, + now-unused `<regex>` include). - Two `rag_app` tests in `test_rag_index_status.py` went with `rag/app.py`. The chat/talk/file-monitor index-status tests stay. - `thread_fold` keeps its own coverage in `hub/agents/email/python/tests/test_thread_fold*.py`. - The import test's allowlist is keyed on the *missing package* (`mcp`, `reportlab`), not the module. An allowlisted module still fails if it breaks another way, and a second test checks each allowlisted package is an optional extra in `setup.py`, not a base dependency. Loose `.py` files outside a package are loaded by path, so broken relative imports fail too. - A CI-equivalent venv (`.[api]` + the unit job's test deps) flags only `mcp` and `reportlab` today, and the sweep takes ~7 s cold. No module does an unguarded platform-only import at top level, so the Windows smoke lane should match. That lane is not verified locally. - No open PR modifies a deleted file. amd#4260 edits the chat agent's `app.py`, not `src/gaia/rag/app.py`. </details> ## Test plan - [x] `pytest tests/unit/test_import_all_modules.py`: fails on `origin/main` (shell/prompt.py + 3 mic scripts). It also fails with prompt_toolkit installed (broken relative import) and with an `__init__.py` added (`gaia.shell.commands` missing). Passes on this branch in both the full dev venv and a `.[api]`-only venv. - [x] `pytest tests/unit/test_rag_index_status.py tests/unit/test_packaging.py tests/unit/test_model_comparison.py tests/unit/email tests/unit/rag tests/test_rag.py`: 296 passed, 9 skipped - [x] `pytest tests/unit` (`.[api]` venv): 14422 passed. The 23 failures (`test_cli_smoke`, `test_uninstall_command`, `test_lemonade_asr`) also fail on `origin/main` in the same env. - [x] C++: `cmake -S cpp -G Ninja && cmake --build` builds clean, and `tests_mock` passes 1002/1002 - [x] black, isort, pylint (CI flags) on the changed Python files - [ ] Windows and macOS unit smoke lanes pass (CI) Part of amd#4243 Co-authored-by: Kalin Ovtcharov <[email protected]>
Running
/clear-cacheingaia chatfrom your home directory deleted the whole~/.gaiafolder, which holds memory, connector sign-ins, installed agents and models. It then recreated an empty folder, so nothing looked wrong until the next run asked you to log in again. Started from anywhere else, every run left a stray.gaia/folder in the working directory. Now the RAG cache lives in~/.gaia/cache/rag(it honoursGAIA_CONFIG_DIR), clearing removes only the files the cache wrote, and it refuses outright if the cache dir is$HOMEor~/.gaia. Old./.gaiacaches aren't migrated: the cache is content-hashed and rebuilds on the next index.Test plan
origin/main(5 failed) and pass with the fix:~/.cache/gaia-dev/venv/bin/python -m pytest tests/test_rag.py -q→ 47 passedpytest tests/unit/rag tests/unit/test_rag*.py hub/agents/chat/python/tests -qpass.tests/test_sdk.pyhas 17 failures from its own stale interface checks (index_documents,create_app); none involve this changepython -m gaia.rag.app clear-cache --forcerun from a scratch home withGAIA_CONFIG_DIRset: removed the cache file,.gaia/memory.dbsurvived, andstatusshows the absolute cache path/clear-cacheinside an interactivegaia chatsession (needs Lemonade running)Fixes #4194