Practice exam 2
A second full-length exam with new items, weighted the same way as Chapter 10 (53 items, 120 minutes). It leans more heavily on scenarios and on topics the first exam touched lightly, such as platform differences, effort, MCP primitives, and session hygiene. Take it at least a few days after Practice exam 1, under timed conditions.
Applications and Integration (items 1 to 18)
- 1. Support agents read Claude-drafted ticket summaries in a side panel and want to start reading immediately rather than waiting for the full summary. What should the developer implement?
- A. The Message Batches API.
- B. A higher max_tokens.
- C. Streaming, rendering text as it arrives.
- D. A stop sequence.
- 2. Which statement about the official Anthropic SDKs' default behavior is correct?
- A. They automatically retry rate-limit and server errors a small number of times with backoff.
- B. They retry all errors, including 400s, indefinitely.
- C. They never retry; retries must always be hand-written.
- D. They retry only authentication errors.
- 3. A developer's second request in a tool loop fails with a 400 stating that a tool_result block has no corresponding tool_use. What is the most likely mistake?
- A. The tool took too long.
- B. The tool result was too large.
- C. strict was not set.
- D. They appended only the assistant's text to the history, dropping its tool_use blocks.
- 4. Which two fields are required in every Messages API request besides messages? (Choose two.)
- A. system
- B. max_tokens
- C. temperature
- D. tools
- E. model
- 5. A batch finishes with 2% of requests marked expired. What is true?
- A. The whole batch must be resubmitted and paid for again.
- B. Expired requests were not billed and can be resubmitted.
- C. Expired results can be downloaded for 90 days.
- D. Expiry means the model refused the requests.
- 6. During a long turn using a server tool, the API returns stop_reason: "pause_turn". What should the application do?
- A. Send the response back in a follow-up request so Claude can continue the turn.
- B. Treat the answer as complete.
- C. Raise max_tokens and start over.
- D. Switch to the Batch API.
- 7. A healthcare company requires all model inference to run within its Google Cloud environment under existing GCP identity controls. Which option fits best?
- A. The first-party API from a laptop.
- B. Claude Desktop.
- C. Claude through Google Cloud (Vertex AI), with its client class and GCP authentication.
- D. Amazon Bedrock.
- 8. A team pastes an entire 900,000-token codebase into every request because "the context window is big enough." Quality is inconsistent and costs are high. What is the best improvement?
- A. Use a larger max_tokens.
- B. Add a stronger system prompt.
- C. Switch to the Batch API.
- D. Give Claude tools to search and read the relevant files, or retrieve only relevant code, instead of sending everything.
- 9. A request fails with HTTP 413. What should the developer do?
- A. Retry with exponential backoff.
- B. Reduce the request size, for example by uploading large files through the Files API or sending less content.
- C. Rotate the API key.
- D. Change the model to Haiku.
- 10. A team carefully tuned instructions in a claude.ai Project and then moved the workflow to their own API integration. Results are worse. What explains this?
- A. Project instructions and product context in claude.ai are not part of API requests; the team must include equivalent instructions in their own system prompt.
- B. The API does not support system prompts.
- C. API models are older than claude.ai models.
- D. Projects use a larger context window.
- 11. A RAG app retrieves internal wiki passages to answer questions. Where should the passages go in the request?
- A. In the system prompt, mixed with the rules.
- B. In a tool description.
- C. In the user turn inside clearly labelled tags, before the question, with the system prompt saying they are reference data.
- D. In an assistant prefill.
- 12. A shared in-store kiosk uses one ongoing conversation for every customer, and customers occasionally see references to earlier customers' questions. What is the fix?
- A. Raise effort.
- B. Add "do not mention other customers" to the system prompt.
- C. Switch to a smaller model.
- D. Start a new conversation for each customer session and clear state between them.
- 13. A developer wants to install a Claude Code plugin from an unfamiliar marketplace that adds hooks and an MCP server. What is the best practice?
- A. Install it globally for every project.
- B. Review what it adds (commands, hooks, servers, permissions), install only if trusted, and pin its version.
- C. Install it and disable all permission prompts.
- D. Copy its hooks into the shared CLAUDE.md.
- 14. Staging and production produce different answers to identical inputs. Staging pins an exact model ID; production uses an alias. What should be done?
- A. Pin the same exact model ID in every environment and change it deliberately.
- B. Add a stop sequence in production.
- C. Switch staging to the alias too.
- D. Lower effort in staging.
- 15. Claude Code opens a pull request implementing a feature. What should happen before merge?
- A. Merge immediately; Claude ran the tests.
- B. Ask Claude to approve its own pull request.
- C. Normal code review by a human and CI checks, as for any other change.
- D. Rewrite the change by hand.
- 16. A request fails with a 400 saying roles must alternate between user and assistant. What is the likely cause?
- A. The API key is invalid.
- B. Two consecutive messages share the same role, such as two user messages in a row.
- C. The model is overloaded.
- D. max_tokens is too low.
- 17. Requirements for a translation feature: "three languages, responses under one second, cost under a fraction of a cent per request, quality acceptable for internal use." Which requirement most constrains model choice?
- A. Three languages.
- B. Internal use.
- C. The word "translation."
- D. The latency and cost targets.
- 18. Anthropic announces the retirement date of the model a production app uses. What is the best response?
- A. Evaluate candidate replacement models on the app's eval set, pin the chosen ID, and schedule the migration before the date.
- B. Wait until requests fail, then switch.
- C. Switch to an alias so it upgrades automatically.
- D. Move all traffic to the Batch API.
Model Selection and Optimization (items 19 to 27)
- 19. What counts against a request's context window?
- A. Only the system prompt.
- B. Only the user's latest message.
- C. All input tokens (system, tools, messages) plus the output generated.
- D. Only output tokens.
- 20. A lead agent delegates simple lookup tasks to subagents. Which effort setting is usually most cost-effective for those subagents?
- A. max
- B. low
- C. xhigh
- D. Effort has no effect on subagents.
- 21. What does adaptive thinking do?
- A. Forces a fixed number of thinking tokens on every request.
- B. Disables reasoning for faster answers.
- C. Shows the raw chain of thought to end users.
- D. Lets Claude decide when and how much to reason, guided by the effort setting.
- 22. A nightly job processes 200,000 requests that share a 6,000-token instruction prefix. Which statement is correct?
- A. The Batch API discount and prompt caching can both apply, so the costs stack down.
- B. Prompt caching is not allowed in batches.
- C. Batches only work with Haiku.
- D. Caching makes batching unnecessary.
- 23. A developer adds cache_control to a 300-token system prompt, but cache_creation_input_tokens stays at 0. Why?
- A. Caching is only for tools.
- B. The TTL is too short.
- C. The prefix is shorter than the model's minimum cacheable length, so it silently is not cached.
- D. Breakpoints must go in the user message.
- 24. A voice assistant needs the shortest possible time to first audio. Which two changes help most? (Choose two.)
- A. Use a faster, smaller model where quality allows.
- B. Switch to the Batch API.
- C. Increase effort to max.
- D. Stream the response and start speech synthesis on the first sentence.
- 25. Which protocol does the Claude Messages API use to stream responses to your server?
- A. Websockets
- B. Server-sent events over HTTP
- C. gRPC bidirectional streams
- D. Long polling
- 26. After upgrading models, requests using tool_choice: {type: "any"} return a 400 error. What is the recommended fix?
- A. Downgrade permanently.
- B. Use tool_choice: none.
- C. Retry until it succeeds.
- D. Use auto with a clear instruction to use the tool, strict: true on the tool, or structured outputs if the goal was JSON.
- 27. Which usage field confirms that prompt caching is saving money?
- A. cache_read_input_tokens
- B. output_tokens
- C. max_tokens
- D. stop_reason
Agents and Workflows (items 28 to 35)
- 28. A help desk sends easy questions to a fast, cheap model and complex ones to a more capable model, based on a first classification call. Which pattern is this?
- A. Evaluator-optimizer
- B. Routing
- C. Orchestrator-workers
- D. Prompt chaining
- 29. A team uses the Claude Agent SDK to build an agent that analyzes a repository and reports findings but must never modify it. What is the most important configuration?
- A. A system prompt saying "read only."
- B. A high effort level.
- C. An allowed-tools list limited to read and search tools, such as Read, Grep, and Glob.
- D. A larger context window.
- 30. Compliance requires a record of every tool call an agent makes, with its inputs and results. Where should this be implemented?
- A. A PostToolUse hook (or equivalent code in the loop) that writes each call to the audit log.
- B. An instruction asking Claude to summarize its tool calls at the end.
- C. CLAUDE.md.
- D. A few-shot example.
- 31. A moderation system runs the same classification three times with different prompts and takes the majority answer. Which pattern is this?
- A. Routing
- B. Prompt chaining
- C. Orchestrator-workers
- D. Parallelization (voting)
- 32. A bank's agent needs shell and file tools, and policy says code and data must never leave the bank's own network. Which approach fits?
- A. Claude Managed Agents with default hosted sandboxes.
- B. The Claude Agent SDK deployed inside the bank's network, with model access through an approved channel.
- C. claude.ai with file uploads.
- D. A browser extension.
- 33. Which two are signs that a task should not be built as an autonomous agent? (Choose two.)
- A. Every step is known in advance and always the same.
- B. The task requires exploring an unknown number of sources.
- C. Mistakes cannot be detected or rolled back.
- D. The number of tool calls needed varies widely by input.
- 34. A personal assistant agent must remember each user's preferences (time zone, writing tone) across separate sessions. Which pattern addresses this?
- A. A larger context window.
- B. Higher effort.
- C. A persistent memory store or file that the agent reads and updates.
- D. Parallel tool calls.
- 35. A team adopted an agent framework and now cannot see the exact prompts sent to Claude, making debugging hard. What is the most commonly recommended approach?
- A. Start with direct API calls and add a framework only when it clearly solves a problem; if keeping it, make sure you understand and can log the prompts it sends.
- B. Add more agents.
- C. Switch frameworks every sprint.
- D. Disable logging to improve speed.
Prompt and Context Engineering (items 36 to 41)
- 36. A prompt's instructions say "one-word answers," but every few-shot example shows a full sentence. What will Claude most likely do?
- A. Ignore the examples entirely.
- B. Tend to follow the examples, so the examples should be fixed to match the instructions.
- C. Return an error.
- D. Alternate randomly between styles.
- 37. What is the main purpose of wrapping inputs in XML-style tags such as <contract> and
<instructions>?
- A. The API requires XML.
- B. Tags reduce token usage.
- C. Tags enable caching.
- D. They clearly separate parts of the prompt so Claude can tell instructions from data and refer to each part.
- 38. An agent must scan 200 log files for one error pattern, but the main conversation should stay focused on the user's goal. What is the best technique?
- A. Delegate the scan to a subagent that returns only the matching lines and file names.
- B. Paste all 200 files into the main context.
- C. Ask the user to read the logs.
- D. Increase max_tokens.
- 39. Structured outputs return valid JSON, but the date field sometimes uses "11/02/26" instead of ISO 8601. What is the best next step?
- A. Accept it; the schema passed.
- B. Switch off structured outputs.
- C. Specify the format in the schema description and prompt (for example "YYYY-MM-DD"), validate it in code, and retry with feedback on failure.
- D. Raise the temperature.
- 40. A user pastes text containing </document> followed by new instructions into a field your prompt wraps in <document> tags. What should the application do?
- A. Nothing; Claude ignores tags.
- B. Sanitize the input, escaping or stripping tag sequences that could break the prompt's structure, and treat the content as untrusted.
- C. Move the user input into the system prompt.
- D. Remove all tags from the prompt.
- 41. Where is the best place to explain when Claude should use a particular tool and what its parameters mean?
- A. The first user message only.
- B. A separate document stored outside the request.
- C. An assistant prefill.
- D. The tool's own description and parameter descriptions.
Tools and MCPs (items 42 to 47)
- 42. What does tool_choice: {type: "none"} do?
- A. Prevents Claude from calling any tools in that response, even though tools are defined.
- B. Forces Claude to call every tool.
- C. Deletes the tools from the account.
- D. Lets Claude invent new tools.
- 43. An MCP server offers a read-only list of product categories that the host application can attach as context. Which MCP primitive is this?
- A. Tool
- B. Prompt
- C. Resource
- D. Sampling
- 44. Which of these tools executes on Anthropic's infrastructure rather than in your application?
- A. A custom get_invoice tool.
- B. The web fetch server tool.
- C. The bash tool in your own container.
- D. The text editor tool in your own environment.
- 45. An agent has access to 200 tools across many systems, and the tool definitions alone consume a large share of the context window. What helps most?
- A. Shorten every description to one word.
- B. Remove all but five tools permanently.
- C. Raise max_tokens.
- D. Use tool search with deferred loading so only relevant tool definitions are loaded when needed.
- 46. Policy says refunds above $500 need a human's approval. How should the tool loop implement this?
- A. Check the amount in code after receiving the tool_use and before executing it; pause for approval when it exceeds $500.
- B. Ask Claude to be careful with large refunds.
- C. Execute the refund and notify a human afterwards.
- D. Lower the effort level.
- 47. A sales team wants Claude to read and update live Salesforce records from Claude Code, Claude Desktop, and an internal app. Which mechanism fits best?
- A. A Skill containing a Salesforce export.
- B. A custom tool duplicated in each app.
- C. An MCP server for Salesforce.
- D. Pasting records into each conversation.
Security and Safety (items 48 to 51)
- 48. Which design best illustrates guardrail layering?
- A. A single, very detailed system prompt.
- B. An input classifier, a policy system prompt, least-privilege tools, a blocking hook for dangerous actions, output validation, and monitoring.
- C. Using the largest model available.
- D. Logging only errors.
- 49. A reporting agent needs to query a production database. Which credential should its query tool use?
- A. The database administrator account.
- B. A developer's personal account.
- C. A shared account used by all services.
- D. A read-only account limited to the reporting tables.
- 50. A public chatbot sees frequent attempts to make it produce prohibited content. Which control adds a cheap, fast first layer?
- A. An input-screening call on a small, fast model that flags or blocks abusive requests before the main call.
- B. Raising max_tokens.
- C. Turning off streaming.
- D. Using the 1-hour cache TTL.
- 51. An agent calls a payment provider's API. Which two practices are correct for that provider's secret key? (Choose two.)
- A. Put the key in the system prompt so Claude can use it.
- B. Store it in a secrets manager and inject it inside the tool implementation at call time.
- C. Never expose it to the model's context or outputs.
- D. Commit it to the repository in an encrypted-looking string.
Claude Code (item 52)
- 52. A dashboard must show each step of a headless Claude Code run live as it happens. Which output format should the run use?
- A. text
- B. json
- C. markdown
- D. stream-json
Eval, Testing, and Debugging (item 53)
- 53. An agent's inventory tool intermittently gets HTTP 503 from a downstream service, and the agent then tells users items are unavailable. What is the best recovery strategy?
- A. Remove the tool.
- B. Return an empty result so the agent continues.
- C. Retry the downstream call with backoff inside the tool, and if it still fails return an is_error result explaining the outage so Claude does not report false unavailability.
- D. Raise the model's effort.
Answer key and rationales (Practice exam 2)
# Answer Rationale
1 C Streaming lets readers start before generation finishes.
2 A SDKs retry 408, 409, 429, and 5xx a few times with backoff by default.
3 D Each tool_result must follow an assistant turn containing the matching tool_use. 4 B, E model, max_tokens, and messages are required.
5 B Expired requests are not billed; resubmit them.
6 A pause_turn means send the response back to let the turn continue.
7 C Claude on Google Cloud keeps inference in GCP with GCP identity.
8 D Retrieve or let Claude fetch only relevant code; huge contexts dilute attention and cost more. 9 B 413 means the request is too large; shrink it.
10 A Product-side instructions do not travel with API calls.
11 C Reference data goes in tagged user content, with instructions in the system prompt. 12 D Session hygiene: a fresh conversation per customer.
13 B Review, trust, and pin plugins before installing.
14 A Aliases can move; pin exact IDs everywhere.
15 C AI-written code goes through the same review and CI as any change.
16 B Roles must alternate; merge consecutive same-role messages.
17 D Latency and cost targets rule out the largest models.
18 A Plan deprecations: evaluate, pin, migrate on schedule.
19 C Input plus output must fit in the context window.
20 B Simple subagent work rarely benefits from high effort.
21 D Adaptive thinking lets Claude decide how much to reason.
22 A Batch discounts and caching can both apply.
23 C Prefixes under the minimum length silently do not cache.
24 A, D Smaller models and streaming cut time to first output.
25 B The API streams with server-sent events.
26 D Forced tool choice is rejected on the newest models; use the alternatives. 27 A Cache reads show tokens served from cache.
28 B Classify then dispatch is routing.
29 C Least privilege through the tool list is enforceable.
30 A Deterministic logging belongs in a hook or loop code.
31 D Multiple runs with a majority vote is parallelization by voting.
32 B A self-hosted harness keeps execution inside the bank's network.
33 A, C Fixed steps call for a workflow; unrecoverable errors argue against autonomy. 34 C Cross-session memory requires persistent storage.
35 A Prefer simple, transparent code; frameworks are optional.
36 B Examples strongly steer output; keep them consistent with instructions. 37 D Tags separate and label prompt parts.
38 A Subagents isolate heavy exploration and return summaries.
39 C Describe the format, validate, and retry with feedback.
40 B Sanitize input that could break prompt structure.
41 D Tool usage guidance belongs in tool descriptions.
42 A none disables tool calls for that response.
43 C Resources are application-controlled data.
44 B Web fetch is a server tool run by Anthropic.
45 D Tool search with deferred loading keeps definitions out of context until needed. 46 A Enforce approval in code before execution.
47 C MCP gives reusable live access across multiple clients.
48 B Multiple independent controls form layers.
49 D Least privilege: read-only, scoped access.
50 A A fast classifier is a cheap first guardrail.
51 B, C Keep secrets in a manager and out of the model's context.
52 D stream-json emits events as they happen.
53 C Retry transient failures, then report errors honestly to the model.
Scoring guide. Use the same thresholds as Practice exam 1. If your score on this exam is more than 5 points below your first, review the domains where you missed the most items; this exam deliberately probes different sub-skills.