Skip to content

fix(webui): drop AgentInfo fields no backend endpoint sends - #3846

Merged
itomek merged 4 commits into
mainfrom
autofix/issue-3842
Sep 23, 2026
Merged

itomek merged 4 commits into
mainfrom
autofix/issue-3842

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

The Agent UI's AgentInfo type promised two things the backend has never sent.
compatibility drove a green/yellow/red dot on every Hub card and could disable
the Install button; avatar_url was a remote agent image. Neither key is emitted
by GET /api/agents or GET /api/agents/catalog, so the dot never appeared for
any 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 AgentInfo field against the real backend
emitters, 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/ -x passes — 12128 passed locally, including the new tests/unit/test_webui_agent_info_contract.py
  • python util/lint.py --all passes
  • cd src/gaia/apps/webui && npx tsc --noEmit clean, npx vitest run green (322/322 locally)
  • Re-add avatar_url?: string; to AgentInfo and confirm the contract test fails with a message naming the field
  • Open the Agent Hub in the running app (gaia chat --ui) and confirm Installed and Available cards render unchanged — badges, version, security tier, install/update buttons all intact and clickable

⚠️ Needs manual validation — the automated checks confirm no Python or
TypeScript regression, but can't render the Agent Hub. A maintainer should
build the webui, run gaia chat --ui, and confirm the Hub cards and install
flow look and behave exactly as before removing the dot.

🔍 Technical details

Root cause. src/gaia/apps/webui/src/types/index.ts declared
compatibility?: AgentCompatibility and avatar_url?: string. Neither appears in
gaia.hub.catalog.merge_with_registry, gaia.ui.models.AgentInfo, or
gaia.ui.routers.hub. Because both were read defensively (agent.compatibility && …, ?? 'compatible'), compatLevel() always returned compatible and
incompatible was always false — removal is a behavioural no-op.

Removed: the two type fields and the AgentCompatibility interface;
compatLevel/compatLabel and the compatibility line in mergeCatalogStatus
(utils/agentHub.ts); the dot <span> plus the disabled=/title= branch on the
install button (components/AgentHubCard.tsx); the four .agent-compat-* rules
(AgentHub.css); and the now-unreachable compatLevel cases and mock fields in
agentHub.test.ts / HubPage.test.tsx.

