System design walkthroughs 6: AI-era questions
Problem. Full interview answers for the bank’s 2026 layer — agents, async AI jobs, and ML systems in production. Part 6 of 6. (1: foundations · 2: feeds · 3: geo & marketplaces · 4: media & storage · 5: money)
27. Enterprise AI research agent [Cohere, reported Sep 2026]
Requirements. Functional: answer from internal + web sources with citations. Non-functional: per-user permissions strictly respected, answers grounded (no invented citations).
Estimation. 1k sessions/day × 20 tool calls × 2k tokens ≈ 40M tokens/day — compute the token bill before the architecture; retrieval QPS is the smaller number here.
API. POST /ask {query, scope}, streaming GET /sessions/{id}/events
(SSE), GET /sessions/{id}/sources.
Core design. Permission-filtered retrieval (filter before generation, never after — the graded topic), connector fan-out across internal stores plus web, synthesis with source-attached citations, full audit log of what was read. Cache per (user, query) never across permission boundaries — leakage via shared cache is the trap answer to reject.
28. Long-running query service [Perplexity, reported Sep 2026]
Requirements. Functional: submit deep query, poll or subscribe for the result. Non-functional: survive worker loss mid-run, explicit cancel, bounded cost per job.
Estimation. 10k jobs/day, 5-minute median runtime → ~35 concurrent workers average, 5× provisioned for peaks; checkpoints bound redo work.
API. POST /jobs {query, webhook?} → job id; GET /jobs/{id}
(status + partial results); DELETE /jobs/{id} (cancel);
POST /jobs/{id}/retry.
Core design. Durable job records before the first worker picks them up; leased execution with heartbeats and checkpoints; status/result polling plus optional webhooks; idempotent steps so redelivery is safe. Progress events (SSE) separate from the final result payload.
29. Concurrent image processing with backpressure [Anthropic, reported Jul 2026]
Requirements. Functional: process images through a pipeline, scale one worker to many. Non-functional: exactly-once effects, bounded queues, cancellation that actually cancels.
Estimation. 100k images/day × 5s each ≈ 6 worker-days/day → ~10 workers sustained; queue depth × processing time = worst-case latency, say it.
API. POST /jobs {image_url, ops[]}, GET /jobs/{id}, DELETE
/jobs/{id} (cancel), lease heartbeats internal.
Core design. Lease-based claiming (no double-processing), idempotent outputs keyed by input hash, retries with backoff plus poison-task quarantine, bounded queues that push back on producers. Cancellation propagates as a first-class signal down the whole chain.
30. AI travel booking agent [OpenAI, Anthropic, Google]
Requirements. Functional: search and book flights/hotels conversationally. Non-functional: never book without confirmation, credentials never in prompts, partial failures recoverable.
Estimation. 5k sessions/day × 15 tool calls × 3k tokens ≈ 225M tokens/day — the orchestrator LLM dwarfs the booking APIs in cost; say it and propose the small-model triage.
API. POST /sessions, POST /sessions/{id}/message (streaming),
POST /sessions/{id}/confirm {action_id} for the irreversible step.
Core design. Orchestrator plus tool gateway with one schema; risk-classified actions (search freely, book only on explicit confirm); credential vault injected at the tool layer; idempotent bookings with compensating cancellations; evaluation on seeded task-completion scenarios.
31. AI code assistant [Microsoft, Google, JetBrains]
Requirements. Functional: inline completions + chat refactors. Non-functional: ghost text under 100 ms, private code stays private.
Estimation. 10k engineers × 100 completions/day = 1M/day ≈ 12/s average, 100/s peak; each completion ~500 tokens context in, 50 out — context assembly, not generation, is the cost.
API. POST /complete {prefix, suffix, context_refs} (streaming),
POST /chat {history, workspace_refs}.
Core design. Local context assembly (open files, imports, recent edits) pruned to budget; small fast model for completions, bigger model for chat; prefix caching; telemetry-gated rollouts. Privacy boundary stated: what leaves the IDE, hashed or redacted how.
32. Real-time fraud detection [Stripe, PayPal, Amazon]
Requirements. Functional: approve/deny in the payment path. Non-functional: 50 ms budget at tens of thousands TPS, false declines cost real money (say the business side).
Estimation. 50k decisions/s × 200 features; models must fit the 50 ms envelope including feature fetch — precompute everything possible.
API. POST /score {transaction} → {decision, reasons[]} synchronous;
async POST /feedback {outcome} for labels.
Core design. In-memory rules first (fast, explainable), model score second, async deep analysis after the decision; streaming features with batch fallback; continuous deployment with champion/challenger; precision vs recall tuned as a business number, not an ML metric.
33. Feature store for ML [Netflix, Uber, Airbnb]
Requirements. Functional: one definition of each feature for training and serving. Non-functional: point-in-time correctness (no leakage), millisecond online reads.
Estimation. 1k features × 10M entities; online store sized for hot keys only, full history in the warehouse.
API. GET /features {entity, names[], as_of}, POST
/features/definitions (versioned), batch POST /backfill.
Core design. Batch backfill for history, streaming for freshness, online low-latency store vs offline warehouse from the same definitions; point-in-time joins so training never sees the future; versioned features with deprecation, not silent edits.