Skip to content

fix(ui): show a relayed agent's file changes in Outputs, Changes and Undo - #5553

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/relay-outputs-ledger
Oct 23, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/relay-outputs-ledger

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 feat(agent-ui): the agent writes a new chat's greeting, behind a loading screen #5512 (contract 2.19, /greeting) merges first, this PR moves to 2.20 when it's rebased.
  • If feat(ui): Add to this reply and Always allow work with the flagship agent #5541 (contract 2.19, grants) merges first, this PR moves to the next contract number when it's rebased.

Test plan

  • 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.
  • 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.
  • 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.
  • 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.
  • python util/lint.py --black --isort, and python -m gaia_agent.export_openapi --check
  • 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.
🔍 Screenshots

After the relayed write:

Outputs and Changes after a relayed write

After Undo:

After undoing the relayed turn

Files the flagship sidecar wrote never showed in the session panel's
Outputs: the relay emitted tool events straight onto the queue and skipped
the turn ledger the summary is built from, and the summary view a relayed
result is reduced to dropped the resolved path the tool returned.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes labels Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Files the agent writes in a desktop (relayed) chat now show up in the chat's Outputs panel. Before this, the relay never recorded the turn's tool calls, so Outputs stayed on "Nothing yet". The fix is small. It reuses the bookkeeping the in-process path already has, and the new tests run a write through the real sidecar handler, translator and relay. I found no correctness problems.

  • Live check still open. Before merge, tick the unchecked desktop item in the test plan (ask the agent to create notes.txt, confirm it appears under Outputs), ideally with a screenshot. Only the unit tests show the change works so far.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review alone. The user-visible surface is the Agent UI Outputs panel, and its live check is still pending in the PR's test plan. I couldn't run the unit tests either, because this runner has no pytest installed.

🔍 Technical details

Issues

🟡 No live evidence for an Agent UI change. This changes what the Outputs panel shows, but the PR has no screenshot and no captured route or response for a relayed turn. The unit tests cover the logic end to end (sidecar SSEOutputHandler → CanonicalTranslator → relay._dispatch_one → _turn_summary), so treat this as a nudge, not a blocker. Please attach a before→after screenshot when the pending live item runs.

🟢 Relay skips the dict check the in-process path has (src/gaia/ui/email_sidecar/relay.py:233). pretty_print_json passes args to the ledger only when isinstance(data, dict). Here event.get("args") or {} goes straight into TurnLedger.tool_args, which calls dict(args). A malformed sidecar event would now fail in the ledger, before _format_tool_args fails on it as it already does. Guarding it costs nothing:

        handler.turn_ledger.tool_args(args if isinstance(args, dict) else {})

Strengths

  • Uses the existing ledger API (tool_started / tool_args / tool_result) instead of a parallel relay-only path, and computes success once so the event and the ledger can't disagree.
  • RESULT_PATH_KEYS on the handler and SUMMARY_VIEW_KEYS in the translator keep the resolved path across the relay hop. That fixes relative and ~ paths once the sidecar is rebuilt. The old-sidecar case (absolute path only) is pinned by its own test.
  • The negative test (a failed write is not listed) and the doc row for file_path / image_path on tool_result keep the API reference in line with the code.

…Undo

Desktop chats run in the flagship sidecar, which never copied the files a
turn changed, so the Changes view and per-answer Undo stayed empty. The
Agent UI now sends a turn id on /query (contract 2.19, changes_turn_id);
the sidecar records that turn's changes in the shared snapshot store and
finishes the recording before its terminal event. The UI links the turn
to its answer through a file beside the manifest, so the two processes
never write the same file.
A refused confirmation ended the stream before the recording was saved,
and an end state that failed to save left the turn looking interrupted.
The refusal now saves it first, and a failed save is tried again when
the run ends.
@kovtcharov kovtcharov changed the title fix(ui): list files a relayed agent writes in the chat's Outputs fix(ui): show a relayed agent's file changes in Outputs, Changes and Undo Oct 22, 2026
server.py moved to 2.19 for changes_turn_id, but the npm package still declared 2.18, so its contract test failed on every platform.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Fixed the npm package build: the package still declared contract 2.18 after the agent moved to 2.19. I didn't apply the suggested args guard, because replacing a malformed event with {} would hide a broken sidecar.

