Skip to content

The agent that grows with you

Merge pull request #71184 from NousResearch/bb/desktop-stream-resume

brooklyn!62e07223d630
diff --cc tui_gateway/server.py
index c9237a6b28e,23be58cb63c..c5ad49720dc
--- a/tui_gateway/server.py
+++ b/tui_gateway/server.py
@@@ -10461,21 -10575,15 +10698,20 @@@ def _(rid, params: dict) -> dict
_start_agent_build(sid, session)
def run_after_agent_ready() -> None:
- err = _wait_agent(session, rid)
+ # Patient wait (#63078): the user's message is already the accepted
+ # in-flight turn, so a slow deferred build must not eat it. The wait
+ # delivers the prompt when the still-running build completes, honors a
+ # cancel promptly, notices the user once past the slow threshold, and
+ # only errors when the build itself fails or the bounded cap expires.
+ err = _wait_agent_for_prompt(session, rid, sid)
if err:
- _emit(
- "error",
+ # Terminal frame + retained snapshot (not a bare "error" event +
+ # cleared inflight): if the client is disconnected right now, the
+ # retained snapshot is the only way resume can show this failure.
+ _emit_terminal_turn_error(
sid,
- {
- "message": (err.get("error") or {}).get(
- "message", "agent initialization failed"
- )
- },
+ session,
+ (err.get("error") or {}).get("message", "agent initialization failed"),
)
with session["history_lock"]:
session["running"] = False