Repository navigation
fix(gaia-agent): stream answers on the /query sidecar route - #5567
Conversation
A relayed flagship turn in the Agent UI showed "Waiting on the model" until the whole answer landed at once, and Stop left an empty bubble. The sidecar built its agent with streaming off, so every model call was unstreamed and no token events reached the relay. Every /query turn now streams, the way the stdio transport and the in-process Agent UI path already do. A turn stopped mid-answer ends with an empty final, as stdio does, instead of the "finished without producing an answer" error, and no token follows the cancel. The Agent UI keeps the text already streamed in.
|
Verdict: Approve with suggestions This fixes the main complaint: on a desktop install, flagship answers in the Agent UI arrived all at once after a long "Waiting on the model", and Stop left an empty bubble. The sidecar now streams every relayed turn, and a stopped turn ends cleanly and keeps the text already shown. The fix is small and well aimed, and the new end-to-end test runs the real agent loop, socket and relay, so it would catch this regression again. Nothing blocks merge. Things to know before merging:
Real-world evidenceN/A: no evidence bundle was produced for this run. The two live checks (an Agent UI answer that visibly grows, and Stop keeping partial text) are still unchecked in the test plan, so this verdict rests on static review plus the author's reported test runs. The 🔍 Technical detailsIssues 🟢 SPEC.md doesn't state the new cancel terminal ( 🟢 Tokens queued before the cancel are dropped as well ( 🟢 Timing-based tests ( Strengths
|
|
Checked live in the Agent UI on a desktop-style install (relayed sidecar built from this branch, 🔍 Technical detailsSampling the reply bubble once a second during "Write a 400-word story": 112 → 551 → 1,649 → 2,193 characters (before this branch: 24 characters for ~10 s, then all 2,174 at once). Stopping a 1,500-word answer at ~1,666 characters left that text in the bubble followed by "Stopped" (before: an empty "Stopped" bubble). Build: the integration branch plus #5553/#5561/#5562/#5568, app/backend/agent binary from one commit. |
SPEC.md now carries the cancel contract SKILL.md already promised: a stopped run ends with an empty final and no token after the cancel. Both docs and the changelog say text not yet sent when the cancel lands is dropped.
|
SPEC.md now states what a stopped 🔍 Technical details
|
…answers # Conflicts: # hub/agents/gaia/python/gaia_agent/server.py
Head branch was pushed to by a user without write access
|
Merged current main (6cbb246) into this branch. There was one conflict, in the npm CHANGELOG, and both entries are kept. Tests pass. 🔍 Technical details
|
|
Checked live in the desktop app: fresh install, local Qwen3.6-35B-A3B, and a gaia-agent binary frozen from this branch merged with main
|
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 amd#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. <details> <summary>🔍 Technical details</summary> `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. </details> ## 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 amd#5728

In the Agent UI on a desktop install, flagship answers didn't stream. A 400-word story sat on "Waiting on the model" for about 12 s and then appeared all at once. Pressing Stop during that wait left an empty "Stopped" bubble. The flagship runs in the daemon's sidecar there, and the sidecar built its agent with streaming off, so the model call was unstreamed and no answer text reached the relay until the turn ended. Now every relayed turn streams its answer token by token, and Stop keeps the text that has already arrived. This supersedes the draft #5006.
Test plan
pytest hub/agents/gaia/python/tests/test_relayed_answer_streams.py: drives the real agent loop, a real sidecar socket and the UI's relay with a model that parks mid-reply. It asserts answer text reaches the UI before the model finishes, and that Stop keeps it. All 3 cases fail without the fix.pytest hub/agents/gaia/python/tests/test_server_query.py: 81 passed, including the new streaming, per-turn and stopped-run casespytest tests/unit/chat -n 4: 2164 passedpytest hub/agents/gaia/python/tests -n 4: 769 passed. 3 fail intest_full_tool_bundles.py/test_manifest_tools_count_matches_real_registrybecause the optional browser tools aren't installed locally. They don't touch this change.python util/lint.py --black --isortgaia_core,gaia_tool_selection,gaia_honesty,tool_selection,error_recovery🔍 Technical details
build_query_agentandbuild_session_agentconstructGaiaAgentwithGaiaAgentConfig's defaultstreaming=False, and the/queryroute never turned it on. The base loop therefore took thesend_messagesbranch and its "Waiting on the model" progress label, and the only text the route ever saw was the finalanswer. The stdio transport setsstreaming=True, and so does the in-process Agent UI path, so neither had this problem. The relay, the daemon proxy andSidecarProxy.iter_linesalready forward each event as it arrives.agent.streaming = Trueon every/queryturn, set afteragent.console = handlerso a retained session agent can't drift back.status: "cancelled"with no text._terminal_from_run_resultmaps that to an emptyfinal, the same as stdio, instead of the "finished without producing an answer… This is a bug" error.tokenevents are dropped once the run is cancelled, so a half-written JSON reply flushed at teardown can't leak.chunktext when a relayed turn is stopped without ananswer.test_relayed_stop_keeps_text.pypins that behaviour, since the fix depends on it.{"thought", "answer"}envelope.SSEOutputHandlerhas streamed theanswerfield since fix: stream JSON answers again and repair main CI #5147, so those answers stream too, and the new end-to-end test uses that envelope./querySSE contract is unchanged:tokenwas already part of it.