iterate.com / ui

git clone https://git.iterate.com/repos/ui

Agent chat: an activity failed only when its last step failed (#13)

Jonas, 28 Nov 2026, in a call (relayed on /agents/main@48380): "I don't think
it's right to show an exclamation mark when you make three requests, the
first two fail, but the third one succeeds. ... errors in the UI feed should
only come when they're terminal."

summarizeAgentUiActivity said "failed" when any step of the activity failed.
Now the last step decides: a request that failed and that a later request
recovered, or a script whose error the next request read, is no failure of
the activity. The step's own row, when a person opens the activity, still
says what it was. An activity that ends on a failure is red as before.

Via: /agents/claude/dash-context-feed-threads-mwy308tb-4d1e63
Session: claude 89f0feea-b83f-4937-8b4a-56af6cb8884b on beelink
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Iterate-Run: /@1683021

jonas, 2026-11-28 10:52 UTC · 4c403fa029cf55e132034909e9cfb1ac731f4309 · parent cdd7ad5

2 files changed

M src/components/agent-chat/agent-ui-reducer.test.ts
@@ -1140,6 +1140,34 @@
   });
 });
 
+test("an activity failed only when its last step failed: a request that a later one recovered is no failure", () => {
+  const recovered = settleAtIdle(
+    reduceAll([
+      request(1, { model: "gpt-test" }),
+      settled(2, 1, failed("overloaded")),
+      request(3, { model: "gpt-test" }),
+      settled(4, 3, failed("overloaded")),
+      request(5, { model: "gpt-test" }),
+      settled(6, 5, succeeded("Hi.")),
+    ]),
+  );
+  const first = recovered.items.find((item) => item.kind === "activity");
+  if (first?.kind !== "activity") throw new Error("expected activity item");
+  expect(summarizeAgentUiActivity(first)).toMatchObject({ requestCount: 3, outcome: "clean" });
+
+  const terminal = settleAtIdle(
+    reduceAll([
+      request(1, { model: "gpt-test" }),
+      settled(2, 1, succeeded("Hi.")),
+      request(3, { model: "gpt-test" }),
+      settled(4, 3, failed("overloaded")),
+    ]),
+  );
+  const second = terminal.items.find((item) => item.kind === "activity");
+  if (second?.kind !== "activity") throw new Error("expected activity item");
+  expect(summarizeAgentUiActivity(second)).toMatchObject({ requestCount: 2, outcome: "failed" });
+});
+
 test("the first settlement wins when a duplicate races in", () => {
   // A request settles once; if a second settlement still lands, the UI must keep the first fact.
   const state = reduceAll([
M src/components/agent-chat/agent-ui-reducer.ts
@@ -115,7 +115,13 @@
   interruptedBy?: MessageSender;
 };
 
-/** One canonical interpretation of activity attempts for every UI surface. */
+/** One canonical interpretation of activity attempts for every UI surface.
+ *
+ *  AN ACTIVITY FAILED ONLY WHEN ITS LAST STEP FAILED. Jonas, 28 Nov 2026, in a call: "I don't
+ *  think it's right to show an exclamation mark when you make three requests, the first two fail,
+ *  but the third one succeeds. ... errors in the UI feed should only come when they're terminal."
+ *  A step that failed and that a later step recovered (the next request, or the request that
+ *  reads a script's error) is no failure of the activity; its own row still says what it was. */
 export function summarizeAgentUiActivity(
   activity: AgentUiActivity,
   steps: readonly AgentUiStep[] = activity.steps,
@@ -130,13 +136,14 @@
   for (const step of steps) {
     if (step.kind === "code") {
       codeCount += 1;
-      failed ||= step.success === false;
+      failed = step.success === false;
       continue;
     }
 
     requestCount += 1;
     const cancelled = step.outcome === "cancelled";
     if (cancelled && step.cancelReason === "interrupted-by-user-input") {
+      failed = false;
       interrupted = true;
       // the newest interrupt says who stopped the answer, also when code sent it and names nobody
       interruptedBy = step.interruptedBy;
@@ -148,6 +155,9 @@
       // Any other cancellation (expired, or a reason this UI doesn't recognize) means the
       // request produced nothing.
       failed = true;
+    } else {
+      // it answered, or it still runs: what failed before it is recovered, or tried again
+      failed = false;
     }
   }