AI Interviews · Question

Design an agentic system for engineering automation pain points such as misrouted or excessive engineering pings and bugs deep in infrastructure. When is deterministic code a better choice than an agent?

ML / LLM system design question reported at Apple (2026). Sources, confidence and an answer card.

Researched · updated

r2a-015 AI Engineer Agent design & reliability ML / LLM system design Low confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “I’d split this into two systems. Routing is a workflow: rules from CODEOWNERS and the service catalog handle most pings for free, and one model call picks a team from a fixed list for the rest. Investigating a deep infrastructure bug is the only part that needs an agent, and that agent is read-only, capped on steps and dollars, and only writes a draft for the on-call engineer. Deterministic code wins whenever the rules are stable, the input is structured, volume matters, or someone will later ask exactly why.”

The rest of this page explains each part of that answer.

The interviewer wants to know whether you reach for an agent by reflex. Can you say which parts of an engineering-automation problem are lookups, which are classification, and which really need open-ended investigation?

What makes this different from normal routing

You have built routing before: a rules table, a lookup by key, a default queue. That code does the same thing every time and costs nothing per message.

A step that calls a large language model (LLM) behaves differently. It can read messy free text that no rule matches, which is useful. But it can also be confidently wrong: it may name a team that doesn’t exist. This is called hallucination. Each call also costs money and takes a second or two.

And if you let the model choose its own next action, it becomes an agent: a loop in which the model decides, each turn, which tool to call next (search logs, read a dashboard), until it says it is done or a limit stops it. Every extra step costs more and is another chance to be wrong.

So the answer is about placing each step on the cheapest rung that works: a rule, then one model call, then an agent only where the path can’t be drawn in advance.

This question was seen only through search snippets of one Apple candidate’s account (Interview Querysnippet only), so treat the details as thin. The second half, when deterministic code beats an agent, is the part to answer crisply.

Clarify first

  • What is a “misrouted ping”? A Slack message, a pager alert, a ticket? Assume Slack messages and tickets.
  • What ownership data exists? CODEOWNERS, a service catalog, an on-call rota? Assume all three.
  • Volume and urgency? Assume 2,000 pings a day, each routed within a minute.
  • What does “deep in infrastructure” mean, and who acts on the findings? Assume an on-call engineer.
  • May the agent change anything? Assume read-only.

Say it like this: “I’ll assume the agent can only read. If it can change infrastructure, the design gets much stricter.”

Answer

Words you need first

  • Token: the unit models read and write, roughly ¾ of a word. Providers bill per token, input and output separately.
  • Tool call: the model asks your code to run a named function (for example search_logs) with arguments; your code runs it and sends the result back.
  • Structured output: the model must answer in a fixed JSON shape, for example one team id from a list, so code can check it.
  • Eval set: a fixed list of past examples with known right answers, run before every prompt or model change.

The two systems

Ping (Slack message or ticket)
   │
   ▼
Intake ── drop duplicates about the same incident
   │
   ▼
Rules ── service name / file path / alert id → owner via CODEOWNERS + service catalog
   │  (no match)
   ▼
One model call ── pick one team id from the catalog, or "unknown", plus a short reason
   │
   ▼
Check in code ── does the team id exist?  no → default triage queue
   │
   ▼
Post to that team's on-call, with a reassign button
   │  (on-call asks for help on a deep bug)
   ▼
Capped agent ── read-only tools: logs, metrics, recent deploys, runbooks
                 step cap + dollar cap → draft summary with evidence links

Routing is a workflow. Rules come first. A ping naming a service, a file path or an alert id maps to an owner through CODEOWNERS and the service catalog. Repeated pings about the same incident are deduplicated. For what the rules miss, one model call returns a closed answer: a team id from the catalog, or “unknown”, plus a short reason. An unknown or made-up team id fails validation and goes to a default triage queue.

Feedback comes free. When someone reassigns a ping, that is a label for the eval set.

Investigation is a capped agent, used only for issues routing can’t resolve. It gets read-only tools over logs, metrics, recent deploys and runbooks, and a step cap and a dollar cap. Its output is a draft summary with evidence links for the on-call engineer, never a change.

Follow one ping

At 09:12 this arrives: “Since about 8:40 the nightly export jobs fail with ‘connection reset by peer’ when they write to the reports bucket. Who owns this?” (an illustrative example).

