failover
← All labs

Hard · 14 steps · ~50 min

Design an AI code assistant

Instant inline completions, streamed chat and sandboxed code runs, with per-user limits, a fast model fleet and an outage plan.

Developers use an assistant inside their editor in two ways. Inline completions are many tiny requests that must feel instant, or they are worthless. Chat and agent mode are fewer, longer streamed requests that may run code or tests. One heavy user must not slow everyone down, the bill must be bounded, untrusted generated code must be contained, and a model provider outage must not stop developers from typing.

Same problem as IDE coding assistantsPull-request review bots

How it works

What you'll build

  1. The assistant API and its data model
  2. A limiter, gateway and fast completion fleet
  3. A completion cache and a streamed chat path
  4. A queued sandbox fleet that survives a lost host
  5. One combined design that survives a provider outage and a lost GPU

Steps

  1. 1Design the assistant API
  2. 2Design the data model
  3. 3Put a front door and a fast model in front of the editor
  4. 4Cache repeated completions
  5. 5Completion latency budget and stale requests
  6. 6Per-user quotas versus organisation quotas
  7. 7Stream chat answers through a realtime gateway
  8. 8Run generated code in a sandbox fleet
  9. 9Isolating untrusted generated code
  10. 10Lose a tool runner
  11. 11What code may be sent to the model
  12. 12Put it all together
  13. 13Survive a provider outage
  14. 14Lose a GPU server too
Start the lab →