Design an Agentic AI System That Processes a Continuous Data Stream
Company: Apple
Role: Machine Learning Engineer
Category: ML System Design
Difficulty: hard
Interview Round: Onsite
Design a system in which AI agents process a continuous stream of incoming data. The report gives only this one-line prompt, so what the data is, what the agents must do with each item, which actions they may take, and the scale are all open: settle them with the interviewer before designing.
```hint Not every item needs an agent
Think about how to shrink the volume that reaches the expensive reasoning step, and what decides which items get there.
```
```hint Streams redeliver
Ask what happens when an agent's tool call runs twice for the same item because a worker crashed and the item was delivered again.
```
### Clarifying Questions
- What is in the stream (logs, transactions, user messages, sensor readings), at what rate, and with what bursts?
- What must happen to each item: classification, enrichment, a summary, or an action in another system such as filing a ticket or sending a notification?
- How fresh must results be: seconds, minutes, or is hourly enough?
- Do items depend on each other, for example needing the last hour of events for the same user or device, and must items with the same key be handled in order?
- Which actions may an agent take on its own, and which need human approval?
- Is there a cost budget for model calls per item or per day?
### What a Strong Answer Covers
- Scope, data rates, latency and permitted actions agreed first, with a clear view of which items truly need LLM reasoning
- Durable ingestion with partitioning, per-key ordering, and backpressure when model throughput is the bottleneck
- Tiered processing in which cheap filters, rules and small models handle most items before any agent runs, with batching and cost control
- Agent design: tools, state shared across items, bounded reasoning loops, and when one agent is enough
- Reliability and safety: idempotent actions, checkpoints, retries, dead-letter handling, defense against instructions hidden in the data, and human approval for risky actions
- Evaluation and monitoring of decision quality, latency, lag and cost per item
### Follow-up Questions
- The stream rate jumps tenfold and the model provider starts rate limiting you. What degrades first, and how?
- An agent needs context from the same user's events over the last hour. Where does that state live, and how does it reach the agent?
- How would you test a new prompt or model version before it handles live traffic?
- An item contains text that tries to instruct the agent to take an action. How does the design stop it?
Overview: Design a system in which AI agents process a continuous data stream, from ingestion and routing to agent tool use and actions in other systems. It tests deciding where LLM reasoning is worth its cost, handling backpressure and redelivery safely, guarding agent actions, and evaluating and monitoring agent decisions.
Read the full Apple Machine Learning Engineer interview experience this question came from