Scenario Questions and Coding: A Five-Step Incident Drill and Four Agent-Flavored Coding Problems
Scenario questions ask what you do first when production breaks; coding questions ask whether your code holds up at the edges. First, practice five steps for incidents, symptom, localize, contain, root cause, and prevent recurrence, and walk through five scenarios: looping, hallucination complaints, costs doubling, a tool-timeout avalanche, and retrieval getting worse. Then write four agent-flavored coding problems: merging streamed tool-call chunks, a loop with a budget, retrying only idempotent operations, and trimming history to a budget without splitting a tool call from its result. The interviewer agent learns to run your code: beyond the public test case there are hidden ones, and a failure there becomes the next follow-up.
Today's Goals
- Can answer a production incident scenario in five steps, symptom, localize, contain, root cause, and prevent recurrence, and say why containment comes before the root cause
- Can write the four problems, merging streamed tool calls, a budgeted loop, idempotent retries, and history trimming, and say what each one's hidden test cases are catching
- Can implement a coding round that runs candidate code in a child process with a timeout, contains infinite loops and abrupt exits, and turns the first failing hidden test case into a follow-up
Yesterday was about how it breaks. Today it actually breaks. When you finish, come back to the top and check off the three goals.
Plain-Language Walkthrough
A grease fire: cover the pan first, work out why later
When a pan of oil catches fire, the right first move is to turn off the heat and cover the pan, not to stand at the stove wondering whether the oil was too hot or some water splashed in. The cause matters, but only after the fire is out. Investigate first and put it out later, and by the time you know why, half the kitchen is burned.
Production incidents follow the same order. Interview scenario questions, "your agent suddenly starts looping, what do you do?" or "costs doubled overnight, what is your first move?", test exactly this sense of order. Many candidates hear the question and start analyzing the root cause, eloquently, while the interviewer is waiting for a different sentence: what did you do first to stop the damage?
Coding questions have something similar: the interviewer shows you one example, and what decides whether you pass is the handful of edge cases you cannot see. Code that only runs the example is a stove you only know how to use when nothing is on fire.
The first half of today practices the five steps for scenarios; the second half writes four coding problems that people who have built agents are much more likely to get right.
Interview questions
An agent in production starts looping. How do you investigate and handle it?线上 Agent 开始打转,你怎么排查和处理?
Common in ChinaCommon overseasIntermediate#incident#looping#reliability🔒 Unlock this chapter to see the answer keys.
The agent's model costs doubled overnight. What is your first move?Agent 的调用成本一夜之间翻倍,你第一步做什么?
Common in ChinaCommon overseasIntermediate#incident#cost#prompt-caching🔒 Unlock this chapter to see the answer keys.
How do you merge streamed tool-call chunks without getting it wrong?流式返回的工具调用分片,怎么归并才不会出错?
Common in ChinaCommon overseasIntermediate#streaming#tool-calling#coding🔒 Unlock this chapter to see the answer keys.
When trimming conversation history, what must you preserve?裁剪对话历史时,哪些东西必须守住?
Common in ChinaCommon overseasBasic#context#tool-calling#coding🔒 Unlock this chapter to see the answer keys.
