From 8e9d45b374f0d57bad0fe2b6bb509648e4118ad6 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Wed, 5 Aug 2026 16:13:44 -0700 Subject: [PATCH] [eric] tool-ui: expired respond is 200+gone not a red 404, the orphaned state stays --- backend/main.py | 6 +++--- frontend/src/app/pages/AgentChat/tool-ui/AskUiBubble.tsx | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/main.py b/backend/main.py index 4550cff7..3e66b9f3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -938,9 +938,9 @@ async def ui_request_respond(request: Request): return JSONResponse({"error": "session_id, component_id and response object are required"}, status_code=400) from backend.apps.agents.ui_request_bridge import respond_to_ui_request delivered = respond_to_ui_request(session_id, component_id, response) - if not delivered: - return JSONResponse({"error": "no pending request for that component"}, status_code=404) - return JSONResponse({"ok": True}) + # A consumed/expired request is a normal outcome (replayed transcript, agent moved on), not an + # error; 200 + gone keeps Chromium's console free of red 404 noise while the UI shows its orphaned state. + return JSONResponse({"ok": delivered, "gone": not delivered}) @app.post("/api/invoke-agent/run") diff --git a/frontend/src/app/pages/AgentChat/tool-ui/AskUiBubble.tsx b/frontend/src/app/pages/AgentChat/tool-ui/AskUiBubble.tsx index 60ac8044..300a3655 100644 --- a/frontend/src/app/pages/AgentChat/tool-ui/AskUiBubble.tsx +++ b/frontend/src/app/pages/AgentChat/tool-ui/AskUiBubble.tsx @@ -60,8 +60,9 @@ function AskUiBubble({ pair, sessionId, isPending, suppressReveal }: AskUiBubble headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getAuthToken()}` }, body: JSON.stringify({ session_id: sessionId, component_id: componentId, response }), }) - .then((r) => { - if (!r.ok) { + .then(async (r) => { + const body = r.ok ? await r.json().catch(() => null) : null; + if (!r.ok || (body && body.gone)) { // Nothing parked server-side (agent gone or this is a replayed transcript): say so instead of silently swallowing the click. setSubmitted(false); setLocalChoice(undefined);