🔍 Technical details
  • Build & Test gaia npm package (ubuntu, windows): cli.test.ts > contract constants > matches the sidecar's API_VERSION expected 2.18 to be 2.19. server.py bumped API_VERSION to 2.19 but lifecycle.ts didn't. API_VERSION and its doc comment are now 2.19, which matches server.py, SPEC, SKILL and the CHANGELOG.
  • Declined: isinstance(args, dict) guard in relay.py. The sidecar's CanonicalTranslator._on_tool_args already turns any non-dict args into {} before it emits tool_call, so a conforming sidecar always sends a dict. A non-dict here would mean a sidecar that breaks the contract, which should fail loudly per CLAUDE.md's no-silent-fallbacks rule rather than record an empty call. It already fails in _format_tool_args on the same event.
  • Local verification:
    • npm npm ci && npm run build && npm test: 151 passed.
    • python util/lint.py --all: pass.
    • capability_matrix.py --check: up to date.
    • pytest tests/unit/chat -n 4: 2164 passed. One xdist-only flake in an untouched file passes in isolation 3/3.
    • Relay, snapshot and fidelity tests: 143 passed.
    • hub/agents/gaia/python/tests with an isolated GAIA_HOME: 768 passed. The 3 failures need Playwright, as on main.

@kovtcharov-amd
kovtcharov-amd merged commit 9ff05f9 into amd:main Oct 23, 2026
45 checks passed
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
…-folders

