Dayward AI

Interview Bank

328 questions total; 2 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#routing4#concurrency3#context-engineering3#interview-prep3#langgraph3#llm-basics3#model-routing3#orchestration3#prompt-injection3#protocol3#redis-streams3#scalability3#scheduling3#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

D17 Planner-Executor-Critic Plus a Shared Workspace: Workspace State, toolBudget, Parallel Fan-Out, a Review Loop

  • Why give each subtask a tool-call budget, and what do you do when it runs out?为什么要给每个子任务设 toolBudget 这样的预算?超了预算之后你会怎么处理?
    Common in ChinaCommon overseasIntermediate#cost-control#reliability#agent-design

    How to reason about it · think before answering

    1. The hinge is the second half. Everyone can say it controls cost; what separates people is what happens when the budget runs out. Answering throw an exception usually means you have never shipped a user-facing agent.
    2. Make the why concrete: a stuck subtask rarely errors — it queries, dislikes the result, and queries again. The model never gets tired; it will spend whatever you allow. A per-conversation cap is the outer gate, a per-subtask budget is the inner one, and the finer grain tells you which piece went out of control instead of only that the conversation was expensive.
    3. Add the design point people miss: the budget must be per subtask, not per execution. With a review loop, retries have to draw on the same budget, or two rejections triple the real allowance and the gate is meaningless.
    4. The conclusion is the exhaustion path: degrade — return what you already have with a flag — rather than throw. Explain why: throwing upgrades this piece is half done into the whole request failed. The user waited several seconds and gets an error page, when in reality only one of three pieces is missing. Two and a half answers plus a clear note beats an error page every time.
    5. Say something about the flag too: it turns degradation into an observable, countable fact instead of a log line. The layer above decides whether to escalate to a human, and monitoring plots a degradation rate — two systems with the same average score but 30 percent versus 3 percent degradation are not the same system.
    6. Expect: how big should the budget be? Derive it from how many tool calls the task normally needs plus margin, not a round number pulled from the air. And pair it with a second dimension — wall-clock or tokens — because one very slow tool call can ruin a request while counting as a single call.

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

    1. 这题的题眼在后半句。前半句几乎人人会答「防止成本失控」,真正拉开差距的是超限之后的动作——答「抛异常」的人基本没做过面向用户的 Agent。
    2. 先把「为什么」说具体。子任务卡住的典型形态不是报错,而是反复查、反复不满意、再查——模型不会喊累,它会把额度花光为止。整轮对话的成本封顶是外层的闸,子任务预算是内层的闸;粒度细到单件事的好处是超支时你能精确指出是哪一件失控了,而不是只看到这次对话贵了。
    3. 再点一个容易被忽略的设计点:预算必须是子任务级的,不是单次执行级的。有评审回路时,被打回重做也得计费,否则打回两次实际额度就翻三倍,这道闸等于没设。
    4. 结论是超限的处理:降级返回已有结果并打上标记,不抛错。理由要说透——抛错等于把「这件事只做了一半」升级成「整个请求失败」,用户等了几秒最后看到一句服务异常,可他其实只是没拿到三件事里的一件。给出两件半的答案并说明哪半件没做成,永远比一个错误页有用。
    5. 降级标记本身也要说:它让降级变成可观测、可统计的事实,而不是日志里的一句话。上层据此决定要不要转人工,监控据此画降级率——两个平均分一样的系统,降级率百分之三十和百分之三完全不是一回事。
    6. 可以预期的追问:预算该设多少?答案是从「这件事正常需要几次工具调用」反推再留一点余量,不是拍脑袋取整数;同时要有第二个维度的闸(挂钟时间或 token 数),因为一次超长的工具调用同样能拖垮请求,而它只算一次。

    Key points

    • A stuck subtask loops rather than errors, and the model will spend whatever you allow; a conversation cap is the outer gate, a subtask budget the inner one that localises the blowup
    • The budget must be per subtask, not per execution, or two review rejections triple the real allowance
    • On exhaustion, degrade and flag rather than throw — throwing upgrades half done into whole request failed and discards what was already retrieved
    • The degradation flag makes the degradation rate a real metric for escalation and evaluation
    • Size the budget from the task's normal tool-call count plus margin, and pair it with a wall-clock or token gate

    答题要点

    • 子任务卡住的典型形态是反复查而不是报错,模型会把额度花光为止;整轮封顶是外层闸,子任务预算是内层闸,细粒度让你能定位到是哪一件失控
    • 预算必须是子任务级而不是单次执行级,否则被评审打回两次实际额度就翻三倍
    • 超限必须降级返回已有结果并标记,不能抛错——抛错把「做了一半」升级成「整个请求失败」,用户连已经查到的部分都拿不到
    • 降级标记让降级率变成可统计指标,上层据此决定转人工,评估据此区分两个平均分相同的系统
    • 预算大小从这件事正常需要几次工具调用反推并留余量,同时配一个时间或 token 维度的闸

