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.
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"]totenant_id. - C) Remove
tenant_idfrom the schema and have the server set the tenant from the authenticated session. - D) Set
strict: trueon 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:
strictmakes inputs match the schema. It doesn't decide which values are allowed for this user.
Question 2
To get JSON back, a developer sends this to
claude-sonnet-5-5and 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.formatwith the schema). - B) Change
tool_choiceto{ 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
anyis 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.
- A) Drop the fake tool and use structured outputs (
Question 3
One assistant turn contains two
tool_useblocks:lookup_accountandsearch_kb. Which two statements describe the correct way to send the results back? (Choose TWO.)- A) Send the
lookup_accountresult, call the API, then send thesearch_kbresult in the next turn. - B) Every
tool_useblock gets atool_resultblock with the matchingtool_use_id. - C) Put both results in a single
textblock in the next user message. - D) Both
tool_resultblocks 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_usemust be answered in the next user message. - B: Each result is tied to its call by
tool_use_id. - C: Results must be
tool_resultblocks, 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.
- A) Send the
Question 4
When
lookup_accountcan'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_useblock from the history. - B) Return a
tool_resultwithis_error: trueand 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_usebreaks 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.
- A) Catch the error and silently drop the
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_useblocks were dropped, so thetool_resultblocks refer to tool calls that are no longer in the history. - D)
toolResultsmust 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 everytool_use(and thinking block) stays in the history. - D: Tool results are sent as blocks.
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-idheader.
Show answer
Answer: A
- A: Results can come back in any order, so match them on the
custom_idyou set. - B: Submission order is not guaranteed.
- C: Results are not sorted.
- D: Batch results are matched by
custom_id, not by HTTP headers.
- A) In any order; match each result to its ticket by
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.
Question 8
You stream a reply with
client.messages.stream(...). Where does the finalstop_reasonappear in the event stream?- A) In
message_start, before any content. - B) In the
message_deltaevent near the end. - C) In every
content_block_delta. - D) It only exists on non-streaming responses.
Show answer
Answer: B
- A:
stop_reasonisnullinmessage_start. - B: The final
stop_reasonand usage arrive inmessage_delta. - C: Content deltas carry text, tool input JSON or thinking.
- D: Streamed responses have a stop reason too.
- A) In
Question 9
You call
messages.createwith this raw JSON schema inoutput_config.format, and the API returns a 400:{ "type": "object", "properties": { "urgency": { "type": "integer", "minimum": 1, "maximum": 5 } }, "required": ["urgency"], "additionalProperties": false }Why?
- A)
requiredis not allowed in structured output schemas. - B) Integers are not supported; use strings.
- C) Numeric constraints such as
minimumandmaximumare not supported; use anenumor validate the range after parsing. - D)
additionalProperties: falsemust be omitted.
Show answer
Answer: C
- A:
requiredis supported, and in fact needed. - B: Integers are supported.
- C: Numeric and string-length constraints are not supported in structured output schemas.
- D:
additionalProperties: falseis required.
- A)
Question 10
A request from Acme's session asks the memory tool to
viewthe 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.mdinstead. - 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
/memoriesprefix 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.
- A) Allow it, because it starts with
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.
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
maxso the model reads the history more carefully. - D) Raise
max_tokensso 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_tokenslimits output, not input.
Question 13
The agent often calls
search_kbwhen it should calllookup_account. Both tools have one-line descriptions. Which two changes will most improve tool selection? (Choose TWO.)- A) Force
lookup_accountwithtool_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_articlesandaccount_lookup_by_email) so they don't overlap.
Show answer
Answer: B, E
- A: Forced
tool_choiceis 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.
- A) Force
Question 14
You stream replies from
claude-opus-5-5. Users complain about a long pause before any text appears on hard tickets. Logs showthinkingblocks 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_tokensis 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_tokensdoesn't cause a pause at the start. - D: With the display omitted, thinking still runs (and is billed). A summary shows progress.
Question 15
You attach an invoice PDF with
citations: { enabled: true }on the document block, and also setoutput_config.formatto 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.
- A) Citations can't be combined with structured outputs (