Main shipped contract 2.19 for changes_turn_id (amd#5553), so surface moves
to contract 2.20: the server, relay floor, npm API_VERSION, OpenAPI
artifact, bundled docs and tests now say 2.20, and the relay sends both
fields to a sidecar that takes them.
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
In a private chat, "Please remember …" was correctly not saved, but the
session panel's Outputs still listed "Memory saved" for that turn: a
false claim on a privacy feature. A relayed turn's tool results reach
the Agent UI as a summary view that kept only the summary text and
`success`, so the turn summary never saw that `remember` returned
`status: "skipped"`. The summary view now carries the tool's own
`status`, so a skipped save, and any other tool that reports a skip, is
no longer listed as made.

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

- Fixed at the wire, not by string-sniffing `"skipped:"` in
`TurnSummary`: `SSEOutputHandler.pretty_print_json` puts the result's
`status` on the `tool_result` event, and `SUMMARY_VIEW_KEYS` carries it
into the canonical `data`. `TurnSummary._produced` already skips
`error`/`skipped`, so it needs no change.
- Sidecar contract: an additive field on `tool_result.data`, so there's
no `API_VERSION` bump. The gaia npm CHANGELOG notes it. It takes effect
once the sidecar binary is rebuilt. An older sidecar still sends no
`status`, and its skipped saves stay listed.
- Other Outputs kinds: `error` results were already dropped (they fail
`success`), so only a `skipped` status leaked. In practice that's
`remember`. `generate_image`, the index tools and `schedule_send` never
return `skipped`, and the generic fix covers them if they ever do. The
email sidecar has its own translator and isn't touched here.
- On `main` the relay doesn't feed the turn ledger yet; amd#5553 adds that,
and this is the bug that shows up once it does. The two merge cleanly in
code. Both edit the same lines in `agent-ui.mdx` and the CHANGELOG, so
whichever lands second needs a small rebase. Checked on a local merge of
the two: a relayed skipped `remember` gives no outputs, and a stored one
gives "Memory saved".
</details>

## Test plan

- [x] `pytest tests/unit/test_sidecar_relay_fidelity.py`: new pipeline
tests (sidecar handler → canonical translator → relay → turn ledger). A
private chat's skipped `remember` lists nothing, and a stored one is
still listed. The skipped case fails on `main`.
- [x] `pytest tests/unit/chat/ui` plus the relay suites
(`test_email_sidecar_relay`, `test_relay_*`, `test_daemon_relay`),
`tests/unit/api`, and the SSE narration/usage tests: all pass.
- [x] `python util/lint.py --black --isort`
- [x] Desktop app with a rebuilt sidecar: in a private chat, a "please
remember…" message is refused and Outputs shows no "Memory saved"; in a
normal chat a real save shows it




## Live evidence

Desktop app, re-frozen gaia-agent sidecar: the private chat refuses the
save, and Outputs stays empty.

![Private chat with empty
Outputs](https://raw.githubusercontent.com/kovtcharov/gaia/evidence/ui-test-pass/pr5623_private_outputs.png)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
…d#5561)

When the agent deleted a file with a shell command (`del notes.txt`, `rm
notes.txt`, `Remove-Item notes.txt`), the turn's Changes view only said
it ran a command GAIA can't track, and Undo couldn't bring the file
back. Now a plain delete of named files in the workspace shows each file
as deleted, with its old contents in the diff, and Undo this turn
restores it. A delete GAIA can't read exactly (a wildcard, a variable, a
folder, a file outside the workspace, or extra steps on the line) still
shows as untracked shell work, so Undo never claims more than it has.

Relayed (desktop) chats get this once amd#5553 lands: the shell tool
records into the same turn recorder the sidecar opens there. On `main`
today, relayed turns record nothing at all, shell or otherwise.

## Test plan
- [x] `pytest tests/unit/test_shell_undo_marks.py`: `del`/`rm` of a
workspace file shows as deleted by `run_shell_command`, with no
untracked entry, its old text in the diff, and `restore_turn` puts it
back. `del *.txt` stays untracked with no files. Deleting a file outside
the allowed paths stays untracked and isn't recorded as restorable. A
copy that fails leaves the file and doesn't run the command.
- [x] `pytest tests/unit/agents/test_shell_deletes.py`: which delete
forms are read (cmd, sh, PowerShell) and which are left as unknown.
- [x] On top of amd#5553's branch, a stand-in sidecar agent that runs the
real shell tool with `del notes.txt` under `changes_turn_id`: the
relayed turn lists the file as deleted, with no untracked work, and Undo
restores it. This was a local check only, not added here, because it
depends on amd#5553.
- [x] `pytest tests/unit/test_shell_*.py tests/unit/chat
tests/unit/agents -n 4`: 7688 passed. There was 1 setup error from a
thread left running by an earlier test (`test_step_timing`), and that
test passes when run alone. `origin/main` also had 1 setup error in the
same run, in a different test (`test_email_phishing_guard`).
- [x] `python util/lint.py --black --isort --pylint --flake8`

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

- Approach: parse the delete, not diff the tree. A before/after file
list can show that a file vanished, but it has no copy of the contents
to restore. Copying the whole tree before every command would be
unbounded.
- `shell_deletes.split_exact` splits a step the way cmd.exe or sh will
hand it to the program. It returns None for anything that could expand
or re-split: `%`, `^`, `!`, `*`, `?`, `$`, backticks, `~`, redirections,
cmd's `,;=` name separators, or single quotes under cmd.
`delete_operands` reads `del`/`erase` (`/f`, `/q`), `rm` (`-f`, `-v`,
`--`), `unlink`, and `powershell`/`pwsh` running one `Remove-Item`
statement (`-Path`/`-LiteralPath`/positional, `-Force`,
`-Confirm:$false`). Recursive flags, `/s`, `/p`, `-i`, drive-relative
paths, ADS/device paths and names Windows trims are all refused.
- `ShellToolsMixin._snapshot_shell_deletes` runs where
`note_untracked("shell", …)` used to, after the cancel check and before
anything spawns. It calls `before_change(path, "run_shell_command")` for
each operand that is a regular file (not a link), at most 64 MiB,
outside credential folders, and inside `_path_allowed(...,
prompt_user=False)`. The untracked note is skipped only when every step
is a `cd` or a fully copied delete. A `SnapshotError` returns
NOT_EXECUTED, the same rule the file tools follow.
- The one-time-approval path (raw shell text) is unchanged. Destructive
lines are never offered there anyway.
- Deletes in the existing turn ledger already come through as `change:
"deleted"` with a diff, and the webui already renders that, so there's
no frontend change.
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants