Skip to content

feat(ui): Add to this reply and Always allow work with the flagship agent - #5541

Merged
kovtcharov-amd merged 7 commits into
amd:mainfrom
kovtcharov:kalin/relay-followup-always-allow
Oct 30, 2026
Merged

kovtcharov-amd merged 7 commits into
amd:mainfrom
kovtcharov:kalin/relay-followup-always-allow

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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)

  • 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

  • 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
  • npx vitest run in src/gaia/apps/webui: 1526 passed
  • 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
🔍 Technical details
  • 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: feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen #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.

…turn

"Add to this reply" did nothing for the flagship agent: its turns run in the
daemon sidecar, the backend only knew how to hand a mid-turn message to an
in-process agent, and the 409 that followed was swallowed by the chat, which
quietly put the message back in the queue.

- A relayed turn now forwards the message to the sidecar's
  /query/{run_id}/followup (contract 2.15+). The sidecar cannot say when its
  agent reads it, so a message it accepts is saved and reported taken at once,
  and the turn's follow-up outcome lists only what it accepted.
- A relayed turn that cannot take one (email, an older agent) says so as it
  starts, and the chat hides the button for that reply.
- When the reply refuses a message, the queued row now says it can't be added
  and will send when the reply ends, instead of reverting without a word.
…rompts

Permission prompts for the flagship never offered "Always allow": its turns run
in the daemon sidecar, which holds any "always" grant in its own session, and
the chat had no way to list or revoke one there, so the relay dropped the
option. The user had to approve the same call every time.

- The sidecar (contract 2.19) lists and revokes a session's "always" answers
  at GET/DELETE /v1/gaia/sessions/{id}/grants, including answers given in a
  turn still running, and needs_confirmation now carries always_label.
- The chat offers "always" on a relayed prompt only for such a sidecar and
  never for calls that need fresh consent, relays the decision, and lists the
  sidecar's grants with its own so the session panel and Settings can revoke
  them. A revoke the sidecar did not take is a 502 and stays listed.
- Before each relayed turn the chat revokes any sidecar grant it does not list
  (one from before the Agent UI restarted), so nothing approves unseen.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes agents sidecar Agent sidecar contract / harness labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The flagship agent now does both things the Agent UI already offered other agents. Add to this reply hands a typed message to the reply that's running. Permission prompts offer Always allow, and those grants are listed and can be revoked next to the chat's own. The design fails safely: a revoke the agent can't confirm stays listed and returns an error, and before each reply the chat revokes any agent-side grant it isn't showing. I found no blocking issues.

Before merging:

  • Contract version clash. This PR and feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen #5512 both claim agent contract 2.19. Whichever merges second has to bump every place the number appears. The author already lists them.
  • Small UI gap. If you switch away from a chat while an email-agent reply is running and come back, Add to this reply shows up again. Clicking it fails cleanly with "Can't add to this reply", so it's only a misleading button, not lost input.

Real-world evidence

N/A here: no evidence bundle was produced for this run. The PR description includes a live Agent UI screenshot of Add to this reply working: the running answer picked up "end with the word CORMORANT". The author marks the live Always allow run as blocked until a sidecar at contract 2.19 ships. Tests drive it against the real sidecar app (build_app()) and the real permission handler instead. So Always allow rests on those tests and static review, and a screenshot from the next RC on the Strix Halo lane would close that gap.

🔍 Technical details

Issues

🟢 followup_unavailable isn't restored when the chat re-attaches (src/gaia/apps/webui/src/components/ChatView.tsx:696, :1946)

  • The flag lives in component state and is only set by the live event. Re-attaching skips the reset, but a remounted ChatView starts at false and the event isn't replayed.
  • So for email or a pre-2.15 sidecar, onSteer is offered again after a chat switch. The 409 → steerRefused path handles it cleanly.
  • Fix if you want it: carry the flag on the session's running-turn status, or re-emit it on attach.

