Repository navigation
feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen - #5512
kovtcharov wants to merge 11 commits into
Conversation
…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.
…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.
|
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:
🔍 Technical details
|
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.
…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:  After Undo:  </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.
|
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 Review findings:
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
|
# 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
|
🟡 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
|
…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.  - 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]>
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.
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.gaia initinstall the published agent, so without a new binary every fresh install shows the "can't write greetings yet" message on its first screen.memory,personalityandcontext_retentionon 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.pycd src/gaia/apps/webui && npx vitest run src/components/__tests__/NewChat.test.tsx src/services/__tests__/api.greeting.test.tsgaia chat --uion a set-up PC: the robot shows the loading stage, then a greeting streams in; New chat again keeps the same greetinggaia-agent --serve --port 8199, thencurl -N -X POST http://127.0.0.1:8199/v1/gaia/greeting -H 'content-type: application/json' -d '{"memory":"on"}'streamsstatus,chunkand onedone