Repository navigation
fix(llm): preserve context overrides on local model reload - #3669
kovtcharov wants to merge 8 commits into
Conversation
Request changesThis makes Warnings now print on the normal startup path. While GAIA waits for Lemonade to come up, every failed health poll (once every 2 seconds, which is the expected state until the server is ready) now logs a warning. A successful Dialing the window down now has teeth, with no guard. Previously a low override only relaxed the startup requirement — the model still loaded at its registered window. Now Two tests now depend on whatever machine runs them. The model-loading tests assert a 64K window, but the resolver reads the persisted device setting and the environment variable at call time. On a Ryzen AI box configured for NPU — or any machine with Real-world evidenceNo evidence bundle was produced for this run ( 🔍 Technical details🟡 Important1. Retry-loop probes now log at WARNING ( The startup wait loop polls The other 2. No floor guard on a lowered override (
3. Tests read ambient device config and env (
The same applies to the pre-existing 🟢 Minor
Strengths
|
# Conflicts: # src/gaia/llm/lemonade_client.py # src/gaia/llm/lemonade_manager.py
|
Refreshed this branch against current This PR's helper decides what window to ask for (device profile, the 🔍 Technical detailsConflicts in Every non-conflicted file was diffed against 237 passed. 8 failures in Merged, not rebased. |
One conflict, in `lemonade_client.py`: both sides added a new context-size helper at the same spot, and each has live callers, so both stay. `resolve_ctx_size(model, device)` (this branch) decides what window to REQUEST at load time and is what honours `GAIA_CTX_SIZE`; it is called from the agent base, the CLI, the installer and the manager. `active_profile_ctx_size()` (main, amd#4095) reports the device profile's own window with no override applied, and exists so the context-overflow classifiers can judge a reported `n_ctx`. Collapsing them would break one caller or the other. `cli.py` and `agent.py` automerged, and both sides' intent survives: main's `classify_lemonade_exception` error reporting is intact, and the inline `GAIA_CTX_SIZE` block this branch replaced with the central resolver stays deleted (main never touched it after the merge base).
GAIA can now answer follow-ups using prior tool evidence in the TUI, including after reopening its transcript. Previously the saved conversation could retain only the final prose, losing facts the tools had read. Complete turns are archived locally and replayed within a budget that reserves room for the current prompt, tools, and answer. Closes #3628. Depends on #3669 (included here); also includes the SDK null-content normalization from #3758 with original authorship. <details> <summary>🔍 Technical details</summary> The TUI stores its transcript under `GAIA_TUI_HOME/history/`; `--history-file` or `GAIA_HISTORY_FILE` reopens an explicit transcript. Whole tool groups stay intact when older turns leave the active window. Persistence completes before the terminal response, and clearing the history deletes its archive. Legacy chat persistence uses the same budget calculation. </details> ## Test plan - [x] 219 integrated configuration, SDK, history, and stdio tests passed; 106 history/stdio tests passed after the final error-handler cleanup. - [x] CI runs the history/stdio regression coverage and context-resolution tests. - [x] Real TUI with local Gemma-4-E4B and memory disabled: read a file, omit its facts from the final answer, delete the file, then recover its code in a follow-up without a tool call. - [x] Restart the TUI with the same transcript and recover ledger number `7319`, which appeared only in the deleted file's tool result. - [ ] Formal agent quality evaluation and human review. One initial live follow-up hit a backend timeout; the retry and restart checks passed. These checks establish evidence retention, not a latency or quality benchmark. --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Tomasz Iniewicz <[email protected]>
|
This work has already shipped — every line of it is on Worth flagging before you take my word for it: merging this branch today would actually move Two things this close does not sweep under the rug:
If you have local work on this branch that was never pushed, none of the above can see it — reopen or open a fresh PR and I'll look again. 🔍 Technical detailsVerified against 1. Merging adds nothing. The entire content delta of the merge is 8 lines of conflict-marker scaffolding: 2. Both conflicts are Resolving the merge toward 3. Every added line is already on Both brand-new test files are byte-identical to 4. Provenance. No revert of #3666 exists on 5. Review findings. All three 🟡 Important items from the earlier bot review are addressed in the shipped code — debug-level startup health probes, the |
|
Closing as superseded — see the evidence above. Follow-up for the two remaining gaps: #4362. Reopen if you have unpushed work on this branch. |
amd#4297) Before auto-downloading a model, GAIA guessed its size from the name and checked free space on whatever disk the command ran from. Gemma-4-E4B was estimated at 2.5 GB against a real 5.56 GB, so a nearly full drive could pass and run out mid-download, while a remote server with room could be refused. Now the check uses the catalog's real size and Lemonade's own model-cache free space, and fails loudly if the server doesn't report it. The first-run "Downloading model… several minutes" banner can now actually appear, and `gaia init` stops unloading models that were only downloaded, never loaded. Overlaps textually with amd#3669, which touches the old `except` in `check_model_loaded`. This PR replaces that body, so whichever lands second needs a small rebase. ## Test plan - [x] `python -m pytest tests/unit/test_lemonade_predownload_checks.py -q`: 12 pass. On `origin/main`, 10 fail and 2 pass (the 2 passing are control cases). - [x] `LEMONADE_BASE_URL=<live server> python -m pytest tests/integration/test_lemonade_predownload_checks.py -v`: 3 pass against a live Lemonade 11.8.1. All 3 fail on `origin/main`. - [x] Neighbouring suites (`test_lemonade_ctx_ceiling`, `test_lemonade_model_loading`, `test_lemonade_manager_preload`, `test_llamacpp_backend`, `test_init_command`, `tests/unit/installer`, `test_hardware_advisor_agent`, …): 682 pass. The 2 `test_uninstall_command` failures also fail on `origin/main`. - [x] `tests/test_lemonade_client.py -k Mock`: the same 11 tests fail before and after this change (pre-existing on this machine). - [x] black, isort, and pylint (repo rcfile) clean. Fixes amd#4214 Co-authored-by: Kalin Ovtcharov <[email protected]>
…blocking (amd#4344) 43 test files ran in no CI lane, so they looked green on every PR whether they worked or not. The checker from amd#4124 could see the gap but blocked nothing, so the count kept growing. After this PR, every test file either runs in a lane or is listed with the reason CI can't run it, and lint fails as soon as a new file is neither. Stacked on amd#4343 — merge that first. It repairs the files this PR starts running. - **23 files that need no Lemonade, live account, or AMD hardware** now run in a new `offline-integration` job in `test_unit.yml`. The job takes about 2 minutes of tests, in parallel with the unit job, so the unit job's 30-minute budget isn't touched. One more email file joins the email unit lane. - **18 files are allowlisted with a reason.** Most need a live Lemonade Server, a real Gmail account, or a self-hosted model runner; two are hand-run scripts. Two of them (`tests/mcp/test_mcp_cli_to_agent_workflow.py`, `test_mcp_sdk_integration.py`) fetch unpinned MCP servers from npm at test time **and are broken today**. Their entries say so, so a reviewer can decide whether to repair or delete them. - **The file-search tests no longer walk the real home directory.** On a developer Mac, `test_search_finds_file` ran past a 2-minute timeout, and most search assertions only checked results "if found". They now search a fake home and assert exact results; `test_files_router.py` takes about 4 s with the real `HOME` set. - **The check is now blocking** in `util/lint.py --all`, which CI already runs. Overlaps: amd#4348 makes the whole of `test_files_router.py` use a fake home, so it touches the same search tests. Whichever PR lands second resolves a small conflict. amd#4038 adds its own lint check in the same spots of `util/lint.py` and `docs/reference/dev.mdx`, so expect a trivial conflict there. amd#3669, amd#3721, and amd#3812 touch other parts of `test_unit.yml`. ## Test plan - [x] Before, on `origin/main`: `python util/check_test_lane_coverage.py` reports 43 files and exits 1 - [x] After: the checker exits 0 (850 files, 18 allowlisted), and `python util/lint.py --test-lanes` fails when a new unwired `tests/test_*.py` is added - [x] The new job's exact file list passes locally in a clean py3.12 venv matching its install step, with homes isolated and Lemonade unreachable: 534 passed, 12 skipped - [x] `test_search_finds_file` hangs past 130 s on this branch before the fix, with the real `HOME` set. After it, the whole of `test_files_router.py` passes in 4 s (75 passed, 1 skipped) - [x] The email lane's full command plus the added file passes: 4971 passed - [x] `actionlint` is clean on the three edited workflows, and `black`, `isort`, and `pylint --errors-only` are clean on `util/lint.py` - [ ] Watch this PR's `Offline Integration Tests` job go green on Linux. `test_backend_install_command_is_accepted` only runs there (it's skipped on macOS), so CI is its first real run Fixes amd#4205 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
…4353) About 300 unit tests never ran in CI. Their files skip as a whole when a hub wheel (`gaia_agent_chat`, `gaia_agent`, `gaia_agent_email`) or an optional extra is missing. The unit lane lacks them, but it still names the files, so the lane check counted them as covered. With this PR, each file runs in a lane that installs what it needs, and a lane fails when a file skips as a whole without an allowlist entry saying which lane runs it. Stacked on #4344. Merge #4343 and #4344 first. - **The new guard runs inside each lane**, right after install. It collects the job's own pytest commands in that lane's environment, so it sees what the lane actually runs. It reports the skipping file by name. This matters because a file that imports a skipping helper is otherwise blamed on the helper's line: `test_chat_inline_web_ssrf.py` was hidden that way. - **Two moved files needed repairs to pass together.** `test_chat_fix_contracts.py` picked up file tools leaked from earlier tests. `test_chat_system_prompt_budget.py` evicted the chat agent module at collection, so other files' patches stopped hitting it. - **Two files stay allowlisted with no lane, for an owner to decide.** `test_profilespec_characterization.py` has 11 golden rows that drifted, and its docstring says golden updates need sign-off. `test_tool_loader_token_budget.py` has 4 token and tool-count pins that are stale, and even re-pinned, one ratio is over budget. Overlaps: #4350 is also stacked on #4344 and edits the offline-integration list and the allowlist, so expect a small conflict there. #4038, #3721, #3669, #3812 and #3072 touch other parts of `test_unit.yml` and `test_gaia_agent.yml`. ## Test plan - [x] Before: `python util/check_module_skips.py --workflow test_unit.yml --job unit-tests` with no `module_skips` entries reports 80 files skipping wholesale and exits 1 - [x] After: the guard exits 0 for all 7 guarded jobs, each run in a clean py3.12 venv built from that job's install step - [x] `python util/check_test_lane_coverage.py` and `python util/lint.py --test-lanes` pass (31 module-skip entries verified) - [x] New tests: `pytest tests/unit/test_check_module_skips.py tests/unit/test_check_test_lane_coverage.py` passes 64. They include a real `--collect-only` over a temp repo - [x] Chat-lane files in the chat env: 421 passed. Before the two test repairs, 2 failed when run together - [x] Flagship-lane files in the gaia env: 59 passed. `test_mcp2_server.py` plus the MCP transcript tests in the MCP env: 27 passed - [x] Email unit lane's full command plus `test_synthetic_mbox.py`: 4980 passed - [x] The 4 newly unskipped files in the unit job (docx, pptx, reportlab, slack): 60 passed. Full `tests/unit/` in that env: 14509 passed, 23 failed. The failures are in 3 files (uninstall, CLI smoke, Lemonade ASR) that also fail when run alone. They come from this Mac's setup: `GAIA_HOME` isolated and `gaia` not on PATH. This PR changes no code those files exercise - [x] `actionlint` is clean on the 6 edited workflows. `black`, `isort`, and `pylint --errors-only` are clean on the changed Python - [ ] Watch the MCP lane's Windows leg run `test_mcp2_server.py` and the guard. They were only run on macOS locally Fixes #4206 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Ovtcharov <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: f <f@f> Co-authored-by: probe <probe@local>
Context overrides now survive CLI startup, agent construction, installer verification and local model reloads. All use the same resolver: unknown local models follow the configured profile, GPU/CPU overrides can exceed 64K, and NPU/FLM requests cap at 32K with a warning. Installer verification uses the profile being installed rather than previously saved device settings. Invalid values fail clearly; cloud routing and exact SDK pins retain their separate behavior.
Closes #3634. This fixes requested context capacity, not the separately tracked overflow-recovery policy or a claim that larger windows improve model quality.
Validation: 289 ordered configuration, constructor, installer, backend and real loopback HTTP tests pass, including startup→eviction→reload→reuse at 16K and 128K. Code and architecture review approved. CI includes the resolver and HTTP reload regression tests. Hardware/model capacity remains dependent on the selected backend; no 153K+ capacity or quality claim is made. Latest hosted CI and human review remain required before merge.