The durable check — tests/unit/test_webui_agent_info_contract.py. Parses the
AgentInfo interface body by brace depth (so inline object keys like
requirements?: { platforms?: string[] } don't count as fields), then asserts every
field against set(gaia.ui.models.AgentInfo.model_fields) unioned with the keys of
a payload produced by actually calling merge_with_registry over an index entry
that declares every optional key. version is the single allowlisted
client-derived field, cross-checked so a stale allowlist entry can't mask a real
mismatch. Verified negatively: re-adding avatar_url fails two of the three tests
by name.

Doc sync. src/gaia/hub/compatibility.py's module docstring asserted the
catalog endpoint consults check_compatibility — it never has. Corrected to name
the real consumers (installer.install, the onboarding preflight) and to state
that the catalog reports no per-agent verdict.

`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
@kovtcharov-amd
kovtcharov-amd marked this pull request as ready for review September 23, 2026 18:04
@kovtcharov-amd
kovtcharov-amd self-requested a review as a code owner September 23, 2026 18:04
@github-actions github-actions Bot added tests Test changes electron Electron app changes labels Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve

The removal is correct and the contract test is a real improvement. Both compatibility and avatar_url were always undefined at runtime — compatLevel defaulted to 'compatible' and the dot never rendered — so this is a behavioral no-op for every user. The new test catches the next declared-but-never-sent field at CI time instead of at runtime, and the negative verification (re-adding avatar_url breaks two tests by name) is convincing.

Two small nits on the contract test parser, neither blocking:

🟢 Inline brace counting — depth += line.count("{") - line.count("}") runs on the full line including any inline TypeScript comment. A field declaration like id: string; // uses {namespace} would offset the depth counter. No current field has this, but it's a silent trap for whoever adds one.

🟢 Indentation regex — r"^\s{4}(\w+)\??\s*:" requires exactly 4 leading whitespace chars. The downstream assert fields catches a complete zero-match, but partial drift (e.g. a 2-space-indented field added later) would silently escape the guard. A note in the pattern or a stricter matcher would make this more obvious.

🔍 Technical details

_FIELD_DECL regex in tests/unit/test_webui_agent_info_contract.py:33:

_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("}")

_catalog_payload_keys() entry coverage looks correct: merge_with_registry adds status, requires_trust, installed_version programmatically regardless of the input dict, and the PR-added assertion that requires_trust appears via _requires_trust(security_tier) at catalog.py:470 confirms this. All other TypeScript fields are backed by BackendAgentInfo.model_fields or the entry dict.

Docstring in compatibility.py is accurate now: check_compatibility is called from installer.install and routers.onboarding, not from the catalog endpoint.

@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve

Two 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 evidence

Captured by the automated evidence stage (ubuntu-latest, no Lemonade/GPU), and I re-ran the frontend half myself — tsc --noEmit exits 0 and both changed vitest suites pass 20/20.

A live gaia.ui.server confirms the central claim — neither field is on the wire:

$ 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: False

The 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 passed

Adjacent Hub routes were spot-checked and behave as expected (catalog with include_deprecated, install-status, per-agent lookup, the header-gated disk route, and gaia hub list).

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 gaia chat --ui. That's the right gap to close before merge, and given the removed code was provably unreachable, it's a confirmation rather than a risk.

🔍 Technical details

Verification I ran

  • npx tsc --noEmit -p tsconfig.json → exit 0.
  • npx vitest run src/utils/__tests__/agentHub.test.ts src/components/__tests__/HubPage.test.tsx → 2 files, 20 tests passed.
  • grep -rn "AgentCompatibility|avatar_url|agent-compat|compatLevel|compatLabel" across *.ts,*.tsx,*.css,*.py,*.mdx → only the new test file. No dangling references.
  • Confirmed merge_with_registry (src/gaia/hub/catalog.py:457) builds an explicit dict rather than spreading the index entry, so _catalog_payload_keys() in the new test reflects the real emitter and can't be fooled by the hand-built entry. The registry-only branch (catalog.py:490) emits a strict subset, so catalog-branch coverage is a superset.
  • Confirmed src/gaia/ui/routers/hub.py:113 returns unified.to_dict() with no post-processing — no third emitter the test would miss.
  • Confirmed the reworded src/gaia/hub/compatibility.py docstring: check_compatibility is imported by src/gaia/hub/installer.py:56 and src/gaia/ui/routers/onboarding.py:36, and by nothing in the catalog path. The docstring is accurate.
  • AlertTriangle and every other lucide import in AgentHubCard.tsx still has a use after the deletion.

Issues

🟢 Contract guard covers AgentInfo only (tests/unit/test_webui_agent_info_contract.py) — the same declared-but-never-sent shape can land on InstallStatus, SkillInfo, or any other wire type in types/index.ts. Worth generalizing the parser to take an interface name + emitter pair when the next one bites; not needed for this PR.

🟢 The TS parser assumes 4-space field indentation (_FIELD_DECL, test_webui_agent_info_contract.py:316) — a field wrapped across lines or indented differently is silently skipped, which is a false negative (test passes, dead field survives). A wholesale reformat is caught by the assert fields guard, so the blast radius is small. Fine as is; noting it so the next editor of that file knows the constraint.

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, requirements.platforms is already in the catalog payload and gaia.hub.compatibility.current_platform_key already exists, so a client-side mismatch hint on the card is a small change — and the new contract test will then correctly demand the backend emitter first.

Strengths

  • The test pins the contract from the real emitters, not a mock — it imports the pydantic model and runs an actual merge_with_registry. That's the distinction that makes it durable; a hand-built fixture would have drifted the first time the catalog changed.
  • The allowlist is guarded against rot. test_client_derived_fields_are_still_declared fails if version ever leaves the interface, so a stale entry can't quietly mask a real mismatch — that's the failure mode most allowlists have.
  • Failure messages tell the author what to do (emit it, drop it, or allowlist it with documentation) and cite the issues. This is the fail-loudly rule applied to a test, and it's done well.
  • The compatibility.py docstring was corrected in the same change rather than left asserting the catalog consults the checker. Easy to skip; it would have been the next reader's wrong turn.

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.
@itomek

itomek commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

The new contract test caught something real on its first run against current main — but the catch was its own fixture, not a dead field. eval_score_version is on the wire; the test's hand-built catalog entry just predated the emit that #3801 added, so it failed on a field that genuinely ships. Fixed at the root: the fixture now reads the conditionally-emitted keys out of merge_with_registry's own source, so the next optional field can't stale it the same way.

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 details

The failure (Unit Tests py3.10 / py3.12 / macOS smoke, run 35899997376):

FAILED tests/unit/test_webui_agent_info_contract.py::test_every_declared_agent_info_field_has_a_backend_emitter
AssertionError: ... declares AgentInfo field(s) that no backend endpoint sends: ['eval_score_version']

catalog.py:488 emits it conditionally (if "eval_score_version" in entry:), so the key only appears in a merged payload when the fixture entry declares it. _catalog_payload_keys() declared eval_score and eval_scorecard_url but not the third.

Fix — _CONDITIONAL_EMIT over inspect.getsource(merge_with_registry) backfills every if "<key>" in entry: key via setdefault, leaving the unconditional keys hand-declared as before. An empty match asserts with a message saying the idiom changed, so a silently-empty introspection can't reintroduce the same false positive.

Nit 1 (trailing-comment braces) — lines are now stripped of //… before both the field match and the depth += count.

Nit 2 (indentation) — ^\s{4} → ^\s+; the depth == 1 guard is what restricts matching to top-level members, so the column was doing no work. Parsed field set is unchanged.

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 main (0 behind).

@itomek itomek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@itomek
itomek added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit 6c2ed5f Sep 23, 2026
44 checks passed
@itomek
itomek deleted the autofix/issue-3842 branch September 23, 2026 19:42
itomek added a commit that referenced this pull request Sep 24, 2026
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.
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Sep 26, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

electron Electron app changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(webui): AgentInfo declares fields the backend never sends

2 participants