Skip to content

test(tool-loader): measure reduction guards against a same-run baseline - #4125

Merged
kovtcharov-amd merged 3 commits into
mainfrom
kalin/tool-budget-pins
Sep 25, 2026
Merged

kovtcharov-amd merged 3 commits into
mainfrom
kalin/tool-budget-pins

Conversation

@kovtcharov-amd

@kovtcharov-amd kovtcharov-amd commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

The tool-loader budget tests went red on main without anything regressing. Four
tests failed at once, three of them pointing at CORE bloat that never happened —
CORE's share of the registry moved from ~40% to ~43% while the registry itself
grew. The cause is that the reduction guards divided a freshly-measured numerator
by a constant frozen in June, so any registry-wide edit trips every guard
simultaneously and buries the one failure that actually means something. Those
guards now take their baseline from the same run, so a real CORE regression fails
the CORE test and a schema-wide change fails only the pin test.

This PR does not turn the file green, and that is deliberate. The tool count
is re-pinned to 38, because #3670 added read_tool_output to the doc profile on
2026-09-18 — an unconditional 12th CORE tool, so the old 37 is a stale
measurement, not a regression. The char and token pins are left alone: #4038
re-pins them on the same lines and earns those numbers by trimming the very
docstrings they measure (~17% smaller), so any value pinned here is wrong the
moment it lands. One failure therefore survives this PR —
test_token_baseline_when_tiktoken_available — and it is #4038's to fix. The
share ceilings hold on both sides: CORE measures 42.8% native today and 41.0%
with #4038 applied, against a 45% ceiling.

A green check on this PR verifies none of the above. No CI lane executes this
file: test_unit.yml collects it but never installs the chat wheel, so the root
conftest.py leaves gaia_agent_chat unimportable and pytest.importorskip
skips the whole module at collection without printing a line. That is why the
pins rotted unnoticed — tracked in #4121, not fixed here. Every result below was
produced locally.

Test plan

  • pytest tests/unit/test_tool_loader_token_budget.py on this branch at current main → 1 failed, 9 passed (was 2 failed, 8 passed before the count re-pin); the survivor is the native-token pin perf(tools): a budget for tool descriptions, enforced by lint #4038 owns
  • Test-merged with perf(tools): a budget for tool descriptions, enforced by lint #4038: clean merge, no conflict; test_tool_loader_token_budget.py + test_tool_description_budget.py → 19 passed
  • Guard still bites: temporarily inflated a CORE docstring by ~370 tokens (inside the absolute band, so only the share guard can see it) → 1 failed, 9 passed, CORE native tokens 3104 exceeded 45% of the 6762-token registry measured in this run. Reverted; not committed.
  • Guard stays quiet on registry-wide growth: temporarily grew a non-CORE docstring past the band → 2 failed, 8 passed, both ratio guards silent. Before this change the same edit took down all four. Reverted; not committed.
  • Count is not platform-conditional: read the doc profile's whole registration path — every gate in _register_tools() is profile, config, or constructor-arg; platform.system() appears only in prompt text and tool bodies, never around a registration.
  • python util/lint.py --all → exit 0.

…seline

The four failures in this file were one stale measurement, not a CORE
regression. CORE's share of the doc tool registry has barely moved (40% ->
43% native since the pins were set); the registry itself grew 23%, so every
guard that divided a live numerator by a frozen June denominator went red
at once.

Re-pin the absolute constants to values measured on this checkout, and
change the two reduction guards to take their ratio against a baseline
measured in the same run. Absolute drift is now detected only by
test_harness_runs_and_pins_baseline, which is the test that is supposed to
notice it.
@github-actions github-actions Bot added the tests Test changes label Sep 22, 2026
#4038 re-pins EXPECTED_DOC_TOOL_COUNT, BASELINE_NATIVE_CHARS and
BASELINE_NATIVE_TOKENS on the same lines, and earns those numbers by
changing the schema: dropping the duplicated Args: block from description
and trimming 21 docstrings. The values measured here are correct on main
today and ~17% too high the moment that lands, so a conflict resolved in
this PR's favour would re-break the band it is meant to protect.

Back the re-pins out and keep the structural change. The share ceilings
hold on both sides: CORE measures 42.8% native on main and 41.0% with
#4038 applied, against a 45% ceiling.
The doc profile has had 38 tools since #3670 added `read_tool_output` on
2026-09-18, so the pinned 37 is a stale measurement rather than a
regression. It registers unconditionally — there is no platform gate and
no optional-import gate anywhere in the doc profile's registration path —
so the count is the same on every machine.

Only the count. The char and token pins stay where they are: #4038
re-pins them on the same lines and earns those numbers by trimming the
docstrings they measure, so a value pinned here would be ~18% outside the
band the moment it lands. A docstring trim cannot move a count, so both
PRs make the identical edit to this line and neither side can lose it.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

The only file this PR changes is never executed by any CI lane, so the green checks here are not evidence that the change works. Review the diff on its merits rather than reading green as verification — the behaviour it guards is untested in CI today.

Nothing to fix in this PR itself: the gap is in the lane, not the change. Tracked systemically in #4121, and #4124 adds the guard that would have flagged it automatically.

🔍 Technical details

tests/unit/test_tool_loader_token_budget.py calls pytest.importorskip("gaia_agent_chat") at line 35. test_unit.yml installs -e ".[api]" and never -e hub/agents/chat/python, and the root conftest.py only prepends a hub agent to sys.path when find_spec() already resolves — it redirects an existing install, it never creates one. The module therefore aborts during collection.

Receipt from this PR's own Unit Tests (py3.12) job 106707658772 (run 35715947900, head 797c2361c8):

string searched in the job log hits
tool_loader_token_budget 0
test_tool_loader_selection.py (alphabetical neighbour, control) 34
test_tool_recall.py (alphabetical neighbour, control) 19

It is not even reported as skipped. The job prints 13439 passed, 227 skipped with 148 SKIPPED lines enumerated, and this module is not among them — a collection-time importorskip aborts before the skip report, and the lane passes no -rs.

No other lane covers it. Test Gaia Agent (job 106707360391, SUCCESS) is the one lane on this PR that installs gaia_agent_chat, but it runs a hand-enumerated list of test files that omits this module — 0 hits in its log too.

First spotted while verifying a different PR's test execution in run 35724630521 job 106735254355, where the same 0 / 34 / 19 contrast holds.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit f8f8ddd Sep 25, 2026
31 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/tool-budget-pins branch September 25, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants