Skip to content

feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen - #5512

Open
kovtcharov wants to merge 11 commits into
amd:mainfrom
kovtcharov:claude/agent-greeting
Open

kovtcharov wants to merge 11 commits into
amd:mainfrom
kovtcharov:claude/agent-greeting

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

A new chat in the Agent UI opened on a canned "Good morning. What should we work on?", so nothing proved the agent worked until the user's first question stalled on a cold model. Now the GAIA agent writes the first message itself. It follows up on the last conversation when memory holds one ("the CSV importer European date bug is still open — want to pick it up?"); otherwise it's a short welcome. Writing it runs the first turn's real path: it loads the model and caches the 20K-token prompt, so a greeting that arrives is a health check and the first question answers quickly. While that happens, the robot and the real stage ("Loading Qwen3.6-35B-A3B on your GPU… 12s") sit where the greeting goes. A failure shows its reason with Try again; there's no fallback to a static line.

  • Installed GAIA greets too. An installed GAIA runs the agent as its daemon sidecar, so the sidecar gains POST /v1/gaia/greeting (contract 2.26) and the UI relays to it. An older binary gets a plain "this agent can't write greetings yet; chat works" message. The hub agent's README, SPEC, SKILL and CHANGELOG move to 2.26 together.
  • ⚠️ Release requirement: the release that ships this must also publish a flagship agent binary at contract 2.26 or later. Setup and gaia init install the published agent, so without a new binary every fresh install shows the "can't write greetings yet" message on its first screen.
  • Timing (Strix Halo, Qwen3.6-35B-A3B): the first word arrives in about 30 s cold, which is one read of the prompt that the first question would otherwise pay. It takes 5–6 s once the prompt is cached. A wait for a model another app is using shows as its own stage.
  • Evals: the greeting adds a new prompt but doesn't change the system prompt, tools or a normal turn. Watch memory, personality and context_retention on the next RC; I didn't run them locally because other work is using this machine's Lemonade.

Test plan

  • python -m pytest tests/unit/test_ui_greeting.py tests/unit/test_ui_warmup.py tests/unit/test_warm_up.py tests/unit/test_email_sidecar_proxy.py hub/agents/gaia/python/tests/test_server_greeting.py hub/agents/gaia/python/tests/test_capability_matrix.py hub/agents/gaia/python/tests/test_openapi_artifact.py
  • cd src/gaia/apps/webui && npx vitest run src/components/__tests__/NewChat.test.tsx src/services/__tests__/api.greeting.test.ts
  • gaia chat --ui on a set-up PC: the robot shows the loading stage, then a greeting streams in; New chat again keeps the same greeting
  • Sidecar route: gaia-agent --serve --port 8199, then curl -N -X POST http://127.0.0.1:8199/v1/gaia/greeting -H 'content-type: application/json' -d '{"memory":"on"}' streams status, chunk and one done

…ing screen

A new chat opened on a canned time-of-day line, so nothing proved the agent
worked until the first question stalled on a cold model. The flagship now
writes the first message itself, following up on the last conversation when
memory holds one, and writing it loads the model and caches the prompt the
first turn sends. While that runs the empty chat shows the robot and the real
stage; a failure shows its reason with Try again, never a static line.

- Agent.greet sends the first turn's system prompt and tools with thinking
  off and a small budget, streaming; MemoryMixin adds the turn's memory
  context and the newest session summary (none when memory is off).
- The greeting runs as the process's warm-up (PrefixWarmer.run_now): it
  waits for a running chat turn, and a turn that starts meanwhile waits for
  it. The warm-up and the greeting share one flagship builder.
- POST /api/system/greeting streams status, chunk, done and error events;
  the greeting's text is never logged or kept in the warm-up status.
- The UI asks once per empty chat and keeps it until a chat is created; the
  new-chat warm-up request it replaces is gone.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes electron Electron app changes agents labels Oct 21, 2026
…act 2.19)

An installed GAIA runs the flagship as its daemon sidecar, which the Agent UI
can't build in-process, so every installed user would have seen "can't greet
yet" on every new chat. The sidecar now serves POST /v1/gaia/greeting and the
UI backend relays to it; a binary older than 2.19 gets a loud message that
names `gaia init` instead of a canned greeting.

- The route builds a one-shot agent under the chat's memory mode, leases the
  model like a user's turn (a wait shows as the model_queue stage), streams
  status, chunk, then one done or error with keepalives, and writes no
  session history.
- The relay closes the sidecar connection when the empty chat goes away, so a
  greeting stuck behind another client never holds up the user's message.
- The greeting instruction moved onto Agent so the frozen binary has it.
- README, SPEC, SKILL and CHANGELOG under hub/agents/gaia move to 2.19
  together; the OpenAPI artifact and capability matrix are regenerated.
With Gemma-4-E4B on Lemonade the greeting was the model's raw reasoning,
"<think>The user wants me to write the first message…", cut off before any
greeting. GAIA records no thinking mode for Gemma-4, so the greeting sent no
switch, the server streamed reasoning_content, the provider wrapped it in
<think> tags, and the 96-token budget ran out inside it.

- The greeting now always asks a local model for thinking off; a template
  without the switch ignores it.
- Reasoning is stripped from the stream and the final text, including a block
  cut off mid-thought and tags split across chunks. A reply that is all
  reasoning is an error with Try again, never shown.
- The budget is 512 tokens: a model stops after its two sentences anyway, and
  one that reasons regardless still has room to answer.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The agent-written greeting is well built. It runs the real first-turn path, fails with a reason and Try again instead of falling back to a canned line, keeps memory text out of logs and the warm-up status, and the sidecar contract bump to 2.19 is consistent across README, SPEC, SKILL, CHANGELOG and OpenAPI. Two things to fix before merge:

  • 🟡 About ten unrelated NewChat tests were deleted. The rewrite of NewChat.test.tsx removed coverage for features this PR doesn't touch and that nothing else tests: task cards, the working-folder chip, refocusing on New chat, text handed over from setup, and the "suggestions unavailable" retry and auto-refetch. Please restore them alongside the new greeting tests.
  • 🟡 No screenshot of the new screen. This changes what every new chat in the Agent UI looks like (robot loading stage, streamed greeting, error with Try again), but the PR shows no Playwright before→after screenshots. The test plan's gaia chat --ui item is still unchecked. Please embed screenshots of the loading and greeting states.
  • 🟢 Every new chat now sends a cloud request. The warm-up never sent paid requests, but the greeting runs on cloud models too, so each new chat on a cloud model sends a full first-turn prompt (about 20K tokens). The docs say this is deliberate. If it is, a line in the cloud-provider docs would keep it from surprising users.
🔍 Technical details
  • src/gaia/apps/webui/src/components/__tests__/NewChat.test.tsx deletes these tests: takes focus when New chat is chosen…, offers the task cards the backend picked, a complete task card starts the chat…, a card that needs a subject fills the box…, shows the working folder, says when GAIA works in its own folder, starts with text handed over from setup, says in one plain sentence why there are no suggestions…, tries the suggestions again, fetches the suggestions again on its own…. focusRequest, initialText, SuggestionsUnavailable and START_RETRY_MS are all still in NewChat.tsx, and no other test covers them. START_RETRY_MS is now imported by the test file but never used.
  • Cloud path: _greet_here in src/gaia/ui/greeting.py skips the download check for _ui_cloud_provider(model) and goes on to agent.greet. _warm_new_chat_prefix returns early for the same case.
  • Eval: Agent.greet adds a new prompt (GREETING_INSTRUCTION), but the system prompt, tools and a normal turn are unchanged. Watching memory, personality and context_retention on the next RC, as the PR says, is the right call.