🟢 Contract 2.19 collision with #5512. Whichever lands second must bump all of these together: API_VERSION in server.py, lifecycle.ts, min_grants_api_version in profiles.py, SPEC/SKILL/CHANGELOG, openapi.gaia.json, the capability matrix, and test_only_a_flagship_at_2_19_lists_its_grants.

Checked and fine

  • Reconcile semantics. grants.reconcile revokes sidecar grants the chat doesn't list before each turn, and a turn whose reconcile fails is stopped with an actionable agent_error. That matches "consent must not outlive its context". If refresh fails after an "always", the endpoint returns granted: None and the next turn revokes the grant. That's loud and logged.
  • Revoke ordering. routers/chat.py:revoke_grants revokes through the sidecar first and only then calls forget_relayed. A SidecarError becomes a 502 and the grant stays listed. A sidecar 404 counts as already gone.
  • Follow-up relay. deliver makes the HTTP send outside the global _lock, and the call is moved off the event loop with run_in_threadpool. RelayInbox's own lock orders a send against close. The sidecar's agent loop drains follow-ups before it finalizes an answer (agent.py ~11617), so "accepted = taken" holds except in the narrow race the sidecar already documents.
  • Fresh-consent tools. _FRESH_CONSENT_TOOLS in relay.py never forwards always_scope for allow_path_access, the engineering-context tools or capture_skill, and resolve_relay_confirmation refuses always when no scope was offered.

Strengths

  • The tests drive the real build_app() sidecar and the real SSEOutputHandler, so they would catch a mismatch between what is listed and what is actually honoured. They also cover two answers that share a family: revoking one keeps the other's family granted.
  • Every user-visible error names what failed and what to do ("so it is still allowed. Try again; restarting the agent also clears it.").
  • README, SPEC, SKILL, CHANGELOG, openapi and the capability matrix are all updated in the same change, as CLAUDE.md requires for hub agents.

… pylint

A re-attaching chat rebuilds the turn from its replay buffer, which carries
followup_unavailable, but a run past the 8 MB replay cap trimmed it away and
offered "Add to this reply" again. Turn-wide state frames are now kept out of
the trimmable buffer and replayed first.

The console's lazy grant-scope dict is created through the same helper as its
lazy sets, so pylint no longer flags an attribute defined outside __init__.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Fixed the lint failure and closed the remaining gap where a long-running reply could offer Add to this reply again after a chat switch. The other two red checks were infrastructure flakes, not this change.

🔍 Technical details
  • Review item, re-attach: RunManager.subscribe preloads the full replay buffer, so a remounted ChatView gets followup_unavailable from the replay and sets the flag. _trim keeps the first frame, the note and the newest frame, so after the 8 MB cap the event (usually frame 2+) was dropped. run_manager.py now holds turn-state frames (_TURN_STATE_TYPES) out of the trimmable buffer and replays them first. New test test_a_turn_that_cannot_take_followups_still_says_so_after_a_trim fails without the change.
  • Run Code Quality Checks: pylint W0201 on console.py (_session_grant_scopes assigned outside __init__). The dict is now created through the same lazy helper as the console's sets (_lazy_attribute).
  • Test GAIA CLI on Linux (Full Integration): Launchpad returned 503 Service Unavailable for ppa:lemonade-team/stable, so the step's own outage guard failed it.
  • Unit Tests (macOS): test_file_lock.py::test_the_next_waiter_takes_the_lock_within_milliseconds timing assertion. This PR doesn't touch the file lock, and the same test failed the same way on an unrelated branch (run 39696009832, kalin/awake-clock-s0ix). The new push re-runs both.
  • Local verification:
    • python util/lint.py --all: pass. MyPy is warn-only, as on main.
    • pytest tests/unit/chat -n 4: 2163 passed.
    • Relay, stdio and agents tests: 4207 passed.
    • hub/agents/gaia/python/tests with an isolated GAIA_HOME: 748 passed. The 3 failures need Playwright, which CI installs and this machine doesn't.
    • capability_matrix.py --check: up to date.
    • npm npm ci && npm run build && npm test: 151 passed.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Merge note: #5538, #5541 and #5609 all change the relay loop and the relayed question/prompt state in sse_handler.py, so whichever merges later needs a hand merge that keeps all three behaviours.

🔍 Technical details

Resolution tested live and in unit tests (125 relay/title/queue tests pass combined):

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>
Main moved the sidecar contract to 2.25 while this branch waited, so the
grants endpoints now land as contract 2.26: server API_VERSION, npm
lifecycle, the relay's grants floor, SPEC/SKILL/CHANGELOG, the SSE
contract doc, openapi and the capability matrix move together.

Relay, SSE handler and chat-helper conflicts keep both sides: main's
question tracking, internet switch, turns and context reporting, and this
branch's "always" offer and mid-turn follow-up inbox. A queued message's
"can't add to this reply" note now shows only while that reply runs, so it
no longer hides main's busy-retry wording once the reply has ended.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Merged main back in. Main had reached sidecar contract 2.25, so the grants endpoints now ship as 2.26, and every place that names the version moved together.

🔍 Technical details
  • Version 2.26 in: server API_VERSION, npm lifecycle.ts, min_grants_api_version, SPEC/SKILL/CHANGELOG, the SSE contract doc §5.3, docs/ guide and SDK page; openapi and CAPABILITY_MATRIX.md regenerated.
  • Relay loop keeps main's asked / stepped_away handling and still passes offers_always to _dispatch_one. sse_handler keeps both _relay_question_id and _relay_always_scope.
  • _dispatch_sidecar_query: grant reconcile and the follow-up inbox sit ahead of main's internet-off hold; the inbox closes in the same finally that resets relay_ignores_internet.
  • Queued-message label: the "can't add to this reply" note shows only while that reply runs; afterwards main's "Sending next." / busy-retry wording applies. New QueuedMessages.note.test.tsx pins it.
  • Three new main tests stubbed set_relay_confirmation with one argument; they now take the optional scope.
  • Local: 2797 relay/chat unit tests, 224 hub sidecar tests (grants, openapi, capability matrix), 1965 webui vitest, tsc --noEmit all pass.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Not merging yet: the flagship's own guide on the docs site still says the agent is at contract 2.25, and it doesn't list the two new grants endpoints. Everything else checks out, and the fix is two lines in one file.

  • Bump the "API version" line in the GAIA guide to 2.26.
  • Add GET and DELETE /v1/gaia/sessions/{session_id}/grants to that guide's endpoint table.
🔍 Technical details
  • docs/guides/gaia.mdx:301 reads "(API version 2.25)". Main updates that line on every contract bump (it went from 2.18 to 2.25 through fix(chat): show a relayed flagship its earlier tool calls #5806), so leaving it at 2.25 contradicts API_VERSION = "2.26" in server.py, lifecycle.ts, SPEC, SKILL and the openapi.
  • The endpoint table in the same guide (around line 262) lists /sessions/{session_id}/bypass and /internet but not the new /grants routes, which SPEC.md already lists at ≥ 2.26.

Checked and fine at db43404:

  • The merge dropped nothing from either side. An interdiff of the PR's pre-merge patch (f658edf against its base) and the post-merge patch (against f614e97) differs only in the 2.19 → 2.26 bumps, the relay_query call moving under main's try/finally (with offers_always and the follow-up inbox kept), the queued-label rewrite onto main's queuedLabel, and three main tests' set_relay_confirmation stubs taking the optional scope.
  • The "Always allow" path fails closed. The sidecar grants the parked call's own scope. The relay leaves always_scope out for fresh-consent tools, and the sidecar has no grant scope for them anyway. confirm_id is checked under _confirm_lock on both the "always" and the resolve side. Every relayed event clears the pending prompt. Before each turn reconcile revokes grants the chat doesn't list, and a failure stops the turn with agent_error.
  • Not LLM-affecting: no prompt, tool docstring, schema or registration changes.
  • CI is green and the PR is mergeable. feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen #5512 is still open, so 2.26 doesn't collide with anything yet.

The GAIA guide still said 2.25 and its endpoint table left out the two grants routes the rest of the docs already describe.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Not merging yet: the branch conflicts with main again. Main shipped the flagship agent as 0.3.3, which moved the Unreleased changelog entries under the 0.3.3 heading, so the new "contract 2.26" entry no longer merges. Everything else checks out — the guide fix is right, no doc still calls the current contract 2.25, and 2.26 is still free on main.

Next step: merge main back in and keep the 2.26 entry under [Unreleased], above [0.3.3].

🔍 Technical details
  • Conflict is in hub/agents/gaia/npm/CHANGELOG.md (from chore(release): bump the flagship agent to 0.3.3 #6122). A local git merge looks clean because .gitattributes sets CHANGELOG.md merge=union; GitHub doesn't honour that, and a union merge would also misplace the entry under the released 0.3.3 section.
  • CI was 54 pass / 12 skipped on 1cfe99c.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 30, 2026
Merged via the queue into amd:main with commit d9c5657 Oct 30, 2026
70 of 72 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/relay-followup-always-allow branch October 30, 2026 16:35
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 30, 2026
6 of 12 tasks
akshat-lakhera pushed a commit to akshat-lakhera/gaia that referenced this pull request Oct 31, 2026
## Why this matters

v0.25.4 is cut for Arabic support: the Agent UI runs right to left in
Arabic, and people can ask about Arabic, English or mixed documents in
either language (amd#6165). It also adds a local-only mode that keeps every
AI request on the PC, image indexing, and email thread reading for the
GAIA agent. Among the fixes, chats no longer get stuck on "Waiting for
the GPU", and file paths resolve to the chat's folder and the real
Documents folder. 59 commits since v0.25.3; the notes are in
`docs/releases/v0.25.4.mdx` and credit 7 outside contributors.

This is a patch carrying 8 `feat` commits, approved as v0.25.4 for the
Arabic RC.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.25.4.mdx
--tag v0.25.4` passes, and with `--tag v0.25.4-rc1`
- [x] `mintlify validate` (from `docs/`) passes
- [x] `python util/release_versions.py --check`, `python
util/check_doc_links.py --internal-only` and `python
util/check_doc_versions.py` pass
- [x] `python util/check_component_core_api.py --release-version 0.25.4`
passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
tests/unit/test_release_tag.py tests/unit/test_hub_core_version_gate.py
tests/unit/test_release_versions.py
hub/agents/gaia/python/tests/test_npm_doc_min_version.py`: 230 passed
- [x] Re-run the above after amd#6165 merged and main was merged in
- [ ] CI green on the merge commit
- [ ] `release_train_dryrun.yml` passes on that commit before the RC tag

## Evals to re-run on the RC tag

LLM-affecting PRs merged without per-PR evals; run these on
`v0.25.4-rc1`:

- `rag_quality` and `real_world` (amd#6165, amd#6057)
- `gaia_rag` and `gaia_media` (amd#5651)
- `gaia_email` (amd#6124)
- `gaia_skills_tasks` and `gaia_skills_lifecycle` (amd#5450, amd#5454, amd#6080)
- `gaia_files` and `gaia_shell` (amd#6069, amd#6074, amd#6120)
- `gaia_code` (amd#6056)
- `gaia_core` and `context_retention` (amd#6152)
- `gaia_data` and `tool_selection` (amd#6053, amd#6130)
- `memory` and `gaia_memory` (amd#6127, amd#6081)
- `gaia_tool_selection` for tool confirmations (amd#5541)

## Release checklist

- [ ] Keep amd#6114 unmerged until v0.25.4 is tagged, so main stays on
0.25.4
- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.25.4-rc1` (the RC freezes its
own flagship; no agent release needed)
- [ ] Before the final: release the flagship from the release commit
(`agent-pkg-gaia-v<next>`), merge its pin-lock PR, and pass
`check_flagship_release.py`
- [ ] Extend the changelog if main gains commits before the tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes sidecar Agent sidecar contract / harness tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants