All practice tests

Module 2 practice: Prompts, tools and agents that hold up

15 questions · Tools and MCP · Prompt and Context Engineering · Agents and Workflows · Applications and Integration · Security and Safety

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

  1. Question 1

    Your triage agent has this tool:

    { "name": "lookup_account",
      "input_schema": { "type": "object",
        "properties": { "tenant_id": {"type": "string"}, "email": {"type": "string"} } } }

    A ticket from an Acme user says "our parent company Globex pays the bill", and the agent looks up Globex's account. What is the root-cause fix?

    • A) Add "Only use the current tenant" to the system prompt.
    • B) Add "enum": ["acme", "globex", "himal-traders"] to tenant_id.
    • C) Remove tenant_id from the schema and have the server set the tenant from the authenticated session.
    • D) Set strict: true on the tool.
    Show answer

    Answer: C

    • A: A prompt rule helps, but the ticket can still persuade the model.
    • B: An enum still lets the model pick any listed tenant, including the wrong one.
    • C: Whatever is in the schema, the model chooses. The server must set the tenant from the session.
    • D: strict makes inputs match the schema. It doesn't decide which values are allowed for this user.
  2. Question 2

    To get JSON back, a developer sends this to claude-sonnet-5-5 and gets a 400 error:

    tools: [triageTool],
    tool_choice: { type: "tool", name: "triage" },

    The tool does nothing; it only exists to shape the output. What is the best fix?

    • A) Drop the fake tool and use structured outputs (output_config.format with the schema).
    • B) Change tool_choice to { type: "any" }.
    • C) Add an assistant prefill of { to force JSON.
    • D) Retry the request with exponential backoff.
    Show answer

    Answer: A

    • A: When the goal is JSON, structured outputs is the supported way to get it.
    • B: Forced any is also a 400 on Sonnet 5.5, Opus 5.5 and Fable 5.2.
    • C: Prefill returns a 400 on current models.
    • D: Retrying an invalid request fails again.
  3. Question 3

    One assistant turn contains two tool_use blocks: lookup_account and search_kb. Which two statements describe the correct way to send the results back? (Choose TWO.)

    • A) Send the lookup_account result, call the API, then send the search_kb result in the next turn.
    • B) Every tool_use block gets a tool_result block with the matching tool_use_id.
    • C) Put both results in a single text block in the next user message.
    • D) Both tool_result blocks go back together in one user message.
    • E) Send only the more useful result; the model will ask again for the other.
    Show answer

    Answer: B, D

    • A: Every pending tool_use must be answered in the next user message.
    • B: Each result is tied to its call by tool_use_id.
    • C: Results must be tool_result blocks, not text.
    • D: Results from one turn go back together. Splitting them teaches the model to stop making parallel calls.
    • E: Every call needs a result.
  4. Question 4

    When lookup_account can't find an email, the handler throws, and the whole agent run crashes. What is the better design?

    • A) Catch the error and silently drop the tool_use block from the history.
    • B) Return a tool_result with is_error: true and a short message, so the model can try something else.
    • C) Retry the same lookup until it succeeds.
    • D) Remove the tool so the agent never fails.
    Show answer

    Answer: B

    • A: Dropping the tool_use breaks the history and hides the failure.
    • B: An error result lets the model react: try another email, search the KB, or escalate.
    • C: A missing email won't appear on retry, and endless retries have no brakes.
    • D: Removing the tool removes a needed capability.
  5. Question 5

    Look at this part of an agent loop:

    messages.push({
      role: "assistant",
      content: res.content.filter((b) => b.type === "text"),
    });
    messages.push({ role: "user", content: toolResults });

    The next API call fails with a 400 error. What is the most likely reason?

    • A) Text blocks are not allowed in assistant messages.
    • B) The user message must come before the assistant message.
    • C) The tool_use blocks were dropped, so the tool_result blocks refer to tool calls that are no longer in the history.
    • D) toolResults must be sent as a JSON string, not as blocks.
    Show answer

    Answer: C

    • A: Text blocks are allowed.
    • B: Assistant first, then user with results, is the correct order.
    • C: Append the full res.content, so every tool_use (and thinking block) stays in the history.
    • D: Tool results are sent as blocks.
  6. Question 6

    You submit 5,000 tickets as one message batch. In what order do the results come back, and how do you match them to tickets?

    • A) In any order; match each result to its ticket by custom_id.
    • B) In submission order; match by position.
    • C) Sorted by custom_id; match by position.
    • D) In completion order; match by the request-id header.
    Show answer

    Answer: A

    • A: Results can come back in any order, so match them on the custom_id you set.
    • B: Submission order is not guaranteed.
    • C: Results are not sorted.
    • D: Batch results are matched by custom_id, not by HTTP headers.
  7. Question 7

    Which two jobs are good fits for the Message Batches API? (Choose TWO.)

    • A) The live chat reply a customer is waiting for.
    • B) Re-triaging 20,000 closed tickets overnight for a quarterly report.
    • C) The streamed draft reply shown to a support agent.
    • D) A refund draft that a manager approves within the next minute.
    • E) Running the 400-case eval set before a release, when results are needed by tomorrow.
    Show answer

    Answer: B, E

    • A: A customer is waiting, so use a normal or streaming request.
    • B: A large job with nobody waiting: 50% cheaper, done within 24 hours.
    • C: A person is watching it stream.
    • D: Someone needs it within a minute.
    • E: An overnight deadline suits batch, and the eval costs half as much.
  8. Question 8

    You stream a reply with client.messages.stream(...). Where does the final stop_reason appear in the event stream?

    • A) In message_start, before any content.
    • B) In the message_delta event near the end.
    • C) In every content_block_delta.
    • D) It only exists on non-streaming responses.
    Show answer

    Answer: B

    • A: stop_reason is null in message_start.
    • B: The final stop_reason and usage arrive in message_delta.
    • C: Content deltas carry text, tool input JSON or thinking.
    • D: Streamed responses have a stop reason too.
  9. Question 9

    You call messages.create with this raw JSON schema in output_config.format, and the API returns a 400:

    { "type": "object",
      "properties": { "urgency": { "type": "integer", "minimum": 1, "maximum": 5 } },
      "required": ["urgency"], "additionalProperties": false }

    Why?

    • A) required is not allowed in structured output schemas.
    • B) Integers are not supported; use strings.
    • C) Numeric constraints such as minimum and maximum are not supported; use an enum or validate the range after parsing.
    • D) additionalProperties: false must be omitted.
    Show answer

    Answer: C

    • A: required is supported, and in fact needed.
    • B: Integers are supported.
    • C: Numeric and string-length constraints are not supported in structured output schemas.
    • D: additionalProperties: false is required.
  10. Question 10

    A request from Acme's session asks the memory tool to view the path /memories/../globex/notes.md. What should your memory handler do?

    • A) Allow it, because it starts with /memories.
    • B) Strip the .. and read /memories/globex/notes.md instead.
    • C) Ask Claude to confirm the path before reading it.
    • D) Reject it, because the resolved path leaves Acme's memory folder.
    Show answer

    Answer: D

    • A: A /memories prefix check alone is exactly what path traversal defeats.
    • B: Quietly "fixing" a hostile path hides an attack and may still read the wrong file.
    • C: Claude confirming the path doesn't make it safe. Your code must enforce it.
    • D: Resolve the path and check it stays inside the session tenant's folder.
  11. Question 11

    Your triage always does the same three steps in the same order: classify, look up the account, draft a reply. Which design fits best?

    • A) A workflow: your code runs the three steps in order and calls the model where needed.
    • B) An open-ended agent that chooses its own steps.
    • C) Three agents that talk to each other.
    • D) A single prompt that asks the model to do all three steps "if needed".
    Show answer

    Answer: A

    • A: When the steps are known, a workflow is cheaper, faster and easier to test.
    • B: An agent adds cost and unpredictability for no benefit here.
    • C: Several agents add even more cost and complexity.
    • D: It gives up control of the steps and makes testing harder.
  12. Question 12

    Each agent step sends the customer's full CRM history, about 180,000 tokens. Requests are slow and expensive, and the answers have become less accurate. What is the best first change?

    • A) Switch to Claude Fable 5.2 so the model copes with the extra context.
    • B) Send only what the step needs (recent tickets and an account summary) and give the agent a search tool for anything else.
    • C) Raise effort to max so the model reads the history more carefully.
    • D) Raise max_tokens so the model has more room.
    Show answer

    Answer: B

    • A: A bigger model costs more and doesn't fix the noise.
    • B: Send what the step needs and fetch more on demand.
    • C: More effort on bad context costs more without fixing the cause.
    • D: max_tokens limits output, not input.
  13. Question 13

    The agent often calls search_kb when it should call lookup_account. Both tools have one-line descriptions. Which two changes will most improve tool selection? (Choose TWO.)

    • A) Force lookup_account with tool_choice.
    • B) Rewrite each description to say what the tool does, when to use it, when not to, and what it returns.
    • C) Rename the tools to single letters to save tokens.
    • D) Lower effort so the model makes fewer tool calls.
    • E) Give the tools clearly distinct purposes and names (for example kb_search_articles and account_lookup_by_email) so they don't overlap.
    Show answer

    Answer: B, E

    • A: Forced tool_choice is a 400 on current models, and it would force the tool on every ticket.
    • B: Detailed descriptions are the biggest factor in correct tool use.
    • C: Meaningless names make selection harder.
    • D: Effort doesn't fix ambiguous tools.
    • E: Distinct, non-overlapping tools with clear names reduce selection mistakes.
  14. Question 14

    You stream replies from claude-opus-5-5. Users complain about a long pause before any text appears on hard tickets. Logs show thinking blocks streaming with empty text. What is going on, and what can you change?

    • A) Thinking is broken on streaming; switch to non-streaming.
    • B) The model is rate limited during the pause; add retries.
    • C) max_tokens is too low; raise it.
    • D) Thinking display defaults to omitted on current models; set display: "summarized" if you want to show progress during the pause.
    Show answer

    Answer: D

    • A: Thinking works with streaming, and streaming is recommended for long outputs.
    • B: A rate limit returns a 429. It doesn't stream empty thinking blocks.
    • C: max_tokens doesn't cause a pause at the start.
    • D: With the display omitted, thinking still runs (and is billed). A summary shows progress.
  15. Question 15

    You attach an invoice PDF with citations: { enabled: true } on the document block, and also set output_config.format to your triage schema. The request returns a 400. Why?

    • A) Citations can't be combined with structured outputs (output_config.format).
    • B) PDFs can't be sent as base64.
    • C) Documents must come after the text block.
    • D) Citations need the Batches API.
    Show answer

    Answer: A

    • A: The API rejects citations combined with output_config.format.
    • B: Base64 is a supported PDF source.
    • C: Documents go before the question, which is the recommended order.
    • D: Citations work on normal requests.

↑ ↓ navigate · ↵ select · esc close