Dayward AI

Interview Bank

328 questions total; 2 shown with current filters.

Tag
235 more tags
#idempotency5#streaming5#structured-output5#chunking4#deployment4#distributed-systems4#rag4#system-prompt4#tool-calling4#client3#embeddings3#failure-modes3#ingestion3#mcp3#message-bus3#operations3#progressive-disclosure3#ranking3#timeline3#agent-loop2#agentic-rag2#agents-sdk2#caching2#citations2#code-review2#communication2#concurrency2#consistency2#context2#context-engineering2#context-rot2#cost-control2#data-modeling2#grounding2#hybrid-search2#langgraph2#latency2#model-migration2#model-routing2#multi-agent2#ordering2#pipeline-design2#prompt-basics2#prompt-engineering2#protocol2#rate-limiting2#react2#redis-streams2#responses-api2#retrieval2#retrieval-quality2#routing2#runtime2#sse2#state-management2#subagents2#system-design2#tool-design2#tooling2#tracing2#trade-offs2#transport2#vector-database2#versioning2#workflow2#abstention1#access-control1#agent-design1#agent-quality1#altitude1#approvals1#async1#async-task1#atomicity1#attention-budget1#auth1#av-sync1#behavioral1#bm251#candidate-selection1#capacity-planning1#chain-of-thought1#checkpointing1#ci1#citation-verification1#claude-code1#cli-design1#cloud1#compaction1#compression1#content-hash1#context-compression1#context-window1#contextual-retrieval1#cost-optimization1#cross-model1#dag1#data-quality1#database1#decision-making1#decomposition1#degradation1#deliberate-practice1#design1#diagnostics1#dimensions1#distribution1#docker1#documentation1#engineering-judgement1#engineering-tradeoffs1#eval1#event-driven1#fallback1#fan-out1#ffmpeg1#forking1#four-elements1#framework-design1#framework-selection1#golden-set1#hallucination1#handoffs1#headless1#hnsw1#hybrid1#hyde1#image-generation1#incremental-recompute1#incremental-sync1#index-maintenance1#index-routing1#indexing1#information-retrieval1#instruction-hierarchy1#intent-routing1#interrupt-merge1#interview-prep1#invalidation1#isolation1#ivfflat1#just-in-time1#knowledge-organization1#lease1#llm-as-judge1#llm-output-quality1#long-context1#loop-guard1#media-pipeline1#metadata1#metrics1#mobile1#model-selection1#multi-tenancy1#multimodal1#nodejs1#orchestration1#pagination1#parent-child1#pdf-parsing1#performance1#permissions1#persistence1#pgvector1#pipeline-reliability1#portfolio1#prioritization1#production-readiness1#prompt-assembly1#prompt-caching1#prompt-injection1#prompt-limits1#prompt-techniques1#prompt-template1#prompt-versioning1#provider-abstraction1#quality-check1#quantization1#query-transformation1#quiet-hours1#rank-fusion1#reasoning1#recall1#redis1#reflection1#refusal1#reporting1#reproducibility1#rerank1#retrieval-failure1#retrieval-metrics1#retry1#retry-semantics1#retry-strategy1#review1#rollback1#rrf1#sandbox1#sandboxing1#scalability1#scheduling1#schema-design1#scoping1#scripts1#secrets-management1#self-assessment1#self-presentation1#self-reflection1#service-architecture1#session-management1#sessions1#sharding1#skill-authoring1#skill-description1#skills1#spec1#state-machine1#stateless1#stopping-criteria1#subtitles1#task-graph1#team-governance1#testing1#tool-budget1#tool-execution1#tool-naming1#tools1#tts1#tuning1#ux1#validation1#vector-index1#verification1#workflow-engine1#xml-tags1

MCP in 7 Days: Wire Tools Into Any Agent