StepWhat happensWhat to say in the interview
IntakeNo open run about the same bucket, so it is not a duplicate.”Dedupe first; one outage can produce twenty pings.”
RulesNo service name, path or alert id matches.”Rules handle the easy majority for free.”
One callReturns storage-platform with a one-line reason.”The answer is one item from a list, so one call with a schema is enough.”
Checkstorage-platform exists and has an on-call.”A made-up id would fall back to triage.”
PostThe on-call gets the ping and accepts it.”Every accept or reassign becomes an eval label.”
Agent (on request)Reads logs and deploys in about 8 steps, finds a config change shortly before the failures began.”Read-only and capped; it drafts, a person decides.”

When deterministic code wins

Say this list out loud. Code wins when:

  • the rules are stable and must be auditable;
  • the input is already structured (a stack trace naming a service maps to an owner through CODEOWNERS);
  • the volume or latency matters;
  • someone will later ask exactly why a decision was made.

Use the model for the messy long tail. Anthropic’s guide recommends “finding the simplest solution possible, and only increasing complexity when needed” (Building effective agents, 2024-12-19).

Why the rung matters: the cost

An agent re-sends its whole history to the model at every step, because the model doesn’t remember earlier calls. So each step’s prompt is longer than the last, and total input grows with the square of the number of steps.

For one ping, an 8-step agent costs about $0.196, against $0.0065 for one classification call: about 30 times more. A sensible mix (rules first, one call for the 40% they miss, the agent for 5%) costs about $744 per 30 days at 2,000 pings a day. These are Claude Sonnet 5 list prices fetched 2026-10-11; the step counts and splits are assumptions.

The arithmetic behind the numbers (for a Staff-level follow-up)
  • Agent input tokens = N × C0 + Δ × N × (N + 1) ÷ 2, where N = steps, C0 = the fixed start of each call (system prompt, tool descriptions, task) and Δ = tokens added per step. Assumed N = 8, C0 = 4,000, Δ = 1,500: 32,000 + 54,000 = 86,000 input tokens, plus 8 × 300 = 2,400 output tokens.
  • Agent cost at $2 per 1M input and $10 per 1M output: $0.172 + $0.024 = $0.196 per ping.
  • One call (2,500 in, 150 out): $0.005 + $0.0015 = $0.0065. Ratio ≈ 30.
  • The mix: 0.40 × $0.0065 + 0.05 × $0.196 = $0.0124 per ping × 2,000 × 30 ≈ $744.

Measure before you build the agent

Take 200 past pings with the team that finally fixed each one. Compare rules alone with rules plus one call before building any agent. Often the rules alone already handle most of the volume.

Say it like this: “My eval set comes free from history: every past ping already has the team that fixed it.”

Senior vs Staff

Pings and deep bugs

Senior

  • Separates routing (rules plus one call) from investigation (a read-only agent), with caps and a fallback queue.

Staff

  • Starts from reassignment rate and time-to-right-team, uses reassignments as free labels, and shows most of the value arrives before any agent exists.

In plain words: a Senior answer builds the two systems correctly. A Staff answer starts from the metric the business cares about (how often pings bounce, how long until the right team sees them) and shows that most of the gain comes before any agent.

Small-team version

At a 50–500 person company, the first version is a Slack bot plus the service catalog you already maintain, and one model call for the long tail. That ships in a week or two, with an eval built from history. At an assumed 2,000 pings a day, one Sonnet 5 call per unmatched ping costs at most about $390 a month, and far less once the rules handle most pings.

The investigating agent waits until routing is good, and stays read-only.

Treat every ping as untrusted input. A message can contain hidden instructions (“ignore your rules and…”), and the model may follow them. This is called prompt injection. An instruction hidden in a message must never reach a tool that writes.

Pitfalls

  • An agent where CODEOWNERS answers the question. It costs about 30× more per ping and adds steps that can go wrong, for an answer a lookup already gives.
  • Free-text team names instead of a closed list. Code can’t check a free-text name, so a made-up team slips through.
  • An investigating agent with write access to infrastructure. Pings are untrusted text, so injected instructions could turn into real changes.
  • No eval from history before launch. Without it you can’t show the model beats the rules you already have.

Go deeper

Family