Skip to content

fix(email): stream the email agent's /query answer - #5767

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
xubenqiang:fix/email-query-streaming-5728
Oct 26, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
xubenqiang:fix/email-query-streaming-5728

Conversation

@xubenqiang

@xubenqiang xubenqiang commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

The email agent's /v1/email/query ran with streaming off, so a relayed turn showed "Waiting on the model" until the whole answer landed, Stop could not cut a model call short, and a stopped turn kept no text — the symptoms #5567 removed from the flagship, still present in a package published to npm.

What changed

  • query_routes.py now sets agent.streaming = True where it already sets agent.console, which is where the flagship sets it. That covers both agent paths in this route: the per-turn agent and the session-scoped one.
  • One test in test_query_route.py drives the real route with the fake agent and asserts the flag reached it; the fake starts at the config default (False).
  • hub/agents/email/npm/CHANGELOG.md names the behaviour change under [Unreleased], per the review.
🔍 Technical details

hub/agents/email/python/gaia_agent_email/query_routes.py, in the block that prepares the agent before the worker thread starts. The flagship does this at hub/agents/gaia/python/gaia_agent/server.py:1298. streaming is a base-agent attribute (src/gaia/agents/base/agent.py:2423), default off in GaiaAgentConfig, read at the step and streaming boundaries.

Test plan

  • PYTHONPATH=src:hub/agents/email/python pytest hub/agents/email/python/tests/test_query_route.py -q → 42 passed.
  • With only the fix reverted and the test kept: 1 failed — assert False is True for the fake's streaming. With the fix: 1 passed. That is the red/green pair.
  • black --check and flake8 --select=E9,F63,F7,F82 clean on both Python files.
  • Not run: the rest of the email-agent suite, and a live Agent UI session against a real mailbox (needs Gmail credentials and Lemonade).

Closes #5728

`/v1/email/query` ran with streaming off, so a relayed turn showed "Waiting on
the model" until the whole answer landed, Stop could not cut a model call short,
and a stopped turn kept no text -- the symptoms amd#5567 removed from the flagship,
still present in a package published to npm. The route now turns streaming on
where it already sets the console, which covers both the per-turn and the
session-scoped agent.

Refs amd#5728
Copilot AI balanced review requested due to automatic review settings October 25, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added the agent::email Email agent changes label Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The email agent's query endpoint now streams the model's answer as it's written, the way the flagship has since #5567. Users get live text instead of "Waiting on the model", Stop can cut a model call short, and a stopped turn keeps the text produced so far. The fix is one line in the right place: it covers both the one-shot and session agents, and it matches the flagship. The package's SPEC already promises token events on this stream, so the change makes the code do what the docs say. There are no blocking issues.

Two small follow-ups:

  • Add an entry to the email package's CHANGELOG. This is a visible behaviour change in a package published to npm, and the [Unreleased] section lists changes like it.
  • Shorten the new code comment to one line. The history belongs in the PR body.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change is in a streaming HTTP route whose live behaviour needs a real model (Lemonade) and a connected mailbox, so it would fall to the strix-halo lane. The verdict rests on static review and on the red/green unit test the PR body describes. A live /v1/email/query run showing token events arriving before final would be worth attaching when hardware is available.

🔍 Technical details

Issues

🟢 No CHANGELOG entry (hub/agents/email/npm/CHANGELOG.md). CLAUDE.md asks that a behaviour change to a hub agent package be named in its CHANGELOG. Suggested bullet for [Unreleased]:

- **Answers stream as they are written.** `/v1/email/query` now emits `token`
  events while the model writes, so a relayed turn shows text live, cancelling
  the run cuts the model call short, and a stopped turn keeps what was written.

🟢 Comment is history-tagged and long (query_routes.py:630-634). CLAUDE.md's comment rule asks for one WHY line, with no issue numbers or cross-file narration inline. The flagship's version (hub/agents/gaia/python/gaia_agent/server.py) is a good model:

        # Streamed calls put `token` events on this wire and let Stop cut a call short; set per turn.

Checked and fine

  • The flag is set after agent.console = handler and before the worker thread starts, inside the guarded span that releases the run lock on failure. It runs for both the per-turn and the session-scoped agents.
  • SSEOutputHandler.print_streaming_text exists, and SPEC.md:166 already documents token { delta }, so neither the wire contract nor the docs need to change.
  • Setting the flag on every turn means a retained session agent can't drift back to the config default.

Strengths

  • The fix mirrors the flagship exactly rather than inventing a second mechanism.
  • The test drives the real route with a fake agent that starts at the config default (False), and the PR body shows the red/green pair.

Both points from the review: the `[Unreleased]` section names the behaviour
change, and the comment beside the flag is one WHY line instead of a paragraph
of history.

Refs amd#5728
@xubenqiang

Copy link
Copy Markdown
Contributor Author

Both are in.

The [Unreleased] section now names the change, and the comment beside the flag is the one line you suggested — the history (this is #5567's fix, which the flagship got and the email agent did not) lives in the PR body instead.

pytest hub/agents/email/python/tests/test_query_route.py -q is still 42 passed, and black --check is clean.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 26, 2026
Merged via the queue into amd:main with commit e1fe4b4 Oct 26, 2026
24 checks passed
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 26, 2026
5 of 9 tasks
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 26, 2026
## Why this matters

v0.25.2 is a bug-fix release on top of v0.25.1: setup and install no
longer stop at the first failed step, shell and file access handle
Windows paths and text encodings, the Agent UI and desktop app stop
showing misleading states, and document search, email and skills each
lose a handful of rough edges. 55 commits since v0.25.1; notes are in
`docs/releases/v0.25.2.mdx` and credit 15 outside contributors.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.25.2.mdx
--tag v0.25.2` passes
- [x] `mintlify validate` (from `docs/`) passes
- [x] `python util/check_doc_links.py --internal-only`, `python
util/check_doc_versions.py` and `node
installer/version/bump-ui-version.mjs --check` pass
- [x] `python util/check_component_core_api.py --release-version 0.25.2`
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`: 156 passed
- [ ] 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.2-rc1`:

- `gaia_shell` and shell/safety (amd#5794, amd#5751, amd#5768)
- `gaia_honesty` (amd#5753)
- `gaia_skills_tasks` and `gaia_skills_lifecycle` (amd#5422, amd#5755)
- `rag_retrieval` and `rag_quality` (amd#5742, amd#5754, amd#5761, amd#5817, amd#5812)
- email scenarios (amd#5767, amd#5811)
- `tool_selection` and `error_recovery` (amd#5732)
- Claude provider thinking replay (amd#5072)
- memory categories (amd#5818 merged; amd#5756 has not)

## Release checklist

- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.25.2-rc1`
- [ ] 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

agent::email Email agent changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email agent answers don't stream in the Agent UI — the flagship's /query streaming fix wasn't applied to it

3 participants