Agent Run Console
Help users understand a long-running AI task: how far it has got, what state the system is in, why something failed, and when they need to step in Status: not started | Priority P0
1. Business scenario
A multi-agent research assistant: the user asks a research question and several agents work on it together:
- A planner agent breaks the question down and drafts a search plan
- A search agent calls paper-search tools and collects 20–50 candidate papers
- Reader agents read in parallel and extract key points
- A writer agent turns everything into a report with citations
- When it hits a paywall, gets too few results, or finds conflicting conclusions, it asks the user to step in (add keywords, upload a PDF, decide between options)
A task can run from 10 minutes to an hour, and users leave and come back. The agents work, but users get confused about four things:
| User confusion | What the UI must answer |
|---|---|
| Progress | Which step is it on? How long is left? What has it produced so far? |
| State | Is it running, waiting, retrying, or stuck? Which agent is doing what? |
| Errors | What went wrong and why, what has the system already tried, what can I do? |
| Intervention | Does it need me now? What exactly do I need to do? Will it continue after I'm done? |
2. Architecture and technology choices
[Scenario simulator] Scripted event scenarios (happy path / retry succeeds / partial failure / needs human / disconnect), replayed over time
│ (can be swapped for a real agent backend, see section 7)
▼
[Event API] GET /tasks/:id/events (SSE with event ids, supports Last-Event-ID replay)
GET /tasks/:id/snapshot (current snapshot for first paint and resync)
▼
[Client state] useTaskStream: SSE subscription → dedupe/sort → pure reducer(state, event) → derived view data
▼
[UI] Task list (dense table) | Task detail: summary + timeline + flow graph + agent swimlanes + outputs
Human-action inbox | Error cards | Global connection status| Part | Choice | Why |
|---|---|---|
| Framework | Next.js (App Router) + TypeScript | Front end and a mock SSE Route Handler in one app; easy to deploy on Vercel |
| UI | Tailwind CSS + shadcn/ui (built on Radix) | Source-level control over components; solid accessibility basics (focus management, keyboard support) |
| Server state | TanStack Query | Caching and invalidation for lists and snapshots; the event stream goes through the reducer |
| Real-time data | SSE (EventSource) | One-way push is enough; the browser reconnects automatically and Last-Event-ID allows replay |
| Flow graph | React Flow (@xyflow/react) | Nodes are custom React components, good for a live-colored DAG of agent steps |
| Long lists | TanStack Virtual | Logs and events can reach thousands of rows |
| Motion | CSS transitions + Motion (motion/react) | State changes and list insertions; respects prefers-reduced-motion |
| Testing | Vitest (reducer) + Testing Library (components) + Playwright (E2E scenario replay) + axe (accessibility) | Every state has a replayable scenario, shared by tests and demos |
| Component docs | Storybook | Shows every state of every component, and doubles as the design system showcase |
| Design | Figma | Information architecture and key screens are designed before coding |
Why an event stream + reducer instead of polling a status endpoint: for long tasks the value is in the process. Keeping events makes the timeline, replay and "what happened while you were away" summary possible. The reducer is a pure function, so out-of-order or duplicate events can be replayed after dedupe and sorting by id, and it is easy to test.
3. State model (the core of the design)
Task state: queued → running ⇄ waiting_human → (retrying) → succeeded | partially_succeeded | failed | cancelled
Step state: pending / running / retrying(n/N) / blocked (waiting on a dependency) / needs_human / succeeded / skipped / failed
Connection state: live / reconnecting / offline (shows last update time)
State × UI matrix (excerpt)
| State | Summary bar | Timeline | Primary action |
|---|---|---|---|
| running | Progress bar + current step + estimated time left (shown as "about", or hidden when unsure) | Current node pulses | Pause / Cancel |
| retrying | Yellow "Retrying automatically 2/3" + reason | Node shows retry count | None needed (details expandable) |
| needs_human | Prominent banner "Needs you: add search keywords" + how long it has waited | Node highlighted | "Handle it" goes straight to the form |
| partially_succeeded | "7/10 papers read, 3 couldn't be fetched" | Failed nodes expandable | Upload PDF / Skip and continue |
| failed | Failure card (three parts) | Jumps to the failed node | Retry from the failed step / Edit and rerun |
| offline | Grey bar "Connection lost, reconnecting… last update 12:03" | Frozen | Manual refresh |
Three-part error card copy: what happened → what the system already did → what you can do. Example: "The paper search service timed out. We retried automatically 3 times and all failed. You can: retry this step later / switch to the backup search source / skip search and use the papers you uploaded."
4. Implementation steps (about 3 weeks)
| Phase | Work | Acceptance |
|---|---|---|
| D1–3 | Requirements and design: user task list, information architecture, state diagram, state × UI matrix; Figma designs and prototype for the task list, task detail and human-action pages | Designs cover every state in the matrix |
| D4–5 | Event schema (TypeScript types) + scenario simulator (5 scenarios) + SSE Route Handler (with Last-Event-ID) | The browser receives events replayed from a scenario |
| D6–8 | useTaskStream + reducer + unit tests; task detail page: summary, timeline (virtualized), error cards | All 5 scenarios render correctly |
| D9–10 | Flow graph view (@xyflow/react, nodes colored live) + agent swimlane view | "Who is doing what" across parallel agents is visible at a glance |
| D11–12 | Human-action inbox: tasks needing input in one place, task resumes after handling; unread count in the page title + browser notification (with permission) | The "needs human" scenario works end to end |
| D13 | Task list: dense table, filters, sorting, keyboard navigation (j/k to move, Enter to open), command palette | 100+ tasks without lag |
| D14–15 | Accessibility (axe, keyboard, VoiceOver, aria-live for key state changes) + 375px small-screen layout + dark mode | No serious axe issues; main flow works on a phone |
| D16–17 | Playwright E2E (one per scenario) + Storybook + deployment | Live URL + passing CI |
| D18–21 | Usability test with 5 people → rank issues → one iteration → write a case study page (before/after) | Case study + iteration log |
5. Challenges and highlights
| Challenge | Solution |
|---|---|
| Out-of-order, duplicate or missed events after a disconnect | Events carry monotonically increasing ids; the reducer is idempotent by id; reconnects send Last-Event-ID for replay; periodic snapshot resync |
| High-frequency events cause jank | Buffer events and commit once per frame (requestAnimationFrame); virtualize the log; only the summary layer is live, details expand on demand |
| Too many states, cluttered UI | Use a state machine instead of combinations of booleans; three layers of information: one-line summary → timeline → raw events/logs |
| Users come back and can't tell what happened | "While you were away" summary computed from the last-viewed time, with items needing action on top |
| Intervention requests get missed | Inbox + unread count in the title + optional notification; show waiting time; make the timeout policy visible ("will be skipped after 30 minutes without a response") |
| Screen reader users miss live changes | Announce only key changes (done, failed, needs human) with aria-live="polite", never every log line |
| State shown by color alone | Every state has an icon + text label; contrast meets WCAG AA |
| Demos depend on a real LLM, costly and flaky | The scenario simulator replays scripts, so demos, tests and screenshots are reproducible |
6. Resume description (STAR)
Agent Run Console | Owned interaction design and front-end development
- S: Tasks in a multi-agent research assistant often ran for tens of minutes; users couldn't judge progress, couldn't understand failures, and often missed the moments when human input was needed.
- T: Own the whole interaction chain, from information architecture and design to shipping the front end, so users can understand progress, state and errors and step in on time.
- A: Mapped a three-level state machine (task / step / connection) and a state × UI matrix, and produced designs in Figma; built the client state layer on an SSE event stream with an idempotent reducer, handling reconnect replay and out-of-order dedupe; implemented the timeline, a React Flow graph, agent swimlanes and a human-action inbox; replayed 5 scenario types through a simulator and covered every state with Vitest, Playwright and axe; ran a 5-person usability test and iterated.
- R: In usability tests, completion of "find why the task failed and get it going again" rose from X% to X%, and average time fell from X s to X s; zero serious axe issues; INP < 200 ms with 1,000 events. (Numbers to be filled in from real measurements)
7. Extensions
- Connect a real agent backend: replace the simulator with the event stream of the "Browser Automation Agent" or "AI Document Review Pipeline" project; the front end stays the same
- Replay mode: scrub through any past task along its timeline
- Multi-task status board: aggregate by agent and error type to see which errors are most common
8. Related knowledge base articles
- Front end / Next.js / Streaming UI and long-running tasks: progress for long tasks, SSE
- Back end / FastAPI / SSE streaming endpoints: event stream protocol
- Architecture / Pipeline orchestration / Task state machine and resumable runs: state modeling
- Architecture / Reliability / Human-in-the-loop: when to ask for help and how to resume
- Architecture / Observability / Traces and LLM call records: where timeline data comes from
- AI / Agent / Agent and workflow patterns: how multiple agents collaborate