D4 Remote MCP: the Streamable HTTP Binding, the Stateless Model and Request Metadata, OAuth 2.1 Authorization, Container Deployment

  • The 2026-07-28 revision removed protocol-level sessions. How should a remote server that needs cross-call state — a shopping cart, a database transaction — be designed?2026-07-28 去掉了协议级会话。那一个需要跨调用保存状态的远程服务端——比如购物车、数据库事务——应该怎么设计?
    Common in ChinaCommon overseasIntermediate#statelessness#api-design

    How to reason about it · think before answering

    1. The screen is whether you treat statelessness as a design constraint. Answering 'use Mcp-Session-Id' fails immediately — that header was removed. So does 'keep it in server memory keyed by connection', since clients are not required to reuse connections.
    2. Give the structure first: state must travel with the client, and the server trusts only what arrives in the request. Two concrete shapes — a server-minted explicit handle returned by a creation tool and passed back as an ordinary tool argument, or a signed opaque blob like the requestState used by multi round-trip requests.
    3. The difference is who stores the data. A handle is just a primary key into server-side storage; a requestState encodes the context itself, so the server stores nothing. Handles suit long-lived business objects, requestState suits continuing a single interaction.
    4. Conclusion: either way the server keeps nothing per client in memory, so any replica can serve any request and scaling needs no sticky routing — which is exactly what the change was buying.
    5. Volunteer the security half: a handle is a name, not a credential. Generate it from a secure random source, bind it server-side to the authenticated principal (key storage as user id plus handle), expire it, and re-authorize on every call — the spec says possession of a handle must not be treated as authentication. requestState passes through the client, so it is attacker-controlled input and must be integrity-protected with HMAC or AEAD, carrying the principal, an originating-request identifier, and a short expiry.
    6. Likely follow-up: what about requestState across replicas? Share the signing key; it is still stateless because the state lives with the client and replicas only verify. A second follow-up is single use — signing bounds the replay window but does not guarantee one-time consumption, which needs a server-side redemption record.

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

    1. 这题在筛「有没有把无状态当成设计约束」。答「用 Mcp-Session-Id 头」的当场出局,那个头这一版已经删了;答「存在服务端内存里按连接查」的同样出局,因为客户端根本不保证复用连接。
    2. 先给结构:状态必须由客户端携带,服务端只认请求里带来的东西。落地成两种形态——一是服务端铸造的显式句柄,创建工具返回一个 id,后续调用把它当普通工具参数传回来;二是签过名的不透明状态串,比如多轮请求里的 requestState,服务端把上下文签进去,重试时原样收回。
    3. 两者的差别在于「谁存数据」:句柄背后的购物车内容还是存在服务端的库里,句柄只是主键;requestState 是把上下文本身编码进字符串,服务端零存储。前者适合长期存在的业务对象,后者适合一次交互内的续接。
    4. 结论:不管哪种,服务端内存里都不为某个客户端留东西,所以任何副本都能处理任何请求,扩容不需要粘性路由——这正是这次改动想换来的东西。
    5. 安全是必须主动补的一句:句柄是名字不是凭证。要用安全随机数生成、绑定到已认证的主体(按 user_id 加 handle 做键)、设过期时间,并且每次调用重新校验调用者身份。规范明确写了服务端不得把持有句柄当成身份认证。requestState 同理,它经客户端转手,是攻击者可控输入,必须 HMAC 或 AEAD 验签,并把主体、原请求标识、短过期签进去。
    6. 可预期的追问:多副本时 requestState 怎么办?答案是所有副本共享签名密钥即可,这仍然是无状态的——状态在客户端手里,副本只负责验签。追问二可能是「怎么保证一次性」,答案是签名只能缩小重放窗口,真要单次消费得自己在服务端加一层消费记录。

    Key points

    • State travels with the client: the server mints an explicit handle that later calls pass back as an ordinary tool argument
    • Within one interaction, a signed opaque blob works with zero server storage; replicas just share the signing key
    • A handle is not a credential: securely random, bound to the authenticated principal, expiring, re-authorized on every call
    • The payoff is that any replica serves any request, so scaling needs no sticky routing and retries are cheap

    答题要点

    • 状态必须由客户端携带:服务端铸造显式句柄,作为普通工具参数在后续调用里传回
    • 一次交互内的续接可以用签名的不透明状态串,服务端零存储,多副本共享签名密钥即可
    • 句柄不是凭证:安全随机生成、绑定已认证主体、设过期,每次调用重新鉴权
    • 收益是任何副本能处理任何请求,扩容不需要粘性路由,重启后重发即可

D6 Security and Governance: Prompt Injection in Tool Descriptions, the Confused Deputy, Least Privilege, Audit Logs, and a Tool Allowlist

  • Since the protocol is stateless, a server that needs state mints a handle for the client to carry back. What attack surface does that create, and how do you close it?2026-07-28 之后协议是无状态的,服务端要保存状态就得铸一个句柄让客户端带回来。这会带来什么新的攻击面?怎么防?
    Common in ChinaCommon overseasIntermediate#statelessness#security

    How to reason about it · think before answering

    1. This checks whether you re-derived the threat model after the mechanism changed. Everyone knows session hijacking from the previous revision; sessions are gone now, so many assume the problem left with them. It only got renamed to state handle hijacking.
    2. Describe the attack in four steps: the server mints a handle for an authenticated user and returns it in a tool result; the attacker obtains or guesses it; the attacker sends it back as an ordinary tool argument; the server never checks whether the handle belongs to the caller and operates on the original user's state.
    3. Unpack 'obtains or guesses', because it decides where the defense goes. Guessing means the handle is predictable, such as a sequential id, a timestamp, or too little entropy. Obtaining has many paths: the handle appears in a tool result, so it enters the model context, the logs, possibly another server's view, and it can be coaxed out by a prompt injection. The assumption that handles stay secret is not available to you.
    4. Answer the defenses in the spec's tiers. Mandatory: servers implementing authorization MUST verify all inbound requests and MUST NOT treat possession of a handle as authentication. That is the crux, a handle is a name, not a credential. Recommended: generate handles from a secure random source, avoid predictable or sequential identifiers, and expire them. The most effective recommendation is binding: key server-side storage as user id plus handle, with the user id derived from the verified token rather than supplied by the client, and reject a handle presented by any other principal, so guessing it still buys nothing.
    5. Volunteer that requestState belongs to the same family: a server-signed opaque blob carried back through the client in multi round-trip requests, which the spec requires you to treat as attacker-controlled input, protect with HMAC or AEAD, verify with a constant-time comparison, and bind to the authenticated principal, an originating-request identifier, and a short expiry, covering cross-user, cross-request, and timeout replay.
    6. One-line conclusion: statelessness did not remove state, it moved it into the client's hands, so 'who can present it' and 'who is allowed to use it' must be judged separately.
    7. Likely follow-ups: does signing guarantee single use? No, it only bounds the replay window; true one-time consumption needs a server-side redemption record. And what about replicas? The data behind a handle already lives in shared storage, and requestState only needs a shared signing key, which is still stateless because nothing per client sits in a replica's memory.

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

    1. 这题在考「换了机制之后有没有重新想过威胁模型」。上一版的会话劫持大家都熟,这一版会话没了,很多人就默认问题跟着消失了——其实只是换了个名字叫状态句柄劫持。
    2. 先描述攻击,四步很短:服务端为已认证用户铸一个句柄并放在工具结果里返回;攻击者拿到或猜到这个句柄;攻击者把它当成普通工具参数发过来;服务端没检查这个句柄属不属于调用者,于是操作了原用户的状态。
    3. 拆「拿到或猜到」这一层很关键,因为它决定了防线该架在哪。猜到,说明句柄可预测(自增 id、时间戳、短随机数);拿到,路径就多了——它出现在工具结果里,而工具结果会进模型上下文、会进日志、可能被另一个服务端看到,也可能被一次提示注入骗着吐出来。所以「句柄不会泄漏」这个假设不能要。
    4. 防线按规范分三层答。硬性的:实现了授权的服务端**必须**校验所有入站请求,并且**绝不能**把持有句柄当成身份认证——这是整题的题眼,句柄是名字不是凭证。应当层:用安全随机数生成,避免可预测或连续的标识,并设过期。最管用的一层也是应当:**在服务端把句柄绑定到已认证的主体**,比如存储的键做成「用户 id 加句柄」,用户 id 从校验过的令牌里取而不是客户端传,别的主体拿着同一个句柄来就查不到。这样即使猜中也冒充不了别人。
    5. 然后主动把 requestState 归到同一类:它是多轮请求里由服务端签发、经客户端转手带回的不透明状态,规范要求把它当成攻击者可控输入,用 HMAC 或 AEAD 做完整性保护、验签用定长比较,并把认证主体、原请求标识、短过期一起签进去,分别挡跨用户、跨请求和超时三种重放。
    6. 结论一句话:无状态没有消灭状态,只是把状态挪到了客户端手里,于是「谁能出示它」和「谁有权用它」必须被分开对待。
    7. 可预期的追问一:签名能不能保证一次性?不能,签名只缩小重放窗口,真要单次消费得在服务端加一层消费记录。追问二:多副本部署怎么办?句柄背后的数据本来就在共享存储里,requestState 只需要各副本共享签名密钥——这仍然是无状态的,因为服务端内存里没有为某个客户端留东西。

    Key points

    • The new surface is state handle hijacking: anyone who obtains or guesses a handle can act on another user's state
    • Handles surface in tool results, model context and logs, so secrecy is not a safe assumption
    • Mandatory: verify every inbound request and never treat possession of a handle as authentication
    • Use secure randomness, expiry, and server-side binding keyed by principal plus handle; requestState needs signing bound to principal and a short expiry

    答题要点

    • 新攻击面叫状态句柄劫持:拿到或猜到句柄的人可以操作别人的状态
    • 句柄会出现在工具结果、上下文与日志里,不能假设它不泄漏
    • 硬性要求:必须校验所有入站请求,绝不能把持有句柄当成身份认证
    • 做法:安全随机、设过期、按「主体加句柄」在服务端绑定;requestState 同理,验签并签进主体与短过期