Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Durable Long-Running Agentic Query Execution

Redesign an in-memory LLM-and-search workflow as durable, resumable execution with replayable progress.

Problem statement

For this exercise, assume the following bounded redesign scenario. An existing ask endpoint calls an ask service. The ask service invokes black-box LLM and search APIs, and it currently keeps query execution only in memory. Redesign this path for queries that may take hours.

An accepted query must continue to completion even when its browser tab closes or its connection is lost, and a reconnecting client must be able to resume progress streaming and obtain the terminal result.

Use these additional practice assumptions: each query belongs to one authenticated principal and receives a durable query ID; a client may retry submission after an ambiguous network timeout without intentionally creating duplicate execution; queries typically run for tens of minutes and may run for up to six hours; the service accepts up to 10 new queries per second; and one query may emit up to 10,000 ordered progress events.

Progress should normally become visible to a connected client within two seconds and remain replayable for seven days. Delivery may be at least once, so events have stable IDs and per-query sequence numbers.

The LLM and search APIs are request-response black boxes: retries may cost money and may return different content, but they do not mutate user-owned state. Durability must cover individual API, scheduler, stream-gateway, and worker process restarts after acceptance.

Design for one deployment region with zone-level failure tolerance; multi-region failover, interactive query editing, and collaboration between users are outside the initial scope.

What to build

  1. A client can submit a query and receive a durable query identifier without waiting for the query to finish.
  2. The system continues the multi-step LLM-and-search execution across client disconnects and service or worker restarts.
  3. A client can stream current progress and reconnect from a cursor without losing committed progress events.
  4. A client can read the durable terminal status and final result after execution succeeds or fails.

At scale

  • Assume up to 10 newly accepted queries per second, with typical runtimes of tens of minutes and a maximum runtime of six hours.
  • Assume each query may emit up to 10,000 ordered progress events, which remain replayable for seven days.
  • Assume connected clients should normally observe committed progress within two seconds, while at-least-once delivery is acceptable when event IDs and sequence numbers support deduplication.
  • Assume that once submission is acknowledged, loss of any single service process or worker must not lose the query's committed workflow state, progress, or terminal result.