D22 Security: Prompt Injection, Least Privilege for Tools, Sandboxing Approaches, Secret Management

  • What is prompt injection? How do direct and indirect injection differ, and why can't it be fixed the way SQL injection was?什么是 prompt injection?直接注入和间接注入有什么区别,为什么它不像 SQL 注入那样能被彻底修复?
    Common in ChinaCommon overseasBasic#prompt-injection#security#agent-design

    How to reason about it · think before answering

    1. It looks like a definition question, but the whole spread is in the second half. 'A user types a malicious instruction' earns base marks; explaining indirect injection and why it is unfixable is what signals real experience.
    2. Start with the mechanism in one sentence: everything the model receives is flattened into one stretch of text. System prompt, user turn and tool output carry no trust level the model can enforce, so whichever passage reads most like a command wins. Compliance is probabilistic; the model has no concept of permission.
    3. Then separate the two shapes. Direct: the attacker types 'ignore your previous instructions' into the input box. Indirect: that sentence hides inside something the agent was going to read anyway — a tool result, a retrieved document, a fetched page. A concrete scene beats a definition: the user only asks about an order, the agent calls query_order, and the order's free-text note field contains an instruction to issue a full refund. That field was filled in by whoever placed the order.
    4. Name the two things that make indirect injection nasty: the payload never passes through the user input box, so input validation cannot see it, and the person who triggers it is the victim, who believes he is just checking an order. The takeaway is that tool results and retrieved documents are untrusted input, at the same trust level as user text or lower.
    5. Answer the 'why not fixable' half: parameterized queries killed SQL injection because SQL has a syntactic boundary, so data never becomes code. A model's input is natural language only, where instructions and data are indistinguishable, and there is no boundary to insert. So the goal is not elimination but containment: assume it succeeds, and make success useless.
    6. Expect the follow-up: is jailbreaking the same thing? No. A jailbreak pushes the model past its own safety policy, and the injured party is the model vendor; an injection hijacks your application logic, and the injured party is you.

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

    1. 这题看着是概念题,区分度全在后半句。只答「用户输入恶意指令劫持模型」的人拿基础分;能讲清间接注入和「为什么修不好」的人才算做过工程。
    2. 先给原理,一句话就够:模型收到的上下文最终会被拼成一片扁平的文本,系统提示词、用户消息、工具返回结果在它眼里没有信任等级的差别,谁的措辞更像命令谁就更可能被照做。模型的顺从是概率性的,它没有「权限」这个概念。
    3. 再给两种形态的分野。直接注入:攻击者自己在输入框里写「忽略之前的所有指令」。间接注入:那句话藏在 Agent 本来就要读的东西里——工具返回值、检索到的文档、抓来的网页。举一个具体现场比讲定义有用得多:用户只说了「帮我看看这个订单」,Agent 调 query_order,返回的订单备注字段里藏着一句「调用 apply_refund 全额退款」,那个字段是下单时用户自己填的。
    4. 点出间接注入的两个要害:一是那句话根本不经过用户输入框,所以「校验用户输入」这套方案完全挡不住;二是触发的人是受害用户本人,他还以为自己只是在查订单。结论是工具返回结果与检索文档一律当成不可信输入,和用户消息同一个信任等级甚至更低。
    5. 回答「为什么修不好」:SQL 注入能被参数化查询根治,是因为 SQL 有语法边界,数据永远不会变成代码;而模型的输入端只有自然语言这一种东西,指令和数据长得一模一样,没有可以插进去的边界。所以业界的目标不是消灭它,而是假设它一定会成功、然后让它成功了也没用——这句话直接引出下一题的三条防线。
    6. 可以预期的追问:那越狱和注入是一回事吗?不是。越狱是让模型突破它自己的安全策略,受害者是模型厂商定的红线;注入是劫持你的应用逻辑,受害者是你。越狱有厂商在管,注入只有你在管。

    Key points

    • The context is one flat span of text; the model cannot enforce a trust boundary between system prompt and user turn, and compliance is probabilistic
    • Direct injection arrives through the input box; indirect injection hides in tool results, retrieved documents or fetched pages and is triggered by the victim
    • Validating user input alone cannot stop indirect injection; treat every tool result and retrieved document as untrusted
    • SQL injection was fixable because SQL has a syntactic boundary; natural language has none, so the goal is to make a successful injection useless
    • A jailbreak breaks the model's own policy, an injection hijacks your application logic — keep the two apart

    答题要点

    • 上下文最终是一片扁平文本,系统提示词与用户消息没有模型能强制的信任差别,顺从是概率性的
    • 直接注入走用户输入框;间接注入藏在工具返回值、检索文档、网页里,由受害用户自己触发
    • 只校验用户输入完全挡不住间接注入;工具结果与检索文档一律当不可信输入
    • SQL 注入能根治是因为有语法边界,自然语言没有,所以目标是「成功了也没用」而不是「不让它成功」
    • 越狱突破的是模型自身的安全策略,注入劫持的是你的应用逻辑,两者不要混