Your loop exits whenever the assistant message contains no tool_use block but does contain text. In production, 6% of sessions end after the agent has explained what it is about to do but before it has done it. What is the correct control-flow rule?
正确 CTS 1.1:控制流绑定在 stop_reason 这个结构化字段上。检查 text 内容是 guide 点名的反模式——同一条消息可以既有 text 又有 tool_use。
Audit finds 9% of refunds were issued without a prior identity check, three of them on misidentified accounts. The system prompt already states verification is mandatory and includes four few-shot examples. What change most effectively addresses this?
D2 过度工程违反 P2D:分类器解决的是工具可用性,题干的问题是工具顺序;且需要标注数据与 ML 基础设施。
Q3D2
Users asking "why was I charged twice on invoice INV-4471" get routed to get_customer rather than lookup_invoice. Both descriptions are single sentences and both accept string identifiers. What is the most effective first step?
A customer asks about an order placed four years ago. lookup_order returns an empty result. The same empty shape is returned when the archive service is unreachable, so the agent tells the customer no such order exists — sometimes wrongly. What should the tool do?
A customer writes: "I've been transferred twice already. Put me through to a person." Their issue is a duplicate charge your agent could resolve in two tool calls. What should the agent do?
Policy caps agent-issued refunds. The interception hook blocks a $640 refund and returns a bare failure; the agent tells the customer it cannot complete the action and has nothing further to offer. What is missing?
An engineer asks the agent to "remove all deprecated payment-API usage" from a service it has never seen. Module boundaries are unknown, and early probing shows several call sites are reached through dynamically built handler maps. Which decomposition strategy fits?
After 35 turns your agent quotes a refund amount of "roughly $200" when the customer stated $214.60, and never acts on the customer's stated deadline. Older turns are progressively summarized. What should you change?
正确 DTS 5.1:把交易性事实抽成持久 case facts 块并置于摘要历史之外,从结构上保证它们不进入压缩通道。
After integrating shipping, loyalty, and warranty MCP servers, your single agent sees 21 tools. Selection accuracy falls and it sometimes calls warranty tools during billing conversations. All descriptions are detailed and distinct. What is the right structural change?
正确 DTS 2.3:工具过多(guide 举的正是 18 vs 4–5)降低选择可靠性;拿到专业外工具的 agent 倾向误用。控制手段在分配侧。
D3 治标不治本违反 P4C:候选仍是 21 个;关键词敏感的 system prompt 指令还可能反过来干扰工具选择(TS 2.1)。
Q10D1
The agent escalates a warranty dispute. The receiving human agent has no access to the transcript and currently receives only the customer's last message; handling averages 8 minutes, mostly re-investigation. What should the handoff contain?
Three MCP tools return timestamps as a Unix integer, an ISO 8601 string, and MM/DD/YYYY respectively. The agent misorders events and once told a customer their shipment predated their order. What mechanism fits?
Your support team wants a nine-step account-audit workflow available to everyone on the repo, invoked deliberately, whose several hundred lines of intermediate output must not crowd the main conversation. How should it be configured?
Findings arrive in inconsistent shapes: some name the file and line, some only the function; some propose a fix, some just describe the problem. Your prompt already describes the desired fields in prose. What is most effective?
A customer writes in visible frustration about a mis-delivered parcel, using strong language, but does not ask for a human. The fix is a straightforward address correction and re-ship that the agent can perform. What should it do?
Your agent calls lookup_order with identical arguments five times in one session before the cost guard stops it. Instrumentation shows every call executes successfully and returns within 300 ms. The loop appends the assistant message to messages, then issues the next request. What is the most likely root cause?
The coordinator's first synthesis pass returns a report that visibly under-covers one of the assigned subtopics — the section is two sentences long while others run several paragraphs. The system delivers it as final. Subagents all reported success. What is missing from the design?
Findings reach the synthesis agent as flat prose paragraphs. The final report's claims are accurate, but page numbers, document names, and source URLs are gone by the time synthesis runs. What should change upstream?
Your report_agent was given the full tool set "so it can fill gaps." Reviewers find it issues its own web searches mid-draft and includes claims that appear nowhere in the findings it was handed. What should change?
The search subagent's index times out intermittently; roughly 80% of those timeouts succeed on an immediate retry. Today every timeout is propagated to the coordinator, which restarts the whole research run. What is the correct design?
Your research system needs Jira integration so the coordinator can file follow-up tasks. A teammate proposes writing a custom MCP server for it. How should you evaluate the proposal?
Two subagents assigned "battery chemistry advances" and "cathode material research" return roughly half the same sources, while recycling economics and refining capacity — clearly in scope — appear nowhere. What is the fix?
D2 过度工程违反 P5D:牺牲可并行的两个独立任务把延迟翻倍,exclusion list 还会持续膨胀。
Q22D5
Your final report renders everything as uniform bullet lists: quarterly revenue figures, a narrative of a regulatory dispute, and a set of benchmark results all look identical. Readers say the financial section is hardest to use. What should synthesis do?
You add a fact_check_agent with a clear AgentDefinition and its own tools, and configure the coordinator to delegate verification to it. At runtime the coordinator never delegates; it answers verification questions itself, sometimes wrongly. What should you check first?
Your document subagent exposes one tool, analyze_document ("Analyzes a document and returns findings"). Callers use it to pull numeric data points, to summarize, and to check whether a claim is supported. Output shape varies unpredictably. What should you do?
Your coordinator prompt is a four-step script (search → analyze → synthesize → report). Simple factual queries take as long as deep research, and when an authoritative meta-analysis exists the system still scatters across secondary sources. What should change?
A report ships on time, but one whole dimension of the topic was never covered because a source database was unreachable for the entire run. The report reads as if coverage were complete. What should the synthesis output have included?
Your team has a shared codebase-analysis baseline and wants to evaluate two competing synthesis strategies against it, comparing results side by side without one contaminating the other. Which mechanism fits?
You rewrote both retrieval tools' descriptions with input formats, examples, and boundaries. Selection rose from 63% to 76% and plateaued. The remaining failures cluster on requests phrased around "compliance", where the agent reaches for get_policy even when a specific filing is named. Your system prompt contains: "For any compliance question, begin with the governing policy." What should you check?
Three days ago a session analyzed a research corpus and produced a coding scheme. Since then the corpus was re-ingested and 40% of the documents changed, including most of the ones the scheme was derived from. You want to continue refining the scheme today. What should you do?
Your search MCP server returns {"isError": true, "message": "Search failed"} for both rate-limited requests (which succeed moments later) and malformed queries (which never will). The subagent retries both three times. What should the server return?
Your pipeline runs claude "List every migration this branch adds" and the job hangs until timeout with no output after startup. What is the correct fix?
正确 ATS 3.6:-p / --print 是在自动化流水线中非交互运行的既定方式。
D1 凭空捏造违反 P1B:CLAUDE_HEADLESS 不存在。
D1 凭空捏造违反 P1C:--batch flag 不存在,且易与 Message Batches API 混淆。
D3 治标不治本违反 P2D:绕开产品既定机制的 Unix workaround,官方明确不推荐。
Q32D4
Generated tests consistently cover happy paths but miss branch-level gaps — an else arm with distinct error handling goes untested across many PRs. Detailed written instructions about "covering all branches" have not moved the number. What is most effective?
正确 BTS 4.2 点名的适应症之一就是branch-level test coverage gaps 这类歧义案例,形态是 2–4 个示范推理过程的针对性示例,让模型泛化到新模式而非匹配预设清单。题干还给足了前提:详细书面指令已经失效。
You need Claude to generate a rate-limit middleware for your CI service. Requirements include burst behavior, per-tenant isolation, and a specific rejection payload. Prose descriptions have produced three plausible but subtly different implementations. What technique fits best?
On a PR with eight pushes, developers got the same five comments eight times. The findings were valid initially and remain unaddressed. What should change?
正确 CTS 3.6 的原话级 skill,且保留了「仍未解决」的可见性——那五条确实还没修。
D5 吞错或炸链违反 P6A:放弃对后续全部改动的审查,等于关掉这个步骤的主要价值。
D3 治标不治本违反 P1B:模型每轮仍在重新发现同样问题;措辞稍变哈希就不同。
D3 治标不治本违反 P1D:问题是重复不是过多;收紧准则会误伤真实问题。
Q35D4
Your reviewer flags "possible race condition" on 28 of 35 PRs; sampling shows 24 involve code protected by a documented lock convention this repo uses. Developers now ignore the bot entirely, including its security findings. What should you do?
Your CI findings schema marks suggested_fix as required. Reviewers report that for findings like "this design will not scale past the current sharding scheme," the model emits a confident but useless one-line fix. What should change?
Your reviewer reports naming nits and import ordering alongside genuine defects. Developers say the signal is buried. The prompt currently says "review the diff and report anything that could be improved." What is the most effective change?
正确 CTS 4.1:写具体的 review 准则明确报什么、跳什么,而不是依赖基于 confidence 的过滤。「anything that could be improved」是一句无边界的指令,风格 nits 完全符合它的字面要求。
D3 治标不治本违反 P8A:「prioritize important issues」是模糊指令的又一版本——模型仍然按自己的理解判断什么重要,且噪音总量没变。
Your monorepo CI job spends most of its per-run budget on discovery — listing packages, locating changed files, reading configs — before any review begins, and on large PRs it runs out of context mid-review. What should you change?
Your pipeline generates a service module and then, in the same Claude Code session, runs the review step before opening the PR. The review approves nearly everything; defects surface in staging. What is the most effective change?
Structural validation fails on 15% of extractions — nested objects flattened, arrays emitted as delimited strings. Your retry simply re-sends the same document with the same prompt. Most retries fail the same way. What should the retry include?
Four veteran engineers report Claude follows the team's logging convention; three engineers who joined this month report it ignores the convention. Same repo, branch, and tool version. What is the likely cause and the fastest confirmation?
正确 BTS 3.1:新成员收不到指令因为它们在 user 级;/memory 的定义用途就是核实加载了哪些 memory 文件、诊断不一致。按人分裂是这个根因的签名。
You must migrate the CI pipeline from one test runner to another: 50+ config and spec files reference the old runner, three custom reporters wrap it, and there are two viable strategies (a shim versus a full rewrite) with different rollout implications. Which approach fits?
正确 DTS 3.4:大规模变更 + 多个可行方案 + 需先摸清依赖,三个触发条件齐备;且体现 plan 调查 + direct 实施的组合。
D6 概率当保证违反 P5A:详尽前置指令假设你已知正确结构,而策略取舍尚未做出。
D3 治标不治本违反 P5B:复杂性已写在需求里,不是可能才出现——等它显形时返工已发生。
D3 治标不治本违反 P5C:逐文件跑测试管实施期正确性,管不了「该选哪种策略」这个先决问题。
Q44D3
A CI-invoked skill generates migration scripts and has shell access; a misinterpreted prompt once caused it to drop a staging table. You want it to keep working but be structurally unable to execute destructive operations. What is the mechanism?
Three CI tools report severity differently: one uses numeric levels 1–5, one uses HIGH/MED/LOW strings, and a legacy scanner returns {"critical": true}. Your agent mis-ranks findings when combining them. What mechanism fits?
SCENARIO D · S6 Structured Data Extraction(Q46–Q60 · 详解见 ch20)
你在构建结构化数据抽取系统:从非结构化文档抽取信息、用 JSON schema 校验输出、保持高准确率,并优雅地处理 edge case 与下游集成。
Q46D4
Source documents write dates as 03/04/2026, 4 March 2026, and 2026-03-04. Your schema types the field as a string, so all three validate. Downstream sorting is wrong. What should you add?
You have six extraction schemas, one per document type; incoming scans are unlabeled. In roughly 8% of requests the model returns a prose summary rather than calling any tool, breaking the loader. What configuration fixes this?
Your reference-extraction works well on documents with a bibliography section but returns almost nothing for papers that use inline citations. Both styles are common in the corpus. What is most effective?
Extraction returns null for the required dosage field on 20% of clinical notes. The value is present but written informally ("a spoonful twice daily", "2 tabs BID"). What should you do?
Your reviewer receives one aggregated input containing extraction results for twelve documents. Findings for documents 3 through 8 are consistently thinner than for the first two and last two. What should change about the input?
Developers dismiss roughly a third of findings. You want to learn which code constructs are generating the dismissed ones so you can fix those criteria specifically, rather than lowering sensitivity across the board. What should the finding schema carry?
Your extraction agent has a general run_query tool that executes arbitrary SQL against the document warehouse. During testing it occasionally issued an UPDATE while "correcting" a malformed record. You need to keep its read access. What is the appropriate change?
Your extraction service reaches a document store through an MCP server you control. The agent spends 25–35 calls per session discovering which collections exist and what fields each carries. What is the appropriate change?
Your pipeline prompts the model to "respond with only a JSON object matching this shape." About 3% of responses carry a trailing explanatory sentence or a truncated closing brace, and the loader throws. What is the most reliable fix?
You already route low-confidence extractions to human review. Leadership asks how you would notice if the automated high-confidence band started making a new kind of mistake. What should be in place?
Two extractions of the same market-size metric from the same vendor's materials differ. Analysts have filed it as a pipeline bug. Inspection shows one figure comes from a 2025 annual report and the other from a 2026 quarterly update. What should the schema require?
Your extraction prompt has been described in prose three times and results still vary: units are sometimes normalized and sometimes copied verbatim, and one field is sometimes a sentence and sometimes a code. The rules are unambiguous to a human reader. What is most effective?
Your team wants two things: a universal rule that every extraction schema change be accompanied by a migration note, applied in every session; and a five-step corpus-revalidation workflow engineers run a few times a month. How should these be configured?
A teammate notices the extraction agent using tools from the OCR MCP server and assumes the warehouse server listed after it is inactive, so they copy a warehouse tool into the OCR server "to make it reachable." Now two tools with the same purpose exist. What is the correct understanding?
Each fetch_record call returns 52 fields; your reconciliation agent needs six. After a dozen lookups the session's context is dominated by record payloads and answer quality degrades. What is the appropriate fix?