Dayward AI

Interview Bank

328 questions total; 4 shown with current filters.

Tag
136 more tags
#api-design6#operations6#sse6#deployment5#message-bus5#tool-calling5#agent-loop4#behavioral4#error-handling4#evaluation4#framework-design4#mcp4#concurrency3#context-engineering3#interview-prep3#langgraph3#llm-basics3#model-routing3#orchestration3#prompt-injection3#protocol3#redis-streams3#scalability3#scheduling3#agent-design2#auth2#checkpointing2#communication2#cost-control2#database2#debugging2#interview-process2#latency2#long-term-memory2#memory2#ordering2#prompt-engineering2#rate-limiting2#react2#resume2#retrieval2#sharding2#state-machine2#state-management2#tool-design2#tool-permissions2#trade-offs2#ux2#agent-basics1#agent-quality1#async1#atomicity1#cancellation1#capacity-planning1#career1#chunking1#compression1#configuration1#consistent-hashing1#context1#context-compression1#context-management1#correctness1#customer-support1#data-modeling1#deliberate-practice1#docker1#documentation1#engineering-tradeoffs1#escalation1#event-driven1#fallback1#fan-out1#fencing-token1#forking1#framework-selection1#frontend1#global-market1#hybrid-search1#interrupt-merge1#isolation1#json-parsing1#jwt1#knowledge-organization1#lease1#least-privilege1#llm-as-judge1#loop-guard1#mobile1#multi-tenancy1#nodejs1#performance1#persistence1#pgvector1#portfolio1#prioritization1#proactive-messaging1#product-engineering1#project-storytelling1#prompt1#provider-abstraction1#quiet-hours1#ranking1#recall1#reconnect1#redis1#reflection1#replay1#reporting1#rerank1#retrieval-quality1#retry1#retry-semantics1#rrf1#sampling1#sandboxing1#schema-design1#secrets-management1#self-assessment1#self-introduction1#self-presentation1#service-architecture1#session-management1#split-brain1#star1#stateless1#storytelling1#structured-output1#system-prompt1#testing1#timezone1#tool-execution1#tools1#tracing1#transport1#vector-database1

From Frontend Engineer to Agent Engineer in 30 Days

