Skip to content

feat(tui): name the running agent, fix /memory on a hub install, add /agents - #3987

Merged
itomek merged 2 commits into
mainfrom
tui/agent-identity-memory-and-agents
Sep 18, 2026
Merged

itomek merged 2 commits into
mainfrom
tui/agent-identity-memory-and-agents

Conversation

@itomek

@itomek itomek commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

On any machine that followed the documented install path — the installer from amd-gaia.ai, then the gaia init the installer tells you to run — /memory answered This agent does not support /memory. while the palette, /help and the docs all advertised it. gaia init hub-installs the flagship, which moves it to the daemon transport, and the memory dump only ever existed over stdio. It works on both install shapes now. The chat also never said which agent was answering (the flagship's name is literally "GAIA", so it was suppressed as a duplicate of the product word) — the header names it, with the id --agent actually takes. And /agents lists the agents installed on the machine and switches to one without leaving the TUI.

Closes #3978 · Closes #3979 · Closes #3980

Proof, on a real machine

t-nx-strx-halo (Ryzen AI MAX+ 395, Ubuntu 24.04, Go 1.26.3, Lemonade 11.0.0), driven through the TUI's loopback control API against a genuinely hub-installed flagship on the daemon transport — the exact broken state — in an isolated $HOME so nothing of the real install was touched.

The sentinel that decides the transport (this is the broken configuration)
{"id":"gaia","version":"0.2.0","language":"python","artifact_kind":"binary","executable":"gaia-agent",
 "path":"/tmp/gaia-drive/home/.gaia/agents/gaia"}

"artifact_kind": "binary" is what flips the flagship off its seeded TransportSubprocess (catalog.go:512). Readiness gate, all four rows green, agent running as a daemon-supervised sidecar:

  [ok]  Background service  running (pid 148054) · host API v1.1
  [ok]  GAIA agent          0.2.0 · running (pid 148112)
  [ok]  Lemonade            Lemonade 11.0.0
  [ok]  Language model      Gemma-4-E4B-it-GGUF · downloaded, not loaded yet

/memory — three facts planted in the store, retrieved through the new route. Before this change this frame read This agent does not support /memory.

 GAIA  │ agent gaia v0.2.0
─────────────────────────────────────────────────────────────────────────────
 MEMORY                                                     3 of 3 entries
  fact 2 · preference 1
  project 2 · global 1
  0 entities · avg confidence 0.82

 FACT                                                                      2
  gaia-tui reaches a hub-installed flagship over the daemon transport
  project · confidence 0.75 · 2026-09-17 19:13
  The Strix Halo box serves Lemonade 11.0.0 on port 13305
  project · confidence 0.80 · 2026-09-17 19:13

 PREFERENCE                                                                1
  Tomasz reviews PRs by reading the evidence block first
  confidence 0.90 · 2026-09-17 19:13

The route itself, against a live sidecar — 200 in 43 ms:

$ curl -s -w "\nHTTP %{http_code} in %{time_total}s\n" http://127.0.0.1:8823/v1/gaia/memory
{"available":true,"stats":{"total_knowledge":2,...},"shown":2,"total":2,"items":[...]}
HTTP 200 in 0.040923s

$ curl -s http://127.0.0.1:8823/v1/gaia/version
{"apiVersion":"2.13","version":"0.2.0","agent":"gaia"}

The header and footer now name the agent (was GAIA │ Gemma-4-E4B-it-GGUF — no agent segment at all):

 GAIA  │ agent gaia v0.2.0
  ● agent gaia v0.2.0 connected          ↑↓/wheel scroll · Ctrl+T select text · Ctrl+C quit

/agents, and a switch that can be backed out of:

  Installed agents
  › gaia       GAIA             v0.2.0   running
    email      Email            v0.6.0   stopped
  ↑/↓ choose · enter switch · r refresh · esc close

Selecting email re-runs the readiness gate for it (view=preflight, agent=email); Esc returns to the live gaia session rather than quitting the program — {'view': 'chat', 'agent': 'gaia', 'overlay': None} — with the outcome visible in the transcript:

  Already running gaia.
  Switch cancelled — staying on gaia.
Two bugs this evidence caught that tests did not

Both were found by driving the real binary, and both now have regression tests:

  1. The /agents panel was never taken off screen after a selection. agents.Model emits SelectedMsg, never ClosedMsg, and only ClosedMsg cleared agentsPanel — so the four non-switching outcomes wrote their status line behind the panel. The flagship sorts first with selected at 0, so the single most likely first interaction — opening /agents and pressing Enter — read as a dead key.
  2. A used panel went deaf. Selecting cancelled the panel's own context, and its Update treated a cancelled context as death, so a panel the host re-showed after an abandoned switch swallowed every key including Esc.

A p-at-the-switch-gate bug (re-launching the outgoing agent with a transcript claiming it switched) came out of an adversarial review pass and was reproduced with a compiled Go test before being fixed.

Test plan

  • go build ./... && go vet ./... clean (Go 1.26.3, Linux)
  • go test ./... -count=1 green — 22 packages, 0 failures (-skip TestCtrlVReadsTheClipboard, which reads the machine's real clipboard)
  • pytest hub/agents/gaia/python/tests — 339 passed, including 6 new tests for GET /v1/gaia/memory
  • pytest tests/unit — 43 pre-existing failures, byte-identical to an unmodified origin/main baseline run on the same box; comm of the two failure lists shows zero unique to this branch, and +6 passing
  • python util/lint.py --black --isort clean · util/check_doc_links.py clean · bash -n installer/scripts/install.sh clean
  • Real-machine drive of /memory, /agents, agent switch, switch cancel, / palette and /help — output above
What is deliberately not in here

/model has the same gap and is not fixed here — #3985. run_model_command exists only in gaia_agent/stdio.py; the sidecar's HTTP surface has no equivalent, so on a hub-installed flagship /model is still answered by the LLM as prose. It is left advertised rather than half-gated: hiding it would trade a wrong answer for a missing feature on exactly the machines #3978 is about, and the real fix is a sidecar route. Verified by reading the code and independently by a reviewer.

Two deviations from the issue text, both deliberate:

#1173 / #1174 / #1175 triaged and closed as superseded — they describe the browse/detail/lifecycle screen #3120 removed by design, not this.

Docs updated together, per the bundled-docs rule: docs/guides/terminal-hub.mdx (the "nothing to browse and nothing to pick" warning was no longer true), docs/guides/memory.mdx, docs/guides/mcp/tui.mdx, and the hub package's README/SPEC/SKILL/CHANGELOG for contract 2.13.

…/agents

`/memory` printed "This agent does not support /memory." on any machine that
followed the documented install path — the installer, then the `gaia init` the
installer tells you to run. `gaia init` hub-installs the flagship, which flips it
from the subprocess transport to the daemon transport, and the memory dump was
only ever reachable over stdio. The palette, /help and the docs all advertised it
anyway. The sidecar now serves `GET /v1/gaia/memory` (contract 2.13) and
*SSEClient implements MemoryProvider against it, so both install shapes expose
the same command set.

Capability is negotiated, not assumed. Once both transports implement
MemoryProvider a type assertion on the client stops discriminating anything, so
the palette and /help gate on a new client.CapabilityReporter tri-state instead:
supported / unsupported / not-yet-known. Unknown shows the command — hiding one
we have not finished asking about is worse than a refusal that explains itself —
and a probe that never heard back stays unknown rather than being cached as
"this agent is too old", which would tell the user to reinstall a current agent.

The chat also never said which agent was answering. The flagship's display name
is literally "GAIA", so both sites that would print it suppressed it as a
duplicate of the product word, leaving the header naming the model but not the
agent. It now reads `GAIA │ agent gaia v0.2.0 │ <model>`, carrying the stable id
because that is what `--agent` takes, and giving way before the model chip on a
narrow terminal.

And `/agents` lists every installed agent in chat — id, name, version, running
state — and switches to one without leaving the TUI. Switching is in place: the
client is swapped, the per-agent readiness gate re-runs, and the transcript stays
on screen with a divider saying plainly that the new agent cannot see the
conversation above it. Backing out of that gate returns to the session you were
already in instead of quitting the program. This does not restore the hub browser
#3120 deleted: no browsing, no installing, no discovery of what is not installed.

`/model` has the same daemon-transport gap as `/memory` and is tracked separately
in #3985 — the sidecar has no equivalent of stdio's `run_model_command`, so it is
still answered by the LLM on a hub install.

Closes #3978
Closes #3979
Closes #3980
@github-actions github-actions Bot added documentation Documentation changes installer Installer changes tui Go terminal UI (gaia-tui) labels Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Skill audit

Skill Verdict Claimed tier Cleared tiers Findings Rules
hub/agents/gaia/npm ✅ ALLOW experimental experimental 1 high body.injection.credential_request

✅ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Approve with suggestions

This fixes /memory answering "this agent does not support /memory" on the machines that followed the documented install path, names which agent is actually answering in the chat header, and adds an in-chat /agents list-and-switch. The failure modes are handled the way this project asks for: an out-of-date sidecar gets a refusal that names the version floor and the fix, never an empty memory view that reads as "you have nothing stored", and a probe that never got an answer is kept distinct from a peer that answered and is old.

Nothing blocking. One thing worth a second look: the refusal shown when a transport genuinely cannot do /memory blames "the daemon transport" — which, after this PR, is the transport that does support it. Only a mock/test client can reach that line, so it's a developer-facing inaccuracy rather than a user-facing one, but it points the reader at the wrong thing. Four smaller suggestions follow: the new memory route builds its throwaway agent on the event loop instead of in a worker thread, the agents panel treats Ctrl+C as "close" where every other panel treats it as "quit", the startup capability probe runs with no deadline, and the switch path appends into the live chat's own message slice.

Real-world evidence

The CI evidence harness failed before producing anything — evidence-bundle.md says so in as many words, so no surface was exercised on this lane. I ran the Go side myself in this checkout instead:

$ go build ./...            # clean
$ go vet ./...              # clean (exit 0)
$ go test ./internal/ui/... ./internal/client/... ./test/... -count=1
ok  github.com/amd/gaia/tui/internal/ui/agents      0.004s
ok  github.com/amd/gaia/tui/internal/ui/chat        0.662s
ok  github.com/amd/gaia/tui/internal/ui/components  1.156s
ok  github.com/amd/gaia/tui/internal/ui/root        0.030s
ok  github.com/amd/gaia/tui/internal/client         5.982s
ok  github.com/amd/gaia/tui/test                    206.883s

(go1.26.3, Linux; every other package in those trees also passed.) The Python tests could not run here — no pytest in this environment — so hub/agents/gaia/python/tests/test_server_memory.py rests on the author's reported run.

The PR description carries on-machine evidence matched to the changed surfaces: the /memory frame rendering planted facts against a genuinely hub-installed flagship on the daemon transport, curl against /v1/gaia/memory returning 200, the /agents panel, and a cancelled switch landing back on the live session. That is the one thing static review cannot establish — that the fix works in the exact broken configuration — and it supports the verdict.

🔍 Technical details

Issues found

🟢 The unsupported-transport refusal names the wrong transport (tui/internal/ui/chat/memoryview.go:56)

This branch only fires when the client is not a MemoryProvider — which, as the comment directly above it says, now excludes both real transports. Blaming "(daemon transport)" tells a developer on --mock-agent to go debug the one path that is fine.

			Content: "/memory is not available on this client — it has no memory route at all. " +
				"Run `gaia tui status` to see how this agent is connected.",

🟢 The memory route builds its agent on the event loop (hub/agents/gaia/python/gaia_agent/server.py:519)

build_memory_dump is correctly off-loaded, but build_query_agent() — tool registration and skill loading for a 70+ tool agent — runs inline in the async handler, stalling every concurrent run's SSE heartbeat while it does. /query has the same shape today, so this is consistency rather than a new defect, but the new route is the cheap one to fix:

        agent = await asyncio.to_thread(build_query_agent)

🟢 Ctrl+C closes the agents panel instead of quitting (tui/internal/ui/agents/model.go:181)

providers.Model treats ctrl+c as tea.Quit (internal/ui/providers/model.go:188), and the status bar advertises "Ctrl+C quit" on every frame. With /agents open the same key silently means Esc, so quitting takes two presses. Either match providers, or drop ctrl+c from this case and let it fall through.

🟢 The startup capability probe has no deadline (tui/internal/ui/chat/availability.go:40)

ProbeCapabilities(context.Background()) calls EnsureAgent, which can spawn a sidecar. The consequences of a hang are mild by design (the command stays in its "unknown, therefore shown" state), but the goroutine lives for the session. A context.WithTimeout here would bound it the way versionProbeTimeout bounds the inner round-trip.

🟢 switchAgent appends into the live chat's own slice (tui/internal/ui/root/agentswitch.go:82)

Messages() hands back m.messages directly, so append(carried, divider) can write the divider into the outgoing chat's spare capacity. It's benign today only because the chat model is not updated while the gate is up. Copying makes it independent of that invariant:

	m.pendingTranscript = append(append([]chat.Message(nil), carried...), chat.Message{

Strengths

  • The contract gate is on the right side of the call. SSEClient.FetchMemory refuses before trusting a response body, and peerContract.answered splits "the peer answered and is old" from "we never heard back" — so a 401 or a still-binding sidecar never tells the user to reinstall a current agent. CapabilityReporter's two-value return carries that distinction all the way to the palette, with "unknown" resolving to show the command, not hide it.
  • The regression test reproduces the real bug, not a convenient one. tui/test/memory_capability_regression_test.go writes a genuine .installed sentinel with artifact_kind: binary and goes through catalog + client.ForAgent, explicitly because SetMockBinary never flips the transport — that is exactly the hidden-state trap CLAUDE.md's testing section is about.
  • Documentation moved with the contract. API_VERSION, SPEC, SKILL, CHANGELOG and the two guides were updated together, the npm test now derives the expected version from server.py instead of restating it, and the Python test asserts a >= floor rather than a literal — both drift-proof rather than drift-detecting-once.
  • The switch path is genuinely reversible. The outgoing client is not touched until the new one builds cleanly, cancelling at the gate returns to the live session instead of quitting, and a failed switch reports on the session it failed to leave.

… a refusal

Five points from the PR review, none of which changed behaviour a user relies
on:

The refusal shown when a session genuinely cannot fetch memory blamed "the
daemon transport" — which, after this change, is the transport that serves it.
It now names the session's connection rather than pointing the reader at the
wrong thing.

`GET /v1/gaia/memory` built its throwaway agent inline in the async handler, so
registering 70+ tools and loading skills stalled every concurrent run's SSE
heartbeat. It moves to a worker thread, like the dump itself already did.

The startup capability probe ran on `context.Background()`, and it can spawn a
sidecar — a wedged daemon left the goroutine alive for the whole session. It is
bounded now; timing out leaves the capability unknown, which shows the command
rather than hiding it.

Ctrl+C closed the `/agents` panel where every other panel — and the status bar's
own "Ctrl+C quit" — means quit, so leaving took two presses. It quits.

`switchAgent` appended the divider into the slice `Messages()` hands back, which
is the live chat's own; it copies first, so correctness no longer rests on the
chat model not being updated while the gate is up.
@itomek

itomek commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

All five suggestions applied in 23aba2c — thanks, they were all correct.

The refusal blaming "the daemon transport" was the sharpest catch: that string came verbatim from #3978's acceptance criteria, written when the daemon transport was exactly the one that couldn't serve memory. This PR makes it the one that can, so the text aged out the moment it landed. It now names the session's connection instead.

🔍 The other four
  • server.py — build_query_agent() moved to asyncio.to_thread, so registering the tool surface no longer runs on the event loop alongside live SSE heartbeats.
  • chat/availability.go — the startup probe is bounded by a 60s capabilityProbeTimeout (generous next to the 8s round-trip inside it, because a first probe may spawn the sidecar). Timing out leaves the capability unknown, which shows the command rather than hiding it — the same tri-state rule as everywhere else.
  • agents/model.go — ctrl+c now returns tea.Quit, matching providers.Model and the status bar's own "Ctrl+C quit"; esc keeps closing the panel.
  • root/agentswitch.go — the divider is appended to a copy, so it no longer depends on the chat model not being updated while the gate is up.

Re-verified after the change: go build/go vet clean, full Go suite green (22 packages, -skip TestCtrlVReadsTheClipboard), pytest hub/agents/gaia/python/tests 339 passed, util/lint.py --black --isort clean — Go 1.26.3 on Linux.

On the evidence stage: noted that the CI harness failed before producing anything. The on-machine evidence in the PR description was gathered by hand against a genuinely hub-installed daemon-transport flagship, not from that lane.

@itomek
itomek added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit d14ea1e Sep 18, 2026
80 of 82 checks passed
@itomek
itomek deleted the tui/agent-identity-memory-and-agents branch September 18, 2026 03:26
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Sep 18, 2026
…amd#3988)

`/memory` is currently offered on the `email` agent and then 404s — the
exact advertised-then-refused defect amd#3978 removed, reintroduced on a
different agent by amd#3987's own fix. This scopes the capability to the
agent that actually has the route.

Found by an adversarial review pass whose report arrived after amd#3987
merged.

## Why it slipped through

The gate asked one question: *is the peer's contract ≥ 2.13?* But every
sidecar numbers its own contract independently, so the same number means
different things across them — `email` is already at **2.14** for
unrelated reasons and has no memory route at all.

Verified on a live machine, not just read:

```
$ grep "email sidecar contract" ~/.gaia/host/daemon.log | tail -1
email sidecar contract: apiVersion=2.14 agentVersion=0.6.0

$ grep -c "memory" hub/agents/email/python/gaia_agent_email/server.py   # routes
0
```

So `Supports(CapabilityMemory)` returned `(true, true)` for `email`,
`/memory` appeared in its palette and `/help`, and `FetchMemory` sailed
through the contract gate to GET a route that does not exist.

Version answers *"is this build new enough"*, never *"does this agent
have the route"* — both have to hold. The gate now pairs the floor with
the agent that owns the memory store, the same way `/model` is already
scoped in `modelcmd.go`. Asking for memory on an agent that keeps none
now says exactly that, instead of telling the user their perfectly
current agent is out of date.

<details>
<summary>🔍 Why no test caught it, and three smaller repairs</summary>

**The test suite was aimed at the wrong agent.** `fakeRelay.client()`
builds an `SSEClient` named `email` (`sse_test.go`), so *every* memory
test was exercising an agent with no memory route and passing anyway,
because the gate never looked at the id. Those tests now use the
flagship id via a new `clientFor(t, id)`, and the `email` case is pinned
by a test that fails against the shipped gate.

- **`Supports` claimed to know about capabilities it had never heard
of.** The `default:` branch returned `(false, true)` — a confident
"unsupported" — so the next capability added would be hidden by
whichever transport was not taught about it, with nothing on screen
saying why. That is precisely what the tri-state exists to prevent.
Unknown is the honest answer.
- **`AgentVersion` decoded only `version`.** That is the flagship's
spelling; `email`'s `/v1/email/version` and *both* agents' top-level
`/version` say `agentVersion`, so the release version was permanently
blank for `email` and amd#3979's live-refinement never fired there. It
accepts both spellings now, preferring `version`.
- **The agents panel matched a late load result by comparing interface
values**, which panics at runtime if the dynamic type is uncomparable (a
`HubAgentLister` passed by value with a slice or map field). A
generation counter does the same job with no such edge.

Also folded in: a `gofmt` misalignment in `chat/model.go` that shipped
in amd#3987, and a test pinning the `/help` Commands block at exactly two
lines — `renderCommandsSection` skips the continuation *by position*, so
a third line would silently leak into every filtered render.
</details>

## Test plan

- [x] **Mutation-verified** — reverting the gate to the shipped
version-only form turns the new test red, and restoring it turns it
green:
      ```
      === with the fix reverted ===
      --- FAIL: TestSupportsMemoryIsScopedToTheAgentThatHasTheRoute
capability_test.go:254: an agent with no memory route must not report
the
          memory capability, whatever its contract number
      === restored ===
      ok  	github.com/amd/gaia/tui/internal/client	0.007s
      ```
- [x] `go build ./...`, `go vet ./...`, `gofmt -l ./internal` all clean
(Go 1.26.3, Linux)
- [x] `go test ./... -count=1` green — 22 packages, 0 failures (`-skip
TestCtrlVReadsTheClipboard`, which reads the machine's real clipboard)
- [x] New regression tests: `email` refused despite 2.14; the refusal is
not an `ErrMemoryContractTooOld`; an unknown capability reports unknown
on both transports; `AgentVersion` accepts both wire spellings; an
abandoned load cannot overwrite the current list

No Python or docs changes — the sidecar route and its contract are
unchanged.
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Sep 19, 2026
Main's allowlist fixes (amd#3593) keep refusing under this branch's ask-first
model: each guard it added is tagged as an outright refusal, so none of
them turns into a yes/no prompt. The /agents switch (amd#3987) and the
conversation-clear test (amd#3650) now use the full-access names, and a
saved-default notice is shown once rather than again on every switch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes installer Installer changes tui Go terminal UI (gaia-tui)

Projects

None yet

1 participant