On a fresh install the released GAIA agent predates the greeting route, so
the first screen said to run `gaia init` to update it. `gaia init` installs
that same released agent, so the remedy could never work. The message now
says plainly that this agent can't write greetings yet and that chat works.
kovtcharov-amd pushed a commit that referenced this pull request Oct 23, 2026
…Undo (#5553)

In the desktop app, a file the flagship agent wrote never reached the
chat's session panel. Outputs stayed on "Nothing yet", and Changes and
Undo had nothing to show. Desktop chats run in the daemon's agent
sidecar and the Agent UI relays them. The relay skipped the bookkeeping
that Outputs is built from, and the sidecar never kept copies of the
files it changed. Now a relayed turn's written and deleted files show
under the answer that changed them, in Outputs and Changes, and that
answer's Undo puts them back.

- **Outputs**: relayed turns now record their tool calls the way
in-process turns do. This works with sidecar binaries that are already
installed, for files written to an absolute path.
- **Changes and Undo**: the Agent UI passes a turn id on `/query`
(contract **2.19**, `changes_turn_id`). The sidecar copies each file
before changing it, into the same undo store the Agent UI reads, and
finishes before it reports the turn done. An older sidecar is never sent
the field. Its turns still show in Outputs, just without Changes or
Undo.
- Files the agent deletes with a shell command (for example `del
notes.txt`) still show as "untracked shell work" rather than as a
deleted file. In-process chats behave the same way, because the shell
tool doesn't copy files before running a command.
- If #5512 (contract 2.19, `/greeting`) merges first, this PR
moves to 2.20 when it's rebased.
- If #5541 (contract 2.19, grants) merges first, this PR moves to the
next contract number when it's rebased.

## Test plan
- [x] `pytest tests/unit/chat/ui/test_turn_changes_recording.py`: the
real streaming chat path relays to a stand-in sidecar that records on
its own thread, creating one file and deleting another. Both appear in
Changes and Outputs under the saved answer, and Undo restores them. A
2.18 sidecar is not sent the field.
- [x] `pytest hub/agents/gaia/python/tests/test_server_changes.py`: the
recording is finished before `final`, while the agent is still working
after its answer. It is also finished when a confirmation is refused. A
save that fails is reported before the turn ends. Bad ids, and ids sent
without a session, get a 422.
- [x] `pytest tests/unit/test_sidecar_relay_fidelity.py
tests/unit/agents/test_file_snapshots.py`: a write goes through the
sidecar handler, the translator and the relay into the turn summary.
Linking the answer can't overwrite the sidecar's own save. Finishing
twice keeps an undo made in between.
- [x] Agent UI, relay, snapshot and flagship-server suites: the same 3
failures on `main` and on this branch (two tool-bundle tests and one
tool-count test, about 7,500 tests in all). No new failures.
- [x] `python util/lint.py --black --isort`, and `python -m
gaia_agent.export_openapi --check`
- [x] Live check with an isolated profile and the flagship relayed to a
dev-mode sidecar built from this branch (Gemma 4 E4B, Full access). I
asked "Create a file notes.txt in my documents folder with the word
hello". The answer shows "Changed 1 file · Review changes · Undo this
turn". Outputs lists notes.txt as "File created", and Changes shows "1
file changed, +1 −0". Undo this turn removed the file, and Outputs then
marked it Undone.

<details>
<summary>🔍 Screenshots</summary>

After the relayed write:

![Outputs and Changes after a relayed
write](https://raw.githubusercontent.com/kovtcharov/gaia/117606655be135ce1f112477f249e13ae50b9f77/f8-relayed-write.jpg)

After Undo:

![After undoing the relayed
turn](https://raw.githubusercontent.com/kovtcharov/gaia/117606655be135ce1f112477f249e13ae50b9f77/f8-relayed-undo.jpg)
</details>
# Conflicts:
#	docs/guides/agent-ui.mdx
#	hub/agents/gaia/CAPABILITY_MATRIX.md
#	hub/agents/gaia/npm/README.md
#	hub/agents/gaia/npm/SKILL.md
#	hub/agents/gaia/npm/SPEC.md
#	hub/agents/gaia/npm/src/lifecycle.ts
#	hub/agents/gaia/python/gaia_agent/server.py
#	hub/agents/gaia/python/openapi.gaia.json
#	src/gaia/apps/webui/src/App.tsx
#	src/gaia/apps/webui/src/__tests__/App.newTask.test.tsx
#	src/gaia/apps/webui/src/__tests__/App.startupSettings.test.tsx
#	src/gaia/apps/webui/src/components/NewChat.css
#	src/gaia/apps/webui/src/components/NewChat.tsx
#	src/gaia/apps/webui/src/components/__tests__/NewChat.test.tsx
#	src/gaia/ui/email_sidecar/profiles.py
On a cloud model every new chat's greeting sent a full first-turn prompt to
the provider, but it skipped the spending limit and was never counted, so the
limit could be passed silently and the month's total understated. The
greeting now stops with the limit message once the limit is reached, before
any model call, and a sent greeting is recorded like a turn (as unknown cost
when the provider reports no token counts).

Also moves the greeting route to contract 2.26: main took 2.19-2.25 for other
/query fields while this branch was open.
…'t stay failed

The startup-race test now mocks the greeting stream the way the real one
behaves (an error event while the backend is down) and checks the greeting
arrives once it is up.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

A greeting on a cloud model got around the monthly spending limit and wasn't counted, so it could push the bill past the limit without anyone seeing it. That's fixed now: once the limit is reached, the greeting shows the limit message before it calls the model, and every greeting that is sent gets recorded. Merging main also moved the greeting to contract 2.26, because main used 2.19 through 2.25 for other /query fields.

Review findings:

  • Deleted NewChat tests: restored. The merge brought back main's task-card, folder, focus, setup-text and suggestions-retry tests, alongside the greeting tests.
  • Cloud requests: the Agent UI guide and the SDK reference now say a cloud greeting is a paid request that counts toward the limit.
  • Screenshots: still missing. Someone has to capture the loading, greeting and error states in a running UI.

When the model is slow or down, the screen fails visibly and never blocks typing. An unreachable Lemonade, a dropped stream or a stream with no final event all end in an error with Try again. The wait for a turn or a model shows as its own stage with a running seconds count. A load that hangs is limited only by the client's own timeouts (900 s for a request, the model-load timeout for a load), the same as a first message.

🔍 Technical details
  • _greet_here (src/gaia/ui/greeting.py) checks spending.limit_refusal before the model loads. After agent.greet it calls spending.record_turn. _with_prompt_usage now also returns completion_tokens.
  • New tests in tests/unit/test_ui_greeting.py: a greeting is recorded at list price, a greeting with no usage counts as an unpriced turn, a refused greeting makes no model call and loads nothing, a local model is never blocked by the limit, and a corrupt saved limit raises.
  • App.startupRace.test.tsx now mocks the greeting stream the way the real one behaves. While the backend is down it sends an error event. Once the backend is up the test checks that the greeting arrives and that no "can't say hello" message is left on screen.
  • The sidecar greeting path (an installed GAIA) has no limit check, because the UI doesn't know which model the sidecar will use.

# Conflicts:
#	src/gaia/apps/webui/src/services/api.ts
# Conflicts:
#	docs/guides/agent-ui.mdx
#	src/gaia/apps/webui/src/components/NewChat.tsx
# Conflicts:
#	src/gaia/apps/webui/src/services/api.ts
@github-actions

Copy link
Copy Markdown
Contributor

🟡 The monthly spending limit still doesn't cover greetings on an installed GAIA. The new limit check and spend recording only run when the flagship greets inside the UI process. When it runs as the daemon sidecar, which is how an installed GAIA runs, a cloud greeting is neither refused at the limit nor counted. The PR says the UI can't know which model the sidecar will use. But the chat path already works this out for sidecar turns: it resolves the model, checks the limit, and sends that model to the sidecar. The greeting can do the same.

🔍 Technical details
  • src/gaia/ui/greeting.py _greet_in_sidecar: the body is only {"memory": ...}, so the sidecar greets on its own default model, with no limit_refusal before it and no record_turn after it.
  • _stream_chat_impl in src/gaia/ui/_chat_helpers.py runs resolve_session_model → spending.limit_refusal before it relays, then passes model_id to _dispatch_sidecar_query. warmup._new_chat_model(db, registry) already gives the greeting that same model id.
  • Smallest fix: in write_greeting, resolve the model with _new_chat_model before the sidecar branch and raise GreetingUnavailable(refusal) if the limit is reached. Then record the turn using the token counts from the done event. If the sidecar ignores the model the UI resolved, its greeting can also load a different model from the one the first turn will use. Passing model in GreetingRequest would fix that too, but it needs a contract field.

tylerbea pushed a commit to tylerbea/gaia that referenced this pull request Oct 30, 2026
…gent (amd#5541)

For the flagship agent, **Add to this reply** did nothing (the message
quietly went back into the queue) and permission prompts never offered
**Always allow**, so users had to approve the same call every time. Both
now work: a mid-reply message is handed to the running turn, and "Always
allow" is offered, listed with the chat's other grants, and revocable
from the session panel and Settings.

![Add to this reply: the running answer picked up the added instruction
(CORMORANT)](https://raw.githubusercontent.com/kovtcharov/gaia/kalin/agent-ui-test-pass-evidence/agent-ui-test-pass/add-to-reply.jpg)

- A reply that can't take a mid-turn message (email agent, an older
agent) says so when it starts and hides the button; a refused message
says it will send when the reply ends.
- "Always allow" is offered only on agents that can list and revoke it,
never for calls that need fresh consent. Before each turn the chat
revokes any agent-side grant it doesn't list, so nothing approves
unseen.

Contract note: main reached sidecar contract 2.25 while this waited, so
the grants endpoints ship as **2.26**.

## Test plan
- [x] `pytest tests/unit/chat tests/unit/test_relay_followup.py
tests/unit/test_relay_always_allow.py
tests/unit/test_relay_tool_confirmation.py
tests/unit/test_sidecar_relay_fidelity.py
tests/unit/test_stdio_permission_control.py`: 2316 passed
- [x] `npx vitest run` in `src/gaia/apps/webui`: 1526 passed
- [x] Live: asked for ten lighthouses, then **Add to this reply** "end
with the word CORMORANT"; the running answer ended with CORMORANT
- [ ] "Always allow" live needs a sidecar built at contract 2.26, which
no release has yet; it is covered by the grants tests against the real
server app
- [ ] Eval on the next RC: the `gaia_*` categories that use tool
confirmations

<details>
<summary>🔍 Technical details</summary>

- Follow-up relays to the sidecar's `/query/{run_id}/followup` (contract
2.15+). The sidecar can't report when its agent reads it, so an accepted
message is saved and reported taken at once.
- Grants: sidecar contract **2.26** adds `GET/DELETE
/v1/gaia/sessions/{id}/grants` and `always_label` on
`needs_confirmation`. A revoke the sidecar refuses is a 502 and stays
listed.
- **Contract collision:** amd#5512 (greeting) also adds a contract version;
whichever merges second bumps to the next number (server `API_VERSION`,
npm `lifecycle.ts`, profile minimums, SPEC/SKILL/CHANGELOG, openapi and
capability matrix).
- README, SPEC, SKILL, CHANGELOG, openapi and the capability matrix are
updated together.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
@kovtcharov-amd kovtcharov-amd added enhancement New feature or request agent-ui Agent UI changes labels Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-ui Agent UI changes agents documentation Documentation changes electron Electron app changes enhancement New feature or request sidecar Agent sidecar contract / harness tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants