Skip to content

CCDV-F · Domain 1: Agents and Workflows · 17% of the exam

Task 1.3: Agent Pattern Diagnosis

Reading a trace or a description of an agent that misbehaves, naming the missing or misused pattern (loop termination, subagent isolation, memory, context-window handling) and choosing the one that fixes it.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.

Question 1 · choose 1

An Agent SDK job reads a log, runs one diagnostic command and then writes a fix, one tool call per turn, before Claude replies with a short summary. It runs with these options:options = ClaudeAgentOptions( allowed_tools=["Read", "Bash", "Edit"], max_turns=3, )The edit is made, but the run never returns the summary. What does the final ResultMessage report, and what fixes it?

  1. ASubtype success with an empty result; raise max_tokens so that the summary fits in the response
  2. BSubtype error_max_budget_usd; set max_budget_usd higher for the summary
  3. CSubtype error_during_execution; add Write to allowed_tools so that the summary can be saved
  4. DSubtype error_max_turns; set max_turns to 4, one more than the turns with tool calls
Show the answer and why
  • ASubtype success with an empty result; raise max_tokens so that the summary fits in the response

    Incorrect

    The output limit is not involved; the turn cap ends the run before the summary turn starts.

  • BSubtype error_max_budget_usd; set max_budget_usd higher for the summary

    Incorrect

    No budget cap is set, so no budget error is reported.

  • CSubtype error_during_execution; add Write to allowed_tools so that the summary can be saved

    Incorrect

    The summary is a text response, not a file, and nothing failed during execution.

  • DSubtype error_max_turns; set max_turns to 4, one more than the turns with tool calls

    Correct

    Count each turn with tool calls plus one for the final text-only response.

max_turns counts every turn with tool calls plus one for the final text-only response. Three tool turns use up max_turns=3, so the run ends with a ResultMessage of subtype error_max_turns and no final response.

Question 2 · choose 1

Your support agent uses the memory tool on the Messages API, and your server runs each memory command against a folder on disk. A security review finds that a crafted conversation got the agent to request a view of "/memories/../config/secrets.env", and your handler returned the file. What does the memory tool's documentation require of your handler?

  1. ANothing: the API checks each memory path before the tool_use block reaches your application
  2. BRun the memory commands in a second Claude request that decides whether each path is safe
  3. CReject any path that does not resolve inside the /memories directory before acting
  4. DMove the memory folder into the system prompt so that Claude reads it without any commands
Show the answer and why
  • ANothing: the API checks each memory path before the tool_use block reaches your application

    Incorrect

    The memory tool is client-side; your application runs the commands and must check them.

  • BRun the memory commands in a second Claude request that decides whether each path is safe

    Incorrect

    The guard belongs in your own handler code, not in another model call.

  • CReject any path that does not resolve inside the /memories directory before acting

    Correct

    The documentation states that the handler must reject paths outside /memories.

  • DMove the memory folder into the system prompt so that Claude reads it without any commands

    Incorrect

    That drops the memory tool rather than securing it, and loads every file into every request.

The memory tool operates client-side: Claude requests file operations and your application runs them against storage you control. Your handler must reject paths outside /memories, which is the path traversal protection the page describes.

Question 3 · choose 1

An Agent SDK coordinator runs with max_budget_usd set to 2.00 and spawns research subagents. Its trace shows the coordinator's own model calls costing about $0.40 when an attempt to spawn one more subagent fails with "Budget limit reached" and the background subagents still running are stopped. What explains this?

  1. AThe budget applies to each subagent separately, and one spent its own $2.00
  2. BThe subagents used up the coordinator's turn limit, which the SDK reports as a budget failure
  3. CThe cap counts only cached tokens, so the coordinator's uncached calls were not included
  4. DThe subagents' spend counts toward the same cap, and together the run reached $2.00
Show the answer and why
  • AThe budget applies to each subagent separately, and one spent its own $2.00

    Incorrect

    The cap is one total for the run, not a separate allowance per subagent.

  • BThe subagents used up the coordinator's turn limit, which the SDK reports as a budget failure

    Incorrect

    A turn limit ends a run with its own subtype, error_max_turns, not with a budget failure.

  • CThe cap counts only cached tokens, so the coordinator's uncached calls were not included

    Incorrect

    The cap is an estimated spend for the whole run, not a count of cached tokens.

  • DThe subagents' spend counts toward the same cap, and together the run reached $2.00

    Correct

    The budget cap covers subagents; once total spend reaches it, spawning fails and background subagents stop.

max_budget_usd caps the estimated spend of the whole run, and subagents' spend counts toward the total. Once spend reaches the cap, spawning another subagent fails with "Budget limit reached" and background subagents still running are stopped.

Question 4 · choose 1

Your loop sends stop_sequences ["END_REPORT", "END_TABLE"]. A response comes back with stop_reason "stop_sequence". How does your code tell which sequence ended the response?

  1. ABy searching the response text for both strings
  2. BBy reading the response's stop_sequence field
  3. CBy reading the last content block's type
  4. DBy sending the request again with one sequence at a time
Show the answer and why
  • ABy searching the response text for both strings

    Incorrect

    The documented way to see which sequence fired is the response's stop_sequence field, not the text.

  • BBy reading the response's stop_sequence field

    Correct

    stop_sequence names the custom stop sequence Claude emitted.

  • CBy reading the last content block's type

    Incorrect

    The block type does not name a stop sequence.

  • DBy sending the request again with one sequence at a time

    Incorrect

    The response already reports which sequence fired.

A stop_reason of stop_sequence means Claude emitted one of your custom stop_sequences. Read the response's stop_sequence field to see which one fired.

Question 5 · choose 1

Your Claude Agent SDK app logs every message of a long code-migration run. Late in the run the log shows a message with type "system" and subtype "compact_boundary". From then on, the agent stops following a naming rule that was given only in the first prompt. What does that message tell you?

  1. AThe SDK compacted the conversation near the context limit, replacing the older history with a summary
  2. BThe agent loop finished, and compact_boundary is the result subtype that reports a completed run
  3. CThe SDK removed the oldest tool results but kept every message and instruction word for word
  4. DThe session crashed and started again from a new init message with an empty context
Show the answer and why
  • AThe SDK compacted the conversation near the context limit, replacing the older history with a summary

    Correct

    compact_boundary marks automatic compaction, which summarizes older history, so early instructions may not survive it.

  • BThe agent loop finished, and compact_boundary is the result subtype that reports a completed run

    Incorrect

    The end of the loop is a ResultMessage; compact_boundary is a system message that marks compaction.

  • CThe SDK removed the oldest tool results but kept every message and instruction word for word

    Incorrect

    Compaction replaces older messages with a summary instead of keeping them as they were.

  • DThe session crashed and started again from a new init message with an empty context

    Incorrect

    init is the subtype that starts a session; compact_boundary marks compaction inside the running one.

When the context window approaches its limit, the Agent SDK automatically compacts the conversation: it summarizes older history to free space, keeps the most recent exchanges, and emits a system message with subtype compact_boundary. Because older messages are replaced with a summary, specific instructions from early in the conversation may not be preserved.

Practice domain 1 →Practice all domains →