Repository navigation
fix(webui): drop AgentInfo fields no backend endpoint sends - #3846
Conversation
`compatibility` and `avatar_url` were declared on the Agent UI's `AgentInfo` type but emitted nowhere in the backend — not by `GET /api/agents`, not by `GET /api/agents/catalog`. Both read as `undefined` forever, so the Hub card's compatibility dot never rendered and the install button's incompatible-gate never fired. Removed both, along with the `compatLevel`/`compatLabel` helpers and dot CSS that only existed to render them. Same class of dead field as #2970's version row, which shipped broken for the same reason. Nothing forced the two sides to agree, so a new contract test asserts every declared `AgentInfo` field against the real emitters — the pydantic model behind `/api/agents` and an actual `merge_with_registry` payload, not a hand-built mock. `version` stays as the one documented client-derived exception. `hub/compatibility.py`'s module docstring claimed the catalog endpoint consults the checker; it never did. Corrected so the next reader doesn't re-add the field on a false premise. Closes #3842
|
Verdict: Approve The removal is correct and the contract test is a real improvement. Both Two small nits on the contract test parser, neither blocking: 🟢 Inline brace counting — 🟢 Indentation regex — 🔍 Technical details
_FIELD_DECL = re.compile(r"^\s{4}(\w+)\??\s*:")Stripping inline comments before the brace/field check would make it robust: line_code = re.sub(r"\s*//.*$", "", line)
depth += line_code.count("{") - line_code.count("}")
Docstring in |
Verdict: ApproveTwo fields the Agent Hub's type declared were never actually sent by the backend, so the compatibility dot never rendered for anyone and the "Install disabled" gate never fired. This PR deletes both, and adds a test that checks every declared field against the real backend responses so the next dead field fails CI instead of shipping. Removing rather than implementing is the right call here, and the PR is right to flag it. The install path already refuses an incompatible package loudly, so nothing a user could see changes. Worth opening a follow-up issue for the compatibility indicator itself — the platform list the check would need is already on the wire, so rebuilding it later is cheap, but if it isn't tracked it just gets forgotten. One caveat on the new guard: it protects the agent type specifically, not the other shapes the Hub reads from the backend. Same class of bug can still land elsewhere. Real-world evidenceCaptured by the automated evidence stage ( A live $ curl -s http://127.0.0.1:4200/api/agents/catalog
HTTP 200 | offline: False | count: 5
union of agent-entry keys: ['author', 'category', 'deprecated', 'description',
'download_size_bytes', 'eval_score', 'eval_scorecard_url', 'icon', 'id',
'installed_version', 'language', 'latest_version', 'name', 'permissions',
'requirements', 'requires_trust', 'security_tier', 'source', 'status', 'type']
compatibility present: False | avatar_url present: FalseThe new test is proven non-vacuous — re-adding both fields fails it with an actionable message: $ python -m pytest tests/unit/test_webui_agent_info_contract.py -q
F.F
FAILED test_every_declared_agent_info_field_has_a_backend_emitter
AssertionError: ... declares AgentInfo field(s) that no backend endpoint sends:
['avatar_url', 'compatibility'] ...
2 failed, 1 passedAdjacent Hub routes were spot-checked and behave as expected (catalog with Not shown: the Agent Hub cards themselves — the runner can't render them, marked pending strix-halo lane. The PR's own checklist already asks a maintainer to eyeball the Hub in 🔍 Technical detailsVerification I ran
Issues🟢 Contract guard covers 🟢 The TS parser assumes 4-space field indentation ( Follow-up worth an issue, not a change here: the per-agent compatibility verdict (#1096/#1097) is now fully unimplemented. If maintainers want it back, Strengths
|
The contract test's catalog fixture hand-listed the conditionally-emitted eval keys, so #3801's eval_score_version left it stale and the test failed on a field that is genuinely on the wire. The fixture now reads those keys out of merge_with_registry's source, so a new conditional emit can't reintroduce the same false positive. Also hardens the TypeScript parser against two silent traps flagged in review: a brace inside a trailing // comment no longer offsets the interface's brace-depth counter, and field matching no longer assumes exactly four spaces of indentation.
|
The new contract test caught something real on its first run against current Both review nits on the TypeScript parser are addressed in the same commit. Follow-up for the compatibility indicator itself is filed as #4164 — the removal shouldn't quietly bury the intent from #1096/#1097. 🔍 Technical detailsThe failure (
Fix — Nit 1 (trailing-comment braces) — lines are now stripped of Nit 2 (indentation) — Verification (local, this branch): $ .venv/bin/python -m pytest tests/unit/test_webui_agent_info_contract.py -q
3 passed, 1 warning in 0.30s
# non-vacuity — bogus field WITH an inline brace comment, which would have
# corrupted the old depth counter:
# bogus_never_sent?: string; // trailing brace test {x}
$ .venv/bin/python -m pytest tests/unit/test_webui_agent_info_contract.py -q
AssertionError: ... no backend endpoint sends: ['bogus_never_sent'] ...
1 failed, 2 passed
$ git checkout -- src/gaia/apps/webui/src/types/index.ts # reverted clean
$ .venv/bin/python util/lint.py --black --isort
[SUCCESS] ALL QUALITY CHECKS PASSED!Branch also merged up to current |
itomek
left a comment
There was a problem hiding this comment.
Approving. The central claim checks out independently — no Python source emits compatibility or avatar_url anywhere, so both were always undefined, the dot's render guard was always false, and disabled={incompatible} was always false. Removal cannot change what the Hub renders, which is why the outstanding "eyeball the Hub cards" item is a confirmation rather than a risk.
The contract test is the real value here, and it earned it immediately: on its first run against current main it caught a field its own fixture had gone stale on. Fixed at the root, and both parser nits are addressed. 34/34 checks green.
Follow-up for the compatibility indicator itself is tracked in #4164 so the intent from #1096/#1097 isn't lost with the code.
Resolves the conflict with main's removal of the never-sent `compatibility` field (#3846) and tightens the version badge so it can't advertise a version the user doesn't actually have. Main deleted `compatLevel`/`compatLabel` and the compatibility dot along with the dead wire field, so this branch's imports and locals for them go too. The version badge itself keeps this branch's behaviour: it now renders on both tabs, derived from the fields the catalog really sends. The badge rule also gained a guard. An agent installed from a registry entry point or an editable dev checkout reports no installed version, and the old chain fell through to the catalog's `latest_version` — badging a card with a version that isn't on disk. Those cards now show no badge at all, while a not-yet-installed catalog card still shows what's on offer. Both the card and the details modal read the single helper, so they can't drift apart, and the modal's scorecard line says "latest" instead of "current" for an agent the reader hasn't installed.
…kend (amd#4345) The Agent UI's TypeScript API types are written by hand, and nothing checked them against what the backend actually sends. Five had already drifted: settings were missing the agent mode, system status was missing the active profile, schedules were missing their parsed config, and three fields were typed as never-null although the backend sends null. Now CI fails and names the field whenever a hand-written type and the backend disagree, and those five types are fixed. Nothing changes for users; no UI code read the missing fields yet. This is the type-generation half of amd#4246. It also covers amd#3327's "snapshot the schema" and "check the TS types agree" items, but not its route `response_model` and conformance-test items. ## Test plan - [x] `python -m pytest tests/unit/chat/ui/test_export_openapi.py tests/unit/chat/ui/test_models.py tests/unit/chat/ui/test_server.py tests/unit/test_webui_agent_info_contract.py -q`: 170 passed - [x] `python -m gaia.ui.export_openapi --check` exits 0, also from another working directory with different env - [x] `cd src/gaia/apps/webui && npx tsc --noEmit`: clean. With `main`'s `types/index.ts` restored it fails five times, naming `agent_mode`, `active_profile`, `schedule_config`, `mail_provider`, `extension` - [x] `cd src/gaia/apps/webui && npm test`: 400 passed. Deleting one line from `api.gen.ts` fails the new generation test and `node scripts/gen-api-types.mjs --check` - [x] `npm run build` succeeds - [x] black, isort, pylint clean on the new Python files - [ ] CI: the Agent UI Vitest job's new Type-check step passes <details> <summary>🔍 Technical details</summary> **The pipeline:** `python -m gaia.ui.export_openapi` writes `src/types/api.schemas.json` from `create_app(":memory:").openapi()`, then `npm run gen:api-types` writes `src/types/api.gen.ts`. Each step has a stale check: a pytest test for the JSON and a Vitest test for the TS. `src/types/apiContract.ts` then compares 18 hand-written wire types with their generated counterparts at compile time. It flags backend fields missing from TS, TS fields never sent, and kind mismatches (string/number/boolean/null/array/object). It also has a self-test so it can't pass vacuously. `tsc` runs in the PyPI build on every PR, and now in the Agent UI Vitest job too. **Why not openapi-typescript:** it has a peer dependency on `typescript@^5` and uses the TS 5 compiler API. The Agent UI is on TypeScript 7, the native port, which has no JS API, so npm refuses the install. Its 6.x line has no TS dependency but pulls a vulnerable `undici`. `[email protected]` is pinned exact and adds no new `npm audit` findings (still 6, all pre-existing). The lockfile was written with npm 11 to keep its `libc` fields. **Only the component schemas are snapshotted, not the full OpenAPI doc.** Route docstring edits don't cause regenerations, since the types don't depend on them. **AgentInfo's 14 "TS-only" fields aren't drift.** They're Hub catalog fields from `merge_with_registry`, and `tests/unit/test_webui_agent_info_contract.py` (amd#3846) already checks each one against its emitter. The contract allowlists exactly those 14. **Not covered:** camelCase view models (`Message`, `AgentStep`, `CommandOutput`), and TS types whose routes have no `response_model` (tunnel, MCP, connectors). The latter are amd#3327's remaining work. **Things to know:** - CI installs unpinned `fastapi`/`pydantic`, as the email agent's `export_openapi --check` already does. The committed snapshot matches the current latest (fastapi 0.141.1, pydantic 2.13.5), but a future release that changes schema output would need a regenerate. - A dependabot bump of `json-schema-to-typescript` or its `prettier` dependency may need `npm run gen:api-types` run on its PR. **Overlap:** - amd#4325 removes `SystemStatus.device_supported` from the backend and TS. Whichever of the two PRs merges second must rerun the two regenerate commands. The fixture edits touch separate hunks. - Other open PRs that edit pydantic models in `src/gaia/ui/` need the same regenerate after this lands. - amd#4186 and amd#4340 don't touch these files. </details> Part of amd#4246 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
The Agent UI's
AgentInfotype promised two things the backend has never sent.compatibilitydrove a green/yellow/red dot on every Hub card and could disablethe Install button;
avatar_urlwas a remote agent image. Neither key is emittedby
GET /api/agentsorGET /api/agents/catalog, so the dot never appeared forany user and the incompatible-gate never fired — the same dead-field shape that
made #2970's version row silently never render. Both are now gone, and a new
contract test checks every declared
AgentInfofield against the real backendemitters, so the next declared-but-never-sent field fails CI instead of shipping
as a quietly dead feature.
Removing rather than implementing is the deliberate call here, and worth a
second opinion: wiring per-agent compatibility into the catalog would be new
behaviour (dots appearing, Install buttons disabling on platform mismatch) rather
than a bug fix, and the install path already refuses an incompatible package
loudly. If you'd rather keep the UI and build the backend side, say so and this
becomes the groundwork for it — the contract test will then require the emitter.
Closes #3842
Test plan
python -m pytest tests/unit/ -xpasses — 12128 passed locally, including the newtests/unit/test_webui_agent_info_contract.pypython util/lint.py --allpassescd src/gaia/apps/webui && npx tsc --noEmitclean,npx vitest rungreen (322/322 locally)avatar_url?: string;toAgentInfoand confirm the contract test fails with a message naming the fieldgaia chat --ui) and confirm Installed and Available cards render unchanged — badges, version, security tier, install/update buttons all intact and clickable🔍 Technical details
Root cause.
src/gaia/apps/webui/src/types/index.tsdeclaredcompatibility?: AgentCompatibilityandavatar_url?: string. Neither appears ingaia.hub.catalog.merge_with_registry,gaia.ui.models.AgentInfo, orgaia.ui.routers.hub. Because both were read defensively (agent.compatibility && …,?? 'compatible'),compatLevel()always returnedcompatibleandincompatiblewas alwaysfalse— removal is a behavioural no-op.Removed: the two type fields and the
AgentCompatibilityinterface;compatLevel/compatLabeland thecompatibilityline inmergeCatalogStatus(
utils/agentHub.ts); the dot<span>plus thedisabled=/title=branch on theinstall button (
components/AgentHubCard.tsx); the four.agent-compat-*rules(
AgentHub.css); and the now-unreachablecompatLevelcases and mock fields inagentHub.test.ts/HubPage.test.tsx.The durable check —
tests/unit/test_webui_agent_info_contract.py. Parses theAgentInfointerface body by brace depth (so inline object keys likerequirements?: { platforms?: string[] }don't count as fields), then asserts everyfield against
set(gaia.ui.models.AgentInfo.model_fields)unioned with the keys ofa payload produced by actually calling
merge_with_registryover an index entrythat declares every optional key.
versionis the single allowlistedclient-derived field, cross-checked so a stale allowlist entry can't mask a real
mismatch. Verified negatively: re-adding
avatar_urlfails two of the three testsby name.
Doc sync.
src/gaia/hub/compatibility.py's module docstring asserted thecatalog endpoint consults
check_compatibility— it never has. Corrected to namethe real consumers (
installer.install, the onboarding preflight) and to statethat the catalog reports no per-agent verdict.