D16 Dynamic Routing With a Supervisor: Structured-Output Routing, Override, routingReason

  • How is the routing decision usually implemented in a supervisor pattern? What should that node do, and what should it not do?Supervisor 模式里的路由决策一般怎么实现?请说说这个节点该做什么、不该做什么。
    Common in ChinaCommon overseasBasic#multi-agent#routing#langgraph

    How to reason about it · think before answering

    1. This is a warm-up question, and warm-ups are where people lose points by restating the prompt: an agent decides who goes next. The discriminator is the second half — can you state the node's responsibility boundary?
    2. Start with the mechanics: the supervisor is an ordinary node. It reads state, makes one model call, and writes exactly two fields — the route and the reason for it. The actual branching happens on the conditional edge after it, whose selector function maps the route to the next node name.
    3. Then draw the boundary, which is where the points are: the supervisor never answers the user, never calls business tools, and produces no side effects. It only takes a multiple-choice test, so it can run on a cheaper small model with a short input.
    4. One boundary people miss: do not call the model inside the selector function. The judgement was already made and stored in state; the selector only translates. Calling a model there makes the same state jump to different nodes across runs, which destroys reproducibility and breaks checkpoint replay and evaluation later.
    5. Close with one-at-a-time: a supervisor answers who takes this, not how to split a task and who reviews the output. That second problem belongs to planner-executor-critic. Drawing that line yourself signals you have seen a real system.
    6. Expect: where does the list of sub-agents live, and how many places change when you add one? Answer that the list should be a single source of truth — the enum, the schema, and the edge mapping all derive from it, so adding an agent is one edit and everything else fails at compile time.

    分析过程 · 先想清楚再作答

    1. 这是一道送分题,但送分题最容易答成「让一个 Agent 决定下一步找谁」这种复述题面的话。区分度在后半句:你能不能说清这个节点的职责边界。
    2. 先给机械原理:Supervisor 是图里的一个普通节点,它读状态、调一次模型、只写两个字段——交给谁(route)和为什么这么判(routingReason);真正的分叉发生在它后面那条条件边上,边上挂一个选择函数,把 route 翻译成下一个节点名。
    3. 再划边界,这是拿分的地方:Supervisor 不回答用户的问题、不调业务工具、不产生副作用。它只做选择题,所以可以配一个更便宜的小模型,输入通常只有系统提示词加最后一两句话。
    4. 还有一条边界更容易被忽略:**选择函数里不要再调模型**。判断已经在 Supervisor 节点里做完并落进状态了,选择函数只做翻译。把模型调用塞进选择函数,同一份状态每次可能跳到不同的节点,图就不可复现,后面做检查点重放和评估都会失真。
    5. 最后补一句「一次只派一个人」:Supervisor 解决的是「交给谁」,不解决「一件事要拆成几件、还得有人验收」。后者是 Planner-Executor-Critic 的活。能主动划出这条线,面试官会认为你见过真实系统的边界。
    6. 可以预期的追问:那三个子 Agent 的名单从哪来、加一个新的要改几处?答案是名单应该是单一真相来源——枚举定义、schema、条件边的映射表都从它生成,加一个子 Agent 只改一处,其余地方编译期报错提醒你。

    Key points

    • The supervisor is an ordinary node: read state, one model call, write only the route and the routing reason
    • Branching lives on the conditional edge after it — a selector maps the route to a node name, and the mapping table must be exhaustive
    • Boundary: it never answers the user, calls no business tools, has no side effects, so it can run on a cheaper small model
    • Never call a model inside the selector, or the same state jumps to different nodes across runs and replay and evaluation both break
    • A supervisor dispatches one agent at a time and only answers who takes this; splitting and reviewing belong to planner-executor-critic

    答题要点

    • Supervisor 是图里的一个普通节点:读状态、调一次模型、只写 route 与 routingReason 两个字段
    • 真正的分叉在它后面的条件边上:选择函数把 route 翻译成下一个节点名,映射表要写全
    • 职责边界:不回答用户、不调业务工具、不产生副作用,因此可以单独配一个更便宜的小模型
    • 选择函数里不能调模型,否则同一份状态每次跳的节点不同,图不可复现,检查点重放与评估都会失真
    • Supervisor 一次只派一个人,只解决「交给谁」;拆任务与验收是 Planner-Executor-Critic 的职责
  • Why use structured output rather than natural language for routing? What exactly goes wrong with free text?为什么要让模型输出 structured output 而不是自然语言来做路由?自然语言到底差在哪?
    Common in ChinaCommon overseasIntermediate#structured-output#routing#reliability

    How to reason about it · think before answering

    1. The trap is answering structured output is cleaner and easier to parse. Those are adjectives, not reasons. The interviewer wants a concrete failure you have actually debugged.
    2. Lead with the sharpest point: free-text routing fails silently. The model replies I think the order desk should look at this — it judged correctly, but it spoke prose, not an id. Your regex misses, you fall through to the default, and the log shows only smalltalk. A correct model with a broken parser looks exactly like a wrong model, so you spend two days tuning a prompt that was never the problem.
    3. Then list three holes and map each to what structured output fixes: wording drifts across versions so regexes never catch up; there is no confidence signal, so you cannot tell certainty from guessing; and an invented route name only explodes at runtime, whereas an enum is a gate that exists before the request is even sent.
    4. Explain the mechanism rather than stopping at zod is nicer: send the schema in the request (response_format with a json_schema), so decoding is constrained by the enum, then validate the response with the same declaration. One declaration used twice means request and validation cannot drift apart.
    5. The counterintuitive point that separates candidates: structured output does not remove the need to validate. Not every gateway or model enforces the schema strictly, and a fallback model may not at all. Your parse function should return something-to-be-validated, not an already-typed decision.
    6. Expect: what if the model does not support json_schema? Fall back to few-shot plus a strict prompt plus your own validation. The real gate was never the model's discipline; it is your parsing layer.

    分析过程 · 先想清楚再作答

    1. 这题最容易答成「结构化更规范、更好解析」——这是形容词,不是理由。面试官想听的是一个具体的失败场景,最好是你真的调过的那种。
    2. 把最锋利的一刀先亮出来:**自然语言路由的失败是静默的**。模型回「我觉得这个可以让查订单的同事看一下」,它其实判对了,但说的是人话不是 id,正则匹配不上就落进兜底,日志里只留下一个 smalltalk。模型是对的、解析是错的,而它和「模型判错了」在日志里长得一模一样。你会去调提示词,调两天才发现问题在那三行正则。
    3. 然后给三个漏洞,一条一条对上结构化输出解决了什么:输出会漂移(今天回「订单查询」明天回「查订单」,正则永远追不上,模型小版本升级你就掉准确率);没有置信度(自然语言里没有「我有多大把握」这个信息,你没法区分它很确定还是在猜);拼错或自造的路由名要到运行时才炸(枚举是一道编译期就存在的闸门)。
    4. 接着说清机制,别停在「用 zod 更规范」:把 schema 发进请求(response_format 里的 json_schema),模型的解码过程被枚举约束;回来之后**用同一份声明再校验一遍**。一份声明两用,请求与校验不会漂移。
    5. 关键的反直觉点,答到这里就拉开差距了:**结构化输出不等于不用校验**。不是所有网关、所有模型都严格执行 schema,降级到备用模型时更说不准。所以解析函数的返回类型应该是「一段待校验的东西」,而不是「已经是 RouteDecision」。
    6. 可以预期的追问:那不支持 json_schema 的模型怎么办?答案是退回「few-shot 加严格提示词加自己校验」,闸门仍然在你的枚举校验那一步——真正兜底的从来不是模型的自觉,是你的解析层。

    Key points

    • Free-text routing fails silently: a correct judgement in prose misses your regex and falls through, looking identical to a wrong judgement in the logs
    • Three holes: wording drifts, there is no confidence signal, and invented route names only fail at runtime
    • One declaration used twice: the schema constrains decoding in the request and validates the response, so the two cannot drift
    • An enum is a gate that exists before the call, turning a misspelled route from an incident into a parse failure
    • Structured output does not remove validation — gateways and fallback models may not enforce the schema, so parsing must return an unvalidated value

    答题要点

    • 自然语言路由的失败是静默的:模型判对了但说的是人话,正则匹配不上就落兜底,和判错在日志里完全一样
    • 三个漏洞:措辞会漂移(正则追不上)、没有置信度(分不清确定与猜)、自造的路由名要到运行时才炸
    • 机制是一份声明两用:schema 随请求发出去约束解码,回来后用同一份声明校验,请求与校验不会漂移
    • 枚举是编译期就存在的闸门,把「拼错的路由名」从线上事故降级成一次解析失败
    • 结构化输出不等于不用校验:网关和降级模型未必严格执行 schema,解析函数的返回类型应该是「待校验」而不是「已经是」
  • How should the system handle an uncertain or wrong routing decision, and how do you pick the threshold?路由不确定或者路由错误时,系统应该怎么兜底?阈值该怎么定?
    Common in ChinaCommon overseasDeep dive#routing#fallback#reliability

    How to reason about it · think before answering

    1. The hinge is that uncertain and wrong are two different failures. Most candidates answer retry or escalate to a human, collapsing both into one. The discriminator is stating a value judgement before giving a policy.
    2. The claim first: routing to the wrong sub-agent is far worse than failing to route. A failure announces itself and lets you ask a clarifying question. A wrong route does not — the receiving agent has no idea it got the wrong job and will produce a confident, well-formatted, wrong answer that the user will act on. A confident wrong answer costs a hundred times more than I did not catch that.
    3. Then give a concrete policy with real numbers: if the model's confidence is below 0.6, or the route name is not in the allowed list, fall back to the small-talk agent and stamp the reason with a fallback prefix plus a cause code (low confidence, unknown route, invalid shape). The fallback agent's job is to ask for the one missing detail rather than guess — falling back means handing the uncertainty back to the user.
    4. The threshold question is the real test, so do not recite a number: it depends on which error is more expensive. In customer support one extra question costs mild annoyance while a misroute can become a wrong refund promise, so stay conservative. For an internal tool the extra question is the bigger cost, so lower it. Then give a method: sweep thresholds over a golden set, plot misroute rate against clarification rate, and pick the knee.
    5. Name the trap: the confidence number is self-reported and is not a probability. Nine tenths does not mean nine in ten are right. It is a usable ranking signal within one model and one prompt — good as a gate, useless for expected-value math. Real accuracy comes from offline evaluation.
    6. Expect: does falling back just hide the problem? Not if you record cause codes. Group a week of fallbacks by cause and you can see exactly which intent the routing prompt fails to describe. The fallback stops the bleeding; the cause code is what fixes it.

    分析过程 · 先想清楚再作答

    1. 题眼在「不确定」和「错误」是两件事。多数人只答重试或人工接管,那是把两个问题揉成一个。区分度在于你能不能先给出一条价值判断,再给策略。
    2. 先立论:**路由到错的子 Agent,比路由失败糟糕得多**。失败你至少知道自己失败了,可以追问一句;错了,接手的子 Agent 完全不知道自己接错了活,会用笃定的语气给出一个格式完整的错误答案,用户不会怀疑,会照着去操作。一个自信的错误答案比一句「我没听清」贵一百倍。
    3. 再给可执行的策略,数字要具体:模型给的置信度低于 0.6,或者路由名不在合法名单里,一律落到兜底的 smalltalk,并在 routingReason 里打上 fallback 前缀加原因码(低置信度、未知路由、结构非法各一种)。兜底那位的人设是「信息不足先追问一句缺的关键信息,不要猜」——兜底的本质是把不确定性还给用户。
    4. 阈值怎么定这一问是重点,别背数字:**取决于两类错误哪一类更贵**。客服场景里多问一句只是用户小小的不耐烦,派错可能变成一条错误的退款承诺,所以宁可保守取 0.6;内部工具型 Agent 里多问一句反而更烦人,阈值就该放低。再补一句可落地的定法:拿标准样本集扫一遍,画出不同阈值下的误派率与追问率,选拐点。
    5. 必须点破的一个坑:**置信度是模型自己报的,它不是概率**。模型说 0.9 不代表有九成对。它只是同一模型、同一提示词下相对可用的排序信号,只能当闸门用,不能拿去算期望值。真正的准确率要靠离线评估去量。
    6. 可以预期的追问:兜底会不会把问题掩盖掉?答案是不会,前提是你记了原因码——把一周内落进兜底的请求按原因分组,能直接看出分诊提示词缺了哪一类描述。兜底是止血,原因码才是治本的输入。

    Key points

    • Separate the two: a failed route can ask a clarifying question, a wrong route produces a confident wrong answer, and the second is far costlier
    • Policy: confidence below 0.6 or a route outside the allowed list falls back to small talk, stamped with a fallback prefix and a cause code
    • Falling back is not picking someone at random — the fallback agent asks for the missing detail instead of guessing
    • The threshold depends on which error costs more; sweep it over a golden set and pick the knee between misroutes and clarifications
    • Self-reported confidence is not a probability — use it as a gate only, and measure real accuracy offline
    • Record cause codes on every fallback; grouping them shows which intent the routing prompt fails to describe

    答题要点

    • 先分清两件事:路由失败可以追问,路由错误会让子 Agent 自信地给出错误答案,后者贵得多
    • 策略:置信度低于 0.6 或路由名不在名单里,一律落兜底的 smalltalk,并在 routingReason 打上 fallback 前缀加原因码
    • 兜底不是随便找个人接,而是把不确定性还给用户——兜底那位应当追问缺失的关键信息而不是猜
    • 阈值取决于两类错误哪一类更贵:客服场景多问一句便宜、派错很贵,所以保守;定法是拿标准样本集扫阈值找拐点
    • 置信度是模型自报的,不是概率,只能当闸门用;真正的准确率要靠离线评估量
    • 落兜底时记原因码,按原因分组就能看出分诊提示词缺了哪一类描述
  • What is a field like routingReason actually worth in production? Is it just logging?routingReason 这类调试信息在生产系统里有什么价值?只是打日志而已吗?
    Common in ChinaCommon overseasIntermediate#observability#routing#debugging

    How to reason about it · think before answering

    1. This looks like a throwaway question but it screens for whether you have ever been on call. Anyone who stops at it helps with debugging has not.
    2. Start with the fact you cannot design around: the routing decision is made by a model, and models are not reproducible. The same sentence may be judged differently next time, so you cannot re-run to see what it was thinking. The reason must be captured at decision time or it is gone forever — that is what turns this field from a log line into the only audit evidence you have.
    3. Then give three concrete uses. One, it separates a wrong model judgement from a parsing or fallback problem, provided the prefix carries a cause code. Two, it is raw material for the next prompt revision: group a week of fallbacks by cause and the missing intent descriptions jump out. Three, it feeds offline evaluation — a golden set should score routing accuracy, not just the final answer, and that is only scorable if the decision and its reason were recorded.
    4. Mention the shape: a structured prefix wrapping a human sentence. The prefix (fallback plus cause, override plus target) is what you aggregate on; the sentence is what you read for one specific case. Making the whole field prose puts you right back in the failure mode this chapter argues against.
    5. Add the detail people skip: neither a fallback nor a human override should erase the model's original judgement — carry it into the reason. Otherwise nobody can later tell whether the model got it wrong or a human redirected it. Twenty extra characters save an afternoon of archaeology.
    6. Expect: do these fields create privacy or cost problems? Yes, so record the basis for the decision rather than the user's raw text, cap the length, and reuse the same run identifier as your tracing instead of inventing a parallel one.

    分析过程 · 先想清楚再作答

    1. 这题看着像水题,其实在筛「有没有真的排查过线上问题」。答「方便调试」就结束的人,基本没值过班。
    2. 先给一条不可回避的事实:**路由决策是模型做的,而模型不可复现**。同一句话下次未必给同样的判断,你没法重跑一遍去看「当时是怎么想的」。所以理由必须在当时就写下来,否则那次判断永远丢了。这一条把 routingReason 从「日志」抬到了「唯一的审计证据」。
    3. 然后给三个具体用途,每个都要能落地:一是把「模型判错了」和「解析或兜底出错了」分开,前缀写成 fallback 加原因码,一眼就能分辨;二是攒下一版提示词的素材,把一周内落进兜底的请求按原因分组,会看到集中的几类意图缺描述;三是它是离线评估的输入——标准样本集要评的不只是最终回答,还有分诊准不准,而这件事只有当时记了判断和理由才评得了。
    4. 写法上有个细节值得主动说:**结构化的壳加自然语言的芯**。前缀(fallback 加原因、override 加目标)用来聚合统计,后面那句人话用来看具体这一单。整条都写成自然语言,就退回成本章批判的那种东西了。
    5. 再补一条容易被忽略的:兜底和人工改派都不要擦掉模型的原判,原样拼进理由里。否则一周后没人说得清这一单是模型判错了还是本来就被人改过——多写二十个字符,省掉一次翻遍代码的排查。
    6. 可以预期的追问:这些字段会不会带来隐私或成本问题?答案是会,所以理由里只写判断依据不写用户原文,长度设上限(比如 120 字),并且和链路追踪共用同一个 run 标识,别另起一套。

    Key points

    • The decision comes from a model and is not reproducible, so the reason must be captured at decision time — it is the only audit evidence you get
    • Use one: it separates a wrong model judgement from a parsing or fallback failure, via a cause code in the prefix
    • Use two: grouping a week of fallbacks by cause tells you exactly what the next routing prompt is missing
    • Use three: it feeds offline evaluation, since routing accuracy can only be scored if the decision and reason were recorded
    • Shape it as a structured prefix around a human sentence: aggregate on the prefix, read the sentence for one case
    • Keep the model's original judgement through fallbacks and overrides; store the basis rather than raw user text, cap the length, and reuse the tracing run id

    答题要点

    • 路由决策由模型做出且不可复现,理由必须在当时写下来,否则那次判断永远丢了——它是唯一的审计证据
    • 用途一:把「模型判错」和「解析或兜底出错」分开,靠 fallback 加原因码一眼分辨
    • 用途二:把一周内落进兜底的请求按原因分组,直接得到下一版分诊提示词该补什么
    • 用途三:它是离线评估的输入,分诊准确率这个指标只有记了当时的判断与理由才评得了
    • 写法是结构化的壳加自然语言的芯:前缀用于聚合统计,人话用于看具体这一单
    • 兜底与人工改派都要保留模型原判;理由只写判断依据不写用户原文,长度设上限,并复用链路追踪的 run 标识