Skip to content

test(api): pin the flagship construction the API server depends on - #3072

Merged
kovtcharov-amd merged 3 commits into
mainfrom
test/pin-flagship-api-construction
Sep 25, 2026
Merged

kovtcharov-amd merged 3 commits into
mainfrom
test/pin-flagship-api-construction

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Renaming one field on ChatAgentConfig breaks /v1/chat/completions for every caller — and the entire API test suite stays green. The server builds the one agent it serves by splatting the registry's init_params plus an SSE output_handler straight into the config dataclass, so any keyword the dataclass stops declaring is a TypeError raised per request; that construction had no test anywhere. It does now, and it drives the real get_agent() rather than a copy of its body, so drift on either side of the contract fails CI instead of shipping.

Test plan

  • python -m pytest hub/agents/gaia/python/tests/test_api_construction.py -xvs — 3 pass
  • python -m pytest hub/agents/gaia/python/tests/ tests/unit/api/ tests/test_api.py -q — no collateral damage (220 + 112 pass locally)
  • Confirm the gate is real: rename output_handler on ChatAgentConfig (hub/agents/chat/python/gaia_agent_chat/agent.py) and re-run — must fail with TypeError: GaiaAgentConfig.__init__() got an unexpected keyword argument 'output_handler'. Before this PR the same break left all 115 API tests passing.
  • Second injected break: add a keyword to init_params inside get_agent() only — must fail. This is why the test calls get_agent() instead of reproducing it.
  • python util/lint.py --imports with and without the hub wheels installed — the new flagship entry reports [OK] when present and [SKIP] when not, never a failure.
🔍 Technical details

Three cases in hub/agents/gaia/python/tests/test_api_construction.py:

  • get_agent("gaia") builds a real GaiaAgent and the SSE handler lands on agent.console — silent_mode=True also ships in init_params, so construction not raising is only half the assertion.
  • AGENT_MODELS["gaia"]["class_name"] still resolves to GaiaAgent; get_agent folds a stale path's ImportError into a generic ValueError, so a rename would otherwise surface only as a runtime 500.
  • _apply_env_overrides() injects debug/silent_mode/show_prompts/streaming for gaia api start --debug; those keys are derived from the function rather than hardcoded, and asserted to be declared fields.

Hermetic and ~14s: memory init is forced off via GAIA_MEMORY_DISABLED and the tool registry is isolated, matching the sibling tests in that directory. No model server needed.

Two smaller items ride along. test_gaia_agent.yml gains src/gaia/api/agent_registry.py in its path filter — without it, editing the registry alone would not run the suite that now guards it. tests/test_api.py and tests/unit/api/test_sse_confirmation_gate.py had comments left garbled by #2995; note the test_api.py stub is defensive rather than load-bearing (model_exists("gaia") is already True), and the rewritten comment says so.

The OpenAI-compatible server builds the one agent it serves by splatting
AGENT_MODELS["gaia"]["init_params"] plus an output_handler straight into
GaiaAgent, which funnels them into the GaiaAgentConfig dataclass. Any
keyword the dataclass does not declare is a TypeError per request, and
nothing covered it: renaming ChatAgentConfig.output_handler leaves all
115 existing API tests green while /v1/chat/completions 500s for every
caller.

The new test drives the real AgentRegistry.get_agent rather than
re-implementing its body, so drift on either side of the contract fails
— a dropped config field and a keyword added only in get_agent were both
verified to fail it. A third case pins the extra keywords
_apply_env_overrides injects for `gaia api start --debug`, which reach
the constructor the same way.

Also adds agent_registry.py to the workflow's path filter, without which
editing the registry alone would not run the suite that guards it, and
adds the flagship to the import smoke-check lists that still named only
the chat agent.
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes labels Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

This closes a real gap: the flagship agent is reached by the OpenAI-compatible API through a call that hands it every configured keyword blind, so a keyword the agent's config doesn't declare would have turned every /v1/chat/completions request into a 500 while the whole test suite stayed green. The new test drives that exact call path — the real registry, the real agent — rather than re-implementing it, which is the right call: a local copy would have pinned the config but not the caller. The CI trigger and the lint import check are updated to match, so editing the registry alone can no longer skip the gate.

I verified the contract the test asserts actually holds today (the config declares every keyword the registry can inject, including the debug-mode ones, and the streaming handler really does reach the agent's console). The three comment rewrites in the existing tests replace genuinely garbled sentences with accurate ones.

Only minor suggestions, none blocking. The most useful: one of the three assertions is weaker than its own error message claims — it would still pass if the streaming flag stopped working, because that key is already present before the flag is applied.

Real-world evidence

N/A — tests and CI configuration only; no user-visible surface changes. The verdict rests on static review plus reading the code under test to confirm the pinned contract holds. I could not execute the new tests in this environment (the review runner's shell is unavailable), so the pass/fail signal has to come from the PR's own CI run of the Gaia Agent Tests workflow.

🔍 Technical details

Issues

🟢 assert injected can't detect a dead streaming flag (hub/agents/gaia/python/tests/test_api_construction.py:146)

streaming is already a key of init_params before _apply_env_overrides() runs, so set(init_params) - set(saved) can only ever surface debug and show_prompts. If GAIA_API_STREAMING stopped being read, this assertion still passes despite its message. It also fails spuriously if GAIA_API_DEBUG=1 happens to be set in the ambient environment at import time, since then saved already contains the injected keys. Asserting the expected key set fixes both:

    assert {"debug", "show_prompts", "streaming"} <= set(
        init_params
    ), f"_apply_env_overrides did not apply every flag — got {sorted(init_params)}."

(Worth noting while you're in there: _apply_env_overrides's docstring advertises GAIA_API_STEP_THROUGH, but nothing in the function reads it — src/gaia/api/agent_registry.py:61. Out of scope for this PR, but it is exactly the "the flags are dead" failure mode this test is named for.)

🟢 _isolated_registry is now copy-pasted in three sibling files (test_api_construction.py:37, test_gaia_agent.py:46, test_full_tool_bundles.py:43)

Third copy, identical body. Worth lifting into a conftest.py in hub/agents/gaia/python/tests/ as a fixture or shared helper — the GAIA_MEMORY_DISABLED monkeypatch pairs with it at every call site too, so one fixture would cover both halves of the setup.

🟢 The new CI trigger covers agent_registry.py but not the other module the test pins (.github/workflows/test_gaia_agent.yml:25, :40)

test_get_agent_builds_the_flagship_and_installs_the_sse_handler asserts isinstance(agent.console, SSEOutputHandler), so a rename or move in src/gaia/api/sse_handler.py breaks this suite without triggering it. Since src/gaia/api/ is small and rarely touched, widening the filter is cheaper than maintaining a per-file list:

      # agent_registry.py's init_params are pinned against the flagship's
      # constructor, and sse_handler.py against its console, so editing the
      # API layer alone must still run that gate.
      - 'src/gaia/api/**'

Strengths

  • Calls get_agent instead of re-implementing it. The module docstring explains precisely why, and it's correct — the registry passes keywords through unfiltered while the entry-point factory (gaia_agent/__init__.py:43) filters them to declared fields. Only the former can 500, and only driving the real function catches the next keyword added to init_params.
  • Determinism handled the same way as the existing suite — GAIA_MEMORY_DISABLED forced on so MemoryMixin's self-disable can't make the surface differ between a dev box and a runner, matching test_gaia_agent.py's established approach.
  • The lint entry is correctly marked optional (util/lint.py:419, util/lint.ps1:351), so a framework-only environment without the gaia-agent-gaia wheel skips rather than fails, consistent with the chat agent's entry directly below it. The dotted path also matches AGENT_MODELS["gaia"]["class_name"] exactly, which is the thing that has to stay resolvable.
  • No new dependency on an optional extra: gaia.api.sse_handler and gaia.api.agent_registry both import only core modules, so this file collects fine under a plain [dev] install as well as the [dev,api] / [api,rag] CI lanes.

The flag-liveness check could not detect the failure it was named for.
It compared init_params before and after _apply_env_overrides, but
AGENT_MODELS already declares `streaming` and `silent_mode`, so those two
never appear in the diff — GAIA_API_STREAMING could stop being read
entirely and the assertion still passed. Asserting the expected key set
instead has the same blind spot for the same reason: the key is present
either way, only the value moves. Verified by simulating a dead
GAIA_API_STREAMING; both key-based forms stayed green, the value check
fails and names the flag.

Comparing values also removes a spurious failure: with GAIA_API_DEBUG and
GAIA_API_SHOW_PROMPTS set in the ambient environment, the import-time call
had already applied them, leaving the before/after diff empty.

Also widens the workflow path filter from agent_registry.py to
src/gaia/api/**, since the same test pins sse_handler.py through the
console assertion and a rename there would have skipped this suite.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Took two of the three suggestions; skipping the conftest.py lift as separate cleanup.

The flag-liveness fix needed to go further than suggested. Asserting the expected key set has the same blind spot as the original diff-based check — streaming is already a key of init_params either way, so no presence-based assertion can tell a live GAIA_API_STREAMING from a dead one. I simulated the dead flag to confirm: the suggested form still passed. It now compares values, which fails and names the flag. That also fixes the spurious-failure case you flagged.

Widened the workflow filter to src/gaia/api/** as suggested.

Skipped: the shared _isolated_registry fixture. The two sibling files wrap it in module-scoped fixtures while the new tests use it per-function, so a shared fixture is a scope decision rather than a lift — worth its own PR.

Also filed #3254: --step-through sets an env var nothing reads, and prints "Step-through mode enabled" while doing nothing. Out of scope here, and it needs a real decision rather than a patch.

🔍 Technical details

Why key presence can't work. AGENT_MODELS["gaia"]["init_params"] is {"silent_mode": True, "streaming": False}. _apply_env_overrides sets debug/show_prompts (new keys) but only flips streaming and silent_mode. So set(init_params) contains streaming unconditionally.

Simulated a dead flag by replacing the GAIA_API_STREAMING read with streaming = False:

  • original assert injected → passed
  • suggested {"debug","show_prompts","streaming"} <= set(init_params) → passed
  • value comparison → AssertionError: ... did not apply every flag: ['streaming']. Expected {...'streaming': True...}, got {...'streaming': False...}

Now asserts {"debug": True, "show_prompts": True, "streaming": True, "silent_mode": False}, covering silent_mode as well. Re-ran with GAIA_API_DEBUG=1 GAIA_API_SHOW_PROMPTS=1 in the ambient environment — passes, where the diff-based version would have failed.

On #3254 — worth knowing before anyone wires it up: step_through is not a field on GaiaAgentConfig or ChatAgentConfig, so adding it to init_params would raise TypeError on every request. test_api_construction.py from this PR catches that.

Validation. hub/agents/gaia/python/tests/ tests/unit/api/ tests/test_api.py → 335 passed. Lint: Black, Flake8, Bandit, imports all pass. Two pre-existing failures unrelated to this branch — 9 Pylint os.killpg/os.geteuid false positives (Windows-only, in src/gaia/daemon/** and src/gaia/installer/**), and an isort complaint in tests/integration/test_email_corpus_alignment.py, which is byte-identical to main and fails there too.

Branch merges cleanly against main (verified with git merge-tree --write-tree) despite tests/test_api.py and util/lint.py having moved on both sides, so no rebase needed.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Skill audit

Skill Verdict Claimed tier Cleared tiers Findings Rules
.claude/skills/agent-hub-release ✅ ALLOW experimental experimental, community none —
.claude/skills/analyzing-claude-sessions ✅ ALLOW experimental experimental, community none —
.claude/skills/driving-the-tui ✅ ALLOW experimental experimental, community none —
hub/agents/email/npm ✅ ALLOW experimental experimental, community 2 medium, 1 info code.suppression, supply.undeclared_dependency
hub/agents/gaia/npm ✅ ALLOW experimental experimental, community none —

✅ All audited skills cleared the tier they claim.

Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the skill-audit-reports artifact from this run. Offending source text is withheld from CI everywhere — reproduce it locally with gaia skill audit <dir> --show-snippets.

# Conflicts:
#	.github/workflows/test_gaia_agent.yml
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Conflicts cleared — this had been stuck for three weeks and the workflow half of it is now redundant, but the tests still earn the merge.

While this sat, main broadened the test_gaia_agent.yml trigger to src/gaia/**, which already covers the src/gaia/api/** path this PR was adding. I kept main's broader glob and folded this PR's rationale into the comment there, so the reasoning survives without duplicating the path. The three test files — the API-construction pin, the SSE confirmation gate, and test_api.py — are untouched by main and are the real content here.

🔍 Technical details

Merged origin/main into test/pin-flagship-api-construction (merge commit 173b4676, no rebase, no force-push). One conflict, in .github/workflows/test_gaia_agent.yml:

Resolution keeps main's src/gaia/** and merges this PR's rationale into main's comment block. src/gaia/** strictly subsumes src/gaia/api/**, so the trigger coverage this PR wanted is intact.

Tests run on the merge result, all passing:

python -m pytest tests/unit/api/test_sse_confirmation_gate.py \
                 hub/agents/gaia/python/tests/test_api_construction.py -q   # 48 passed
python -m pytest tests/test_api.py -q                                       # 80 passed

kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 24, 2026
amd#4120)

Five open PRs (amd#4096, amd#4108, amd#3937, amd#3122, amd#3072) are showing a red
agent-eval lane for a scorecard that was never produced. The Anthropic
account is over its weekly spend cap, and the rejection text changed to
a wording the preflight classifier does not recognise, so instead of
"quota exhausted, this says nothing about your PR" the job dies in ~37
seconds with "could not be classified" and looks like a measured quality
regression. After this change the same outage is named as a quota outage
and points at billing rather than at the PR or the repository secrets.

The pattern matches on `weekly limit`, not on the reset date the message
quotes — that date moves every reset.

## Test plan

- [ ] `python -m pytest tests/unit/test_classify_claude_probe.py -q` —
30 passed
- [ ] `test_real_weekly_limit_rejection_is_a_quota_problem` feeds the
verbatim text from run 35681533582 (job 106629918099), BOM and U+00B7
included, and asserts `quota`; it fails on `main`
- [ ] `test_the_weekly_limit_pattern_does_not_depend_on_the_reset_date`
pins that a different reset date still classifies
- [ ] `python util/lint.py --black --isort --flake8` passes
- [ ] The classifier stays pure ASCII
(`test_the_classifier_module_is_pure_ascii`), which the PowerShell eval
step depends on

Co-authored-by: Kalin Ovtcharov <[email protected]>
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 1e60557 Sep 25, 2026
38 of 39 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the test/pin-flagship-api-construction branch September 25, 2026 17:45
github-merge-queue Bot pushed a commit that referenced this pull request Sep 28, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants