All practice tests

Module 8 practice questions: Cost and latency at scale

15 questions · Cost and Latency Optimization at Scale

Practice questions written by Sanjay Shah. Not exam questions, not affiliated with or endorsed by Anthropic.

  1. Question 1

    The cache-hit rate for helpdesk-agent is 0%, even though every request has cache_control markers. The system prompt starts with Current time: <ISO timestamp>, then Tenant: <name>, then 6,000 tokens of fixed instructions that all tenants share. Which two changes fix this best? (Choose TWO.)

    • A) Freeze the system prompt and move the timestamp to the end of the latest user message, below the last breakpoint.
    • B) Switch the breakpoints to the 1-hour TTL so entries live longer.
    • C) Add a cache_control marker to every block in the request, up to the limit.
    • D) Move the tenant line into its own block after the shared instructions, with its own breakpoint, so all tenants share the instructions' prefix.
    • E) Raise max_tokens so the model has room to use the cached content.
    Show answer

    Answer: A, D

    • A: Right: the timestamp at the top makes every prefix different from its first line; below the last breakpoint it no longer breaks matching.
    • B: Wrong: a longer TTL doesn't help when no two requests ever share a prefix.
    • C: Wrong: more markers can't match bytes that differ before all of them, and the limit is four breakpoints.
    • D: Right: with the tenant line at the top, tenants can't share the 6,000-token block; in its own later block, they all reuse it.
    • E: Wrong: max_tokens limits output; it has nothing to do with cache matching.
  2. Question 2

    A cedar ticket ran through a long agent loop. Its final request sent a prompt of about 60,000 tokens, but the response shows input_tokens: 3,100. An engineer concludes "our prompts are tiny, so caching can't be saving much." What is the correct reading?

    • A) input_tokens is only the uncached remainder; the total prompt is input_tokens + cache_creation_input_tokens + cache_read_input_tokens, so check the read field before concluding anything.
    • B) input_tokens includes cached tokens, so the prompt really was 3,100 tokens and the 60,000 figure is wrong.
    • C) The usage fields are unreliable, so the team should call the token-counting endpoint on every request instead.
    • D) Caching shrinks the prompt the model sees, so only 3,100 tokens were actually used to answer.
    Show answer

    Answer: A

    • A: Right: input_tokens counts only full-price tokens; sum all three fields to get the prompt size.
    • B: Wrong: it reverses the definition; cached tokens are reported in their own fields.
    • C: Wrong: the usage fields are the ground truth for caching, and counting tokens on every request adds calls without showing what was cached.
    • D: Wrong: cached tokens are still in the context the model reads; caching changes their price, not what the model sees.
  3. Question 3

    Tools are built from a Set of features enabled for each tenant, so the order of the tools array varies between requests, even for the same tenant. Cache reads are close to zero. What is the best fix?

    • A) Put a cache_control marker on each tool definition.
    • B) Use the 1-hour TTL so tool caches survive longer.
    • C) Build the tool list once, sorted by name, keep the set fixed per route, and handle tenant differences in code or in content after the shared prefix.
    • D) Move the tool definitions into the system prompt as plain text.
    Show answer

    Answer: C

    • A: Wrong: markers don't fix bytes that differ between requests.
    • B: Wrong: entries that never match don't benefit from living longer.
    • C: Right: tools render first, so a deterministic order and a fixed set make the prefix identical.
    • D: Wrong: tools as plain text stop being callable tools, and a varying order would still break the prefix.
  4. Question 4

    Halfway through long conversations, an admin can switch a tenant to "short answers" mode. The team implements it by editing the top-level system prompt, and cost per ticket jumps on those conversations. The app runs on claude-opus-5-5. What is the best change?

    • A) When the mode changes, summarise the conversation and start a new one with the new system prompt.
    • B) Append a { role: "system", content: "Short-answer mode: ..." } message after the latest user message, and leave the top-level system prompt untouched.
    • C) Put the instruction into the search_docs tool description, since tools are cached separately.
    • D) Route short-answer conversations to a smaller model.
    Show answer

    Answer: B

    • A: Wrong: it throws away the cache and conversation detail, and summaries can lose facts.
    • B: Right: a mid-conversation system message sits after the cached history, so the prefix stays byte-identical.
    • C: Wrong: tool definitions render first, so editing one invalidates everything, and it misuses a tool description.
    • D: Wrong: a model switch also starts the cache cold, and answer length is an instruction, not a reason to change models.
  5. Question 5

    A nightly job sends 12 requests at the same moment. All of them share a 40,000-token prefix with a breakpoint at its end. Every one shows cache_creation_input_tokens and none shows a read. What is the best fix?

    • A) Use the 1-hour TTL for the shared prefix.
    • B) Add a fifth breakpoint in the middle of the shared prefix.
    • C) Send one request first, wait until its response begins streaming, then send the other 11, which can now read the entry it wrote.
    • D) Split the requests across two workspaces to double the cache capacity.
    Show answer

    Answer: C

    • A: Wrong: the TTL isn't the problem; the entry doesn't exist yet when the others start.
    • B: Wrong: the limit is four breakpoints, and an extra marker doesn't fix the timing.
    • C: Right: an entry becomes readable only once the first response begins streaming, so staggering turns 11 writes into reads.
    • D: Wrong: caches are isolated per workspace on the Claude API, so splitting creates two caches and fewer hits.
  6. Question 6

    Birch's customers usually reply about 20 minutes after the bot's last message, and conversations run for many turns. Each reply finds the cache cold. What is the best caching choice for the conversation breakpoints?

    • A) Keep the default 5-minute TTL; entries are refreshed by every read anyway.
    • B) Remove caching from conversations entirely, since it only helps within one agent loop.
    • C) Turn caching off whenever a gap is likely, because caching only helps for requests under 5 minutes apart.
    • D) Use the 1-hour TTL on those breakpoints, because gaps of 5–60 minutes are where its doubled write price pays off.
    Show answer

    Answer: D

    • A: Wrong: refresh-on-read only helps if a read happens before expiry, and with 20-minute gaps it doesn't.
    • B: Wrong: long conversations reuse a growing prefix many times, which is where caching pays.
    • C: Wrong: the 1-hour TTL exists for exactly these gaps.
    • D: Right: a 2× write that survives 20-minute gaps beats a fresh 1.25× write on every reply of a long conversation.
  7. Question 7

    To cut cost, the team plans a cascade for every ticket: try claude-haiku-5-5, then claude-sonnet-5-5, then claude-opus-5-5. What should they do first?

    • A) Measure claude-opus-5-5 at a lower effort on the eval set, per category, and compare cost per resolved ticket (including escalations and retries) with the cascade; remember that a cascade gives up cache reuse across its models.
    • B) Ship the cascade straight away, because smaller models are always cheaper per ticket.
    • C) Have each model report a confidence score and escalate when it's below 0.7.
    • D) Send everything to claude-haiku-5-5 and use thumbs-down feedback to find the failures.
    Show answer

    Answer: A

    • A: Right: the best model at a lower effort often holds quality more cheaply, with one cache namespace and no extra calls; measure it per category first.
    • B: Wrong: cheaper per call isn't cheaper per ticket once escalations, extra calls and lost cache reuse are counted.
    • C: Wrong: a self-reported confidence score isn't calibrated; escalate on measured failures.
    • D: Wrong: it uses customers as the eval suite, so failures reach people first.
  8. Question 8

    After routing all "billing" tickets to claude-sonnet-5-5, the overall eval score moves from 0.91 to 0.90, which is within run-to-run noise. Support staff report that billing disputes are being handled badly. What is the best response?

    • A) Ship it: the overall score is within noise, so quality held.
    • B) Make the release gate check scores per category; split out billing_dispute, pin it to the larger model once its score shows the drop, and generate the route table from eval results.
    • C) Raise effort to max on every route to win back the quality.
    • D) Add "Be extra careful with billing disputes" to the system prompt.
    Show answer

    Answer: B

    • A: Wrong: "within noise overall" is exactly how a regression in one category hides.
    • B: Right: per-category thresholds catch the drop, and pinning only the weak category keeps the savings elsewhere.
    • C: Wrong: max effort everywhere throws away the savings and may not fix the routing mistake.
    • D: Wrong: a prompt line doesn't add capability, and nothing measures whether it worked.
  9. Question 9

    The nightly tagging job uses the Message Batches API. Some tags end up on the wrong tickets, and nothing errors. The code zips the results with the input array. What is the best fix?

    • A) Switch the job to synchronous calls so results arrive in order.
    • B) Sort the results by creation time before zipping them with the inputs.
    • C) Raise max_tokens so no result is cut short and out of place.
    • D) Give each request a custom_id that identifies the ticket, and match results by custom_id, never by position.
    Show answer

    Answer: D

    • A: Wrong: it gives up the 50% discount to fix a bug that one field fixes.
    • B: Wrong: creation order isn't guaranteed to match input order; only custom_id is reliable.
    • C: Wrong: output length has nothing to do with result order.
    • D: Right: batch results arrive in any order, and custom_id is the key for matching them.
  10. Question 10

    The team wants to use the Message Batches API's 50% discount wherever it fits. Which two helpdesk-agent workloads are good candidates? (Choose TWO.)

    • A) Drafting the reply a customer is waiting for in the support widget.
    • B) Nightly tagging of the day's closed tickets by product area.
    • C) Streaming answers to staff in the internal FAQ bot.
    • D) Replies for cedar's premium tier, sent with fast mode for extra speed.
    • E) Running the 60-ticket eval suite overnight before tomorrow's release.
    Show answer

    Answer: B, E

    • A: Wrong: batches can take up to 24 hours, and a customer is waiting.
    • B: Right: nobody waits on nightly tagging, so half price for a slower result is a good trade.
    • C: Wrong: a batch request can't set stream, and staff are waiting.
    • D: Wrong: a batch request can't set speed (fast mode), and these customers are waiting too.
    • E: Right: an overnight eval run has no one waiting on it, and it fits well inside the 24-hour window.
  11. Question 11

    Over two weeks, input tokens per ticket rose by 30%. Customers' messages are the same length as before. What is the best first step?

    • A) Break the prompt down by part (system, tools, history, tool outputs, retrieved chunks) using the usage fields and the token-counting endpoint, find which part grew (a tool output often has), and cap or trim that part.
    • B) Cut retrieval top-k to 1 for every tenant.
    • C) Move all tenants to claude-haiku-5-5 to offset the rise.
    • D) Summarise every conversation after its second turn.
    Show answer

    Answer: A

    • A: Right: if customer input hasn't changed, something the system adds has, so measure which part grew before changing anything.
    • B: Wrong: it's a blunt cut that will likely hurt quality and may not be the part that grew.
    • C: Wrong: it hides the growth behind a model change and risks quality without finding the cause.
    • D: Wrong: summarising that early loses detail on every ticket and breaks the cache, without finding the cause.
  12. Question 12

    Users say the widget "freezes" for several seconds before an answer appears. The app uses non-streaming calls and runs classification, then retrieval, then the answer, one after another. Which two changes are best? (Choose TWO.)

    • A) Turn on fast mode first, since it's the strongest latency lever.
    • B) Lower max_tokens to 500 so answers finish sooner.
    • C) Stream the answer so the first words appear as soon as they're generated.
    • D) Move answers to the Batches API to take load off the live system.
    • E) Start retrieval in parallel with classification instead of after it.
    Show answer

    Answer: C, E

    • A: Wrong: fast mode is a premium-priced last lever; the free fixes for this pattern come first.
    • B: Wrong: a tight cap can cut answers off, and thinking also counts toward it.
    • C: Right: streaming cuts the time until the first words appear, which is the "freeze" users feel.
    • D: Wrong: batch results can take up to 24 hours, the opposite of what users want.
    • E: Right: running retrieval alongside classification removes a sequential wait from every answer.
  13. Question 13

    The model asks for get_order and search_docs in the same turn. The harness runs both, then sends each tool_result back in its own user message. Over time the model stops making parallel calls and latency rises. What is the best fix?

    • A) Set disable_parallel_tool_use so the behaviour is at least predictable.
    • B) Add "Always call tools in parallel" to the system prompt.
    • C) Return all the tool_result blocks from one turn together in a single user message.
    • D) Force tool use with tool_choice: { type: "any" }.
    Show answer

    Answer: C

    • A: Wrong: it makes the slow behaviour permanent instead of fixing the harness.
    • B: Wrong: the harness is sending the opposite signal; fix the cause, not the prompt.
    • C: Right: one turn's parallel results belong in one user message; splitting them teaches the model to stop calling in parallel.
    • D: Wrong: forced tool choice returns a 400 on claude-opus-5-5 (checked 2026-11-25), and it wouldn't make calls parallel anyway.
  14. Question 14

    A small internal route on claude-opus-5-5 has a 300-token system prompt with a breakpoint on it. Every request shows cache_creation_input_tokens: 0 and no reads, and no error is returned. What is the most likely explanation and the best action?

    • A) cache_control needs an explicit ttl; add ttl: "5m".
    • B) Automatic caching is turned off for Opus models; switch to Sonnet.
    • C) It's an API bug; open a support ticket.
    • D) The prefix is below the model's minimum cacheable length, so it is silently not cached. At this size there's little to save, so leave it, or revisit once the shared prefix (tools, policies) grows.
    Show answer

    Answer: D

    • A: Wrong: the TTL is optional and defaults to 5 minutes.
    • B: Wrong: caching works on Opus models; the issue is prefix length.
    • C: Wrong: this is documented behaviour, not a bug.
    • D: Right: prefixes below the model's minimum are silently not cached, and at 300 tokens there's little to save anyway.
  15. Question 15

    A team reports: "Switching the default effort to low cut cost per ticket by 54% and improved p95." What is still missing before the change counts as an optimisation?

    • A) Nothing: cost and latency both improved.
    • B) The quality score from the eval suite, per category, on the same ticket set; cost, latency and quality have to be reported together.
    • C) The cache-hit rate before and after.
    • D) Next month's invoice, to confirm the saving.
    Show answer

    Answer: B

    • A: Wrong: two numbers out of three is exactly the trap.
    • B: Right: lower effort can trade away quality, so without the per-category eval score the saving isn't proven.
    • C: Wrong: the hit rate explains where savings come from, not whether quality held.
    • D: Wrong: the invoice arrives weeks late and still doesn't measure quality.

↑ ↓ navigate · ↵ select · esc close