Repository navigation
test(tool-loader): pin #800 doc-profile data-vs-recall disambiguation - #1844
Conversation
Review — ApproveVerdict: Approve. This is a clean test + docs closeout for #800 with no runtime code changes. It adds a deterministic regression test, a live eval scenario, and an in-repo note that together pin a fix (the dynamic tool loader) that until now had no test guarding it. The work is solid and the claims hold up. I re-ran the 4 new unit tests against the real loader/config and they pass; the central argument — that memory One thing worth a follow-up, non-blocking: the committed eval scenario currently records a FAIL (per the PR description) for a reason unrelated to #800 — a bug in how the data tool handles the monthly-summary CSV plus an agent hallucination on turn 1. Shipping a "live proof" scenario that's red can read as "the feature is broken" to anyone who runs the suite without reading this PR. The unit test is correctly the binding gate, so this is fine to merge — but please file a tracking issue for that separate data-tool bug so the red scenario has a paper trail and eventually goes green. 🔍 Technical detailsVerification performed
Issues🟡 Committed eval scenario is currently red for an unrelated reason ( 🟢 Thin top-salesperson margin ( Strengths
|
CI failures are pre-existing Windows/Lemonade infra flakiness — not caused by this PRThe two red checks are both Windows + real-Lemonade-Server integration steps that this PR's diff (one unit test, one eval scenario YAML, one docs note) neither touches nor runs. What actually failed
Why this PR triggered them (but didn't cause the failure)Both workflows trigger on Evidence it's flaky infra, not a code defect
Recommendation
|
Consolidating every agent onto `Gemma-4-E4B-it-GGUF` is an LLM-affecting change, and CLAUDE.md requires `gaia eval agent` runs against the committed baselines for exactly that class of change — but no CI job ran them, because they need Lemonade on real AMD hardware. Today the consolidation could merge on unit tests alone, which cover code paths and say nothing about model behavior. This adds the missing job on the self-hosted `lemonade-eval` pool: it runs `rag_quality`, `context_retention` and `tool_selection` serially, compares each against its committed Gemma baseline, and uploads the scorecards and traces. It **reports** rather than blocks by default. Code-generation and data-analysis scenarios are expected to regress on a 35B MoE → ~4B swap and that tradeoff is accepted; wiring `--compare`'s exit 2 straight to the step result would make the job permanently red, and a job that is always red gates nothing. Set `enforce: true` (or put `[eval-enforce]` in the commit message) to make regressions blocking. One gate is **not** softened by report mode. `gaia eval agent --compare` only scores scenarios present on both sides, so scenarios that vanish from a run land in an `only_in_baseline` bucket outside its exit-2 verdict — I confirmed that dropping 6 of 7 `rag_quality` scenarios still exits **0**. A broken harness would otherwise sail through as "no regression". The integrity gate therefore fails the job unconditionally when a baseline scenario is missing or came back unmeasured, whatever `enforce` says. ### Verified against a live Lemonade 10.10.0 Behavior this workflow depends on, checked on real fixtures rather than assumed: - `--compare` exits **0** clean, **2** on a real regression (`PASS → FAIL`), **1** on a missing file — the workflow treats only 2 as a verdict and any other non-zero as a harness error. - `gaia eval agent --category X` exits **0** regardless of scenario scores, so the `&&` chain does not short-circuit on the expected regressions. - Scenarios present in CURRENT but absent from BASELINE are neutral — relevant because `tool_selection` now has 5 scenarios on disk vs 4 in the baseline (`data_vs_recall_disambiguation`, added by amd#1844, is currently ungated until a baseline refresh). - The integrity gate itself: passes a healthy run, fails the 6-of-7-vanished case, fails an all-`INFRA_ERROR` category. - Backend `/api/health` returns 200; the `Output: <run-dir>` parsing handles trailing slashes and multiple matches. ### Test plan - [ ] First push to a branch touching a `paths:` entry fires the job — this is the first real runner execution and the debugging pass. - [ ] Confirm the `lemonade-eval` pool is bash and has a persistent Lemonade; the preflight fails loudly with an actionable message if not. - [ ] Confirm `pip install -e ".[dev,eval,ui,api]"` resolves on the runner. - [ ] Check the wall time against the 150-min budget and tighten if there is slack. - [ ] Re-dispatch with `enforce: true` once the accepted regressions are folded into refreshed baselines. ### Notes for the reviewer - Timeout is **150**, not the siblings' 90. The three baselines sum to ~55 min of pure scenario time before install, backend boot and judge latency; a timeout cancels the job and can take the artifact with it. Happy to drop it back once a few runs establish the real number. - Time regressions are **not** comparable to this baseline — it was captured against a remote Lemonade over ngrok on different hardware (see its `meta.json`). `--compare` folds a >2x wall-clock delta into the same exit 2 as a quality regression. The summary block says so; regenerating the baselines on the runner would fix it properly. - `gemma-4-e4b-d71cd914` is the only baseline covering all three categories. `gemma-4-e4b-95e4b372` is newer but `rag_quality`-only.
…ad overwrite (amd#3364) ## Summary Fixes three shipped features that are broken in ordinary use: `gaia api` returned HTTP 500 on every chat completion, web fetch failed on most HTTPS sites, and a download could silently replace a file the user already had. ## Why `POST /v1/chat/completions` failed on *every* request, streaming or not — the server passed a `workspace_root=` keyword that no agent accepts, so the call raised before reaching the model. The whole endpoint was dead for anyone running the flagship agent. Web fetch was failing on most of the web. The IP-pinning adapter closed a DNS-rebinding window by rewriting the request URL's host to the resolved IP, which meant every HTTPS request went out with no SNI — so any host that picks its certificate by SNI returned the wrong one or refused the handshake. Measured live, 9 of 11 hosts failed through `WebClient` while succeeding through plain `requests`, including GitHub, PyPI, Hugging Face and GAIA's own `amd-gaia.ai`. "Summarise this GitHub URL" returned an SSL error. The third is the reason the first two ship together. `download_file` took its filename from the remote `Content-Disposition` header and opened the destination with no existence check, so a page serving `filename=report.pdf` replaced the user's own `~/Downloads/report.pdf`. Today the handshake usually fails first, so the write path is rarely reached — fixing SNI *un-gates* it. It is fixed in the earlier commit on purpose. ## Linked issue Closes amd#3360 ## Changes - **API** — dropped the `workspace_root` kwarg and the `extract_workspace_root` helper that fed it. Nothing consumed it: its only consumer was a deleted agent, and no agent implements the `set_workspace_root` hook the spec described. A Copilot `<workspace_info>` block is now ordinary message text. - **Web fetch** — SNI is set via `build_connection_pool_key_attributes`, the extension point `requests` documents for this, so the socket still dials the validated pinned IP while TLS names the real host. `assert_hostname` is deliberately *not* set: it moves name checking out of the handshake and flips `check_hostname = False` on an SSL context `requests` shares process-wide on some versions. `requests` is pinned `>=2.32.3` — **2.32.2 is specifically unusable**, it routes through `get_connection_with_tls_context` but has no such hook, so SNI would silently revert to the IP. - **Download** — the destination is checked, and handed to the caller's policy screen, *before* anything is created; the body streams to a `.part` file renamed into place only on success. The sensitive-filename blocklist moved from after the write (where it reacted by deleting the file, and only when a `_path_validator` was attached) to before it. - The live TLS test is wired into the unit-tests workflow — an adapter like this can pass every offline test and still fail every real handshake. The rebinding defence is unchanged and re-verified: `validate_url` still rejects a hostname if *any* answer is private, the adapter still re-validates the exact IP it dials, and each redirect hop is still re-validated. ## Test plan - [x] `python util/lint.py --all` — Black / isort / Flake8 / Bandit pass. Pylint reports 9 pre-existing errors, all `os.killpg`/`geteuid` Windows false positives in `daemon/sidecars/*` and `installer/lemonade_installer.py`; none in a file this PR touches. - [x] `pytest tests/unit/test_browser_tools.py` — 73 passed - [x] `pytest tests/unit/test_web_client_ip_pinning.py tests/integration/test_web_client_live_sni.py` — 24 passed - [x] `pytest tests/test_api.py` — 57 passed, 22 skipped (skips are `gaia_agent_email`-gated) - [x] Every unit/integration test file that imports the three changed modules — **462 passed, 0 failed**. - [x] Pre-existing baseline, so a reviewer is not surprised: on Windows the full `pytest tests/unit/` has ~1000 failures/errors from the known `socket.socketpair()` / `_block_network` guard, and `tests/test_sdk.py` fails 17 tests. Both reproduce identically with this branch's source files reverted to `upstream/main`. None are in a file this PR touches. CI runs these on ubuntu, where the socket guard does not fire. - [x] **New tests fail against the previous code**, which is the point: 3/3 API tests fail with `TypeError: Agent.process_query() got an unexpected keyword argument 'workspace_root'`; 5/7 live TLS tests fail with `SSLError`; 6/8 download tests fail. - [x] **CI lanes confirmed to actually run them, not skip them.** `tests/unit/**` → `test_unit.yml` (`pytest tests/unit/`, installs `.[api]` + `pytest-mock`). `tests/test_api.py` → `test_api.yml` (triggers on `src/gaia/api/**` and `tests/test_api.py`, installs `.[dev,api]`, so `fastapi` is present and the new class runs rather than skipping). `tests/integration/test_web_client_live_sni.py` had **no** lane — added as a step to `test_unit.yml`, alongside the existing live-upstream Lemonade asset test. Verified with `-v` that every new test reports `PASSED`, none `SKIPPED`. ### Agent eval — `tool_selection`, no regressions This touches an LLM-affecting surface (two lines added to `download_file`'s `@tool` docstring), so per CLAUDE.md an eval is required. It ran **against this branch at `87b9479c`** — the Agent UI backend on `:4200` was started from this worktree's own venv, so the numbers describe this PR's code, not an installed release. Lemonade served `Gemma-4-E4B-it-GGUF` on GPU at `ctx_size=32768`. `tool_selection` is the category the changed tool docstring feeds. ``` gaia eval agent --category tool_selection → Results: 4/5 passed (80% all, 80% judged), Avg score: 8.7/10 Output: eval/results/eval-20260904-210550/ gaia eval agent --compare \ tests/fixtures/eval_baselines/gemma-4-e4b-d71cd914/scorecard_tool_selection.json \ eval/results/eval-20260904-210550/scorecard.json ``` <details> <summary>🔍 `gaia eval agent --compare` — the tool's own output</summary> ``` SCORECARD COMPARISON Baseline : tests\fixtures\eval_baselines\gemma-4-e4b-d71cd914\scorecard_tool_selection.json Current : eval\results\eval-20260904-210550\scorecard.json ====================================================================== METRIC BASELINE CURRENT DELTA -------------------------------------------------------------- Pass rate (all) 75% 80% +5% Pass rate (judged) 75% 80% +5% Avg score 8.4 8.7 +0.3 Scenarios 4 5 [+] IMPROVED (1 scenario(s)) — FAIL → PASS: known_path_read 6.7 → 9.6 (+2.9) [~] TIME REGRESSION (1 scenario(s)) — elapsed > 2x baseline: smart_discovery 179.1s → 417.2s [~] SCORE CHANGED, STATUS SAME (1 scenario(s)): multi_step_plan PASS 7.3 → 9.8 (+2.5) [=] UNCHANGED (1 scenario(s)): no_tools_needed PASS 10.0 [+] ONLY IN CURRENT (1 scenario(s)) — new scenarios: data_vs_recall_disambiguation ====================================================================== [WARN] 1 time regression(s) detected (elapsed time > 2x baseline)! [OK] Net improvement: 1 scenario(s) fixed, 0 regressions. ====================================================================== [ERROR] Detected 1 issue(s) (status regressions, score regressions, or time regressions); failing. ``` </details> | Metric | Baseline | Current | Δ | |---|---|---|---| | Pass rate (all) | 75% | **80%** | +5% | | Pass rate (judged) | 75% | **80%** | +5% | | Avg score | 8.4 | **8.7** | +0.3 | | Scenarios | 4 | 5 | +1 | Per scenario: | Scenario | Baseline | Current | |---|---|---| | `known_path_read` | FAIL 6.7 | **PASS 9.6** | | `multi_step_plan` | PASS 7.3 | PASS 9.8 | | `no_tools_needed` | PASS 10.0 | PASS 10.0 | | `smart_discovery` | PASS 9.5 | PASS 8.1 | | `data_vs_recall_disambiguation` | *not in baseline* | FAIL 6.4 | **No status or score regressions.** The baseline's one failing scenario now passes. Three caveats, so the numbers are not read for more than they are worth: - **The score deltas are not purely behavioural.** The baseline was judged by `claude-sonnet-4-6`, this run by `claude-opus-5`; the compare tool warns about exactly this. Treat "no regression" as the signal, not the `+2.5` on `multi_step_plan`. - **`data_vs_recall_disambiguation` has no baseline entry** because it did not exist yet: it was added 2026-06-25 in amd#1844, two months after the baseline was captured (2026-04-24). The extra scenario is not a discrepancy. On the 4 overlapping scenarios the result is 4/4 pass vs the baseline's 3/4. - **Zero scenarios errored.** The same command errored all 5 at 0 turns before the auth cause below was found (run `eval-20260904-210157`), so the clean run is itself the confirmation that the diagnosis was right. - **The one flagged "time regression" is hardware, not this change.** `smart_discovery` went 179s → 417s, but the baseline machine sustained 109–115 tok/s where this one runs at 38–45 tok/s — ~2.7× slower, which accounts for the gap on the token-heaviest scenario (8335→2083 tokens). The other three scenarios are *faster* in wall-clock despite that. The docstring addition is ~25 tokens on one tool description, 0.3% of that prompt. <details> <summary>🔍 Two pre-existing eval-harness defects found while getting this to run</summary> Both are untouched by this PR and are filed separately as amd#3367 and amd#3368: - **`runner.py:949` adds `--bare` whenever `ANTHROPIC_API_KEY` is non-empty**, and `--bare` restricts auth to that key — OAuth and keychain are never consulted. Because `load_dotenv()` walks up parent directories, a `.env` anywhere above the checkout injects a key into the process even when the shell has none, silently disabling working subscription auth. A stale key then surfaces as HTTP 400 `"Credit balance is too low"`, which points at billing rather than at the override. This is the "no silent fallbacks" rule in CLAUDE.md: it should fail loudly on an auth error, or prefer OAuth when the key is rejected. - **The runner discards the judge subprocess body on failure**, recording `"error": ""`. The real cause above was invisible until the call was instrumented by hand. </details> ## Evidence **HTTP API / REST** — real requests against `gaia api start --port 8199` with the flagship agent installed and Lemonade serving `Gemma-4-E4B-it-GGUF`. Before (this commit's parent): ``` $ curl -sS -X POST http://127.0.0.1:8199/v1/chat/completions -H 'Content-Type: application/json' \ -d '{"model":"gaia","messages":[{"role":"user","content":"What is 17 * 23? Answer with just the number."}],"stream":false}' -w '\nHTTP_STATUS=%{http_code}\n' Internal Server Error HTTP_STATUS=500 # server log: result = agent.process_query(user_message, workspace_root=workspace_root) TypeError: Agent.process_query() got an unexpected keyword argument 'workspace_root' ``` After — same request, same server: ``` {"id":"chatcmpl-675e7b945f51450595107565","object":"chat.completion","created":1788546133,"model":"gaia", "choices":[{"index":0,"message":{"role":"assistant","content":"391","tool_calls":null},"finish_reason":"stop"}], "usage":{"prompt_tokens":11,"completion_tokens":0,"total_tokens":11}} HTTP_STATUS=200 ``` Streaming path — 7 chunks, terminates with `data: [DONE]`, no `"error"` in the body. A Copilot `<workspace_info>` payload also returns 200 (`5 plus 6` → `11`). <details> <summary>🔍 Web fetch — before/after probe across 11 hosts</summary> Same script, same machine, only `client.py` differing. `www.amd.com` times out identically both ways and through plain `requests`, so it is not an SNI failure. | Host | `WebClient` before | `WebClient` after | plain `requests` | |---|---|---|---| | example.com | FAIL SSLError | **OK 200** | OK 200 | | github.com/amd/gaia | FAIL SSLError | **OK 200** | OK 200 | | pypi.org | FAIL SSLError (cert `*.python.org`) | **OK 200** | OK 200 | | huggingface.co | FAIL SSLError | **OK 200** | OK 200 | | amd-gaia.ai | FAIL SSLError | **OK 200** | OK 200 | | lemonade-server.ai | FAIL SSLError | **OK 200** | OK 200 | | arxiv.org | FAIL SSLError (cert `s.sni-810-default.ssl.fastly.net`) | **OK 200** | OK 200 | | stackoverflow.com | FAIL SSLError | **OK 403** | OK 403 | | www.amd.com | FAIL ReadTimeout | FAIL ReadTimeout | FAIL ReadTimeout | | en.wikipedia.org | OK 200 | OK 200 | OK 200 | | duckduckgo.com | OK 200 | OK 200 | OK 200 | **9 of 11 failed → 1 of 11 fails**, and the one remaining failure is identical under plain `requests`. Security posture re-verified after the change: ``` PASS validate_url still checks EVERY answer (127.0.0.1 in the answer set -> blocked) PASS adapter still re-validates the exact dialed IP (169.254.169.254 -> blocked) PASS scheme guard rejects file:// and ftp://; port guard rejects :22 PASS _request and download both re-validate each redirect hop PASS host_params={'scheme':'https','host':'104.20.23.154'}, server_hostname='example.com' PASS wrong.host.badssl.com / expired.badssl.com / self-signed.badssl.com all rejected (SSLError) ``` </details> <details> <summary>🔍 Download — live run of the download_file tool</summary> Live run of the **tool** (not `WebClient` directly), into a directory that already holds a `README.md`: ``` === BEFORE (upstream/main) === $ cat README.md MY OWN IMPORTANT NOTES >>> download_file("https://raw.githubusercontent.com/amd/gaia/main/README.md", save_to=...) Downloaded: README.md Size: 7.3 KB Type: text/plain; charset=utf-8 $ cat README.md # <img src="https://raw.githubusercontent.com/amd/gaia/main/ <-- user's notes destroyed, tool reported success === AFTER (this branch) === $ cat README.md MY OWN IMPORTANT NOTES >>> download_file("https://raw.githubusercontent.com/amd/gaia/main/README.md", save_to=...) Error: Refusing to overwrite existing file: ...\README.md. Pass an explicit filename= to download under a different name. $ cat README.md MY OWN IMPORTANT NOTES <-- intact $ ls ['README.md'] >>> same tool, a free filename Downloaded: gaia-readme.md Size: 7.3 KB $ ls ['README.md', 'gaia-readme.md'] ``` </details> <details> <summary>🔍 Runtime guard against an older requests</summary> `build_connection_pool_key_attributes` only exists in requests >= 2.32.3, so on anything older the SNI override silently never runs. `PinnedIPAdapter` now refuses to construct. Verified against real wheels: | requests | result | |---|---| | 2.31.0 | refused | | 2.32.2 | refused (routes through `get_connection_with_tls_context` but ships no hook) | | 2.32.3 | constructs | | 2.34.2 | constructs | ``` RuntimeError: PinnedIPAdapter needs requests>=2.32.3 to send the correct TLS SNI while pinning the IP, but requests 2.31.0 is installed. Without it every HTTPS fetch names the pinned IP in the handshake and CDN-fronted hosts reject the connection. Upgrade with: pip install --upgrade 'requests>=2.32.3' ``` </details> <details> <summary>🔍 Download — WebClient-level before/after</summary> A directory containing the user's own `README.md`, then downloading a URL whose name resolves to `README.md`: ``` === BEFORE === before: README.md = b'MY OWN IMPORTANT NOTES' download returned: 7463 bytes after: README.md = b'# <img src="https://raw.githubuserconten' <-- user's file destroyed === AFTER === before: README.md = b'MY OWN IMPORTANT NOTES' download refused: ValueError: Refusing to overwrite existing file: ...\README.md. Pass an explicit filename= to download under a different name. after: README.md = b'MY OWN IMPORTANT NOTES' <-- intact dir now: ['README.md'] fresh download OK: 7463 bytes, dir now: ['README.md', 'fresh.md'] <-- a free name still works ``` </details> - [x] **HTTP API / REST** — real request and response above. - [x] **CLI** — `gaia api start` used to produce the evidence above. - [ ] **Agent exposed in the Agent UI** — N/A, no Agent UI surface changed. - [ ] **MCP tools / servers** — N/A, no MCP surface changed. ## Checklist - [x] I have linked a GitHub issue above (`Closes amd#3360`). - [x] I have described **why** this change is being made, not just what changed. - [x] I have run linting and tests locally (`python util/lint.py --all`, `pytest tests/unit/`). - [x] I have attached **real-world evidence matched to the surface I changed**, or marked each surface N/A. - [x] I have updated documentation if user-visible behavior changed — `docs/spec/api-server.mdx` (removed the workspace-root section and renumbered the flow) and `docs/spec/browser-tools.mdx` + the `@tool` docstring (the new overwrite refusal, so the model learns the rule instead of discovering it from an error). --------- Co-authored-by: Ovtcharov <[email protected]>
Summary
Before this PR, #800's scratchpad/memory tool collision was resolved in code (by the #688 dynamic tool loader, landed via #1449/#1450/#1451) but nothing pinned it — no test asserted that the structured-data tool and memory
recallcan't crowd each other out of the prompt, so the fix could silently regress. This adds a deterministic regression test, a live eval scenario, and an in-repo note that together lock the resolution and let #800 close with evidence. No runtime code changes — this is a closeout + regression, not a feature.Why
#800 is a coordination tracker: it exists to prove the collision is fixed, not leave it as a known gap. The decisive finding (verified on
main) is that the literal pair in the title —scratchpad.query_datavsmemory.recall— cannot occur in the loaded profile: scratchpad tools are registered only for the ChatAgentdata/fullprofiles, neverdoc, which is the only profile the loader is wired to. The real doc-profile arbitration isanalyze_data_file(structured-data, conditional) vsrecall(CORE, always-on). That asymmetry is the resolution — and until now no test encoded it.Linked issue
Closes #800
Changes
recall ∈ CORE(always present) whileanalyze_data_fileloads only when the turn's query clears the semantic threshold, using the realDOC_CORE_TOOLS/DOC_BUNDLESconfig and production τ/cap (not hand-picked literals), with a fresh loader per case so it tests the cold/empty-memory new-user state.sales_data_2025.csvcorpus, so the disambiguation is checked against a real model, not just unit logic.Deviations from the approved sketch (#800's body)
Flagged per CLAUDE.md — the landed design diverges from the original sketch in several places:
mainscratchpad.query_datavsmemory.recalldocprofile; loader isdoc-onlyanalyze_data_file(conditional) vsrecall(CORE)recallis CORE → always present; the conditional side isanalyze_data_filerecallis intentionally always-onmaintool_historyTOOL_LOADER {json}INFO lines;gaia.eval.tool_recallconsumes themscratchpad/browserindocdocprofilesmart_discovery(hardware artifact); fixture is also independently staleTest plan
python -m pytest tests/unit/test_tool_loader_disambiguation.py -v→ 4 passed (the AC Update Documentation #5 gate)python -m pytest tests/unit/test_tool_loader_selection.py tests/unit/test_chat_tool_bundles.py tests/unit/test_chat_dynamic_tools.py -q→ 67 passed (no loader regression; confirms the new test's registry/embedder assumptions match shipped config)python -m pytest tests/test_eval.py -k scenarios -q→ 27 passed (validates the new scenario YAML: required fields, sequential turns, existing corpus path)python util/lint.py --all→ cleangaia eval agent --category tool_selection --agent-type doc→ the 4 pre-existing scenarios match the Tool loader — Part 3: skill-driven signal (gated on #887) #1451 Part-3 proof (no selection regression)Checklist
Closes #800).python util/lint.py --all,pytest tests/unit/).#800 Acceptance Criteria — Proof
Verdict: all 7 ACs satisfied on
main+ this PR. The collision is resolved structurally by the #688 dynamic tool loader (landed via #1449/#1450/#1451); this PR pins it. Three ACs are satisfied with the documented reframing above.query_data&recallnot both unless justifiedAC #1 — Tool-prompt token reduction
Reframed: the ~12K figure assumed the text path; the real cost (and gate) is the native tool-schema path / TTFT. The 38-tool doc profile is capped to 14 (
DEFAULT_MAX_TOOLS).test_core_only_is_the_reduction_best_casepins the always-on CORE floor at ≤45% of the native baseline (~50–60% reduction).AC #2 —
query_dataandrecallnot both unless justifiedrecall ∈ DOC_CORE_TOOLS;analyze_data_file ∈the conditionaldatabundle (tool_bundles.py). The conditional tool loads only when the query clears τ:AC #3 — Core tools always available despite heuristic failure
CORE is admitted unconditionally and is cap-/eviction-exempt; on embedder failure the loader disables for the session and falls back to the full registry, logging loudly (
tool_loader.py).AC #4 — Decisions logged for eval/tune
Satisfied with a deliberate deviation: decisions are emitted as structured
TOOL_LOADER {json}INFO lines (not the SQLtool_historytable — avoids a UI-DB migration). Consumed bysrc/gaia/eval/tool_recall.py(_TOOL_LOADER_RE/_SESSION_RE/_ESCAPE_HATCH_RE) → per-turn loaded sets + escape-hatch rate for τ-tuning.AC #5 — End-to-end regression test (data-query vs recall) — new in this PR
tests/unit/test_tool_loader_disambiguation.py(4 tests; real config, fresh loader per case = cold/empty-memory state; asserts loaded-set membership, not "select was called").eval/scenarios/tool_selection/data_vs_recall_disambiguation.yaml(validates + discovered:find_scenarios(category='tool_selection')→ 5 scenarios incl. the new one).AC #6 — Eval suite passes, no selection regression
Live serial run on Gemma-4-E4B corroborates the #1451 Part-3 success-criteria proof — no regression:
known_path_readno_tools_neededmulti_step_plansmart_discovery* hardware artifact of the local Apple-Silicon box (Metal llama.cpp ~14–19 tok/s), not a behavior change. The new scenario records FAIL 6.58 for reasons unrelated to #800: the disambiguation works (agent routed both aggregates to
analyze_data_file, never misusedrecall; Turn 2 returned the exact answer), but Turn 1's correctness failed onanalyze_data_file's date-filter handling of the monthly-summary CSV plus an agent hallucination — flagged as a separate follow-up. Committed baseline refresh deferred to a clean run on target hardware.AC #7 — Mid-conversation re-evaluation works
Proven for in-profile pivots (the sketch's "file→web" example is out of the doc profile — browser tools aren't registered there):