Courseiva

CCNA Agents And The Agent Sdk Questions

42 questions · Agents And The Agent Sdk topic · All types, answers revealed

1
MCQmedium

A developer is building a support agent with the Claude Agent SDK. The agent must pause execution, ask a human operator to approve a refund above $500, and resume the exact same session with the operator's decision injected as a new message. Which SDK capability should the developer configure to accomplish this reliably?

A.Wrapping the refund tool in a retry loop that re-invokes the model until the operator approves in a separate chat window.
B.A custom tool whose handler blocks on stdin and returns the operator's typed answer as a tool_result.
C.Increasing max_tokens and instructing the model in the system prompt to ask for confirmation before calling the refund tool.
D.Permission callbacks combined with session persistence, so the agent suspends on the sensitive action and later resumes from the saved session state.
AnswerD

Permission callbacks let the SDK intercept a sensitive tool invocation and hand the decision to your code before execution, while session persistence saves the full conversation and pending state. Resuming the same session with the operator's decision injected as a new message continues the run exactly where it paused, which is the intended approval pattern.

Why this answer

Approval gates require an enforcement point plus durable state. Permission callbacks intercept the sensitive tool call before it executes, and session persistence stores the conversation so the run can be resumed later with the operator's decision appended. Together they suspend and continue the same session deterministically, which prompt instructions, blocking handlers, or retry loops cannot provide.

Exam trap

The trap here is assuming that telling the model to ask for confirmation in the system prompt is equivalent to an enforced human-approval pause.

2
Multi-Selecthard

A developer is implementing a multi-agent system using the Anthropic SDK where a 'Coordinator' agent delegates tasks to specialized 'Researcher' and 'Writer' agents via tool calls. The Coordinator must maintain a coherent conversation state and avoid redundant work. Which TWO of the following practices are essential for the Coordinator to effectively manage this delegation? (Choose two.)

Select 2 answers
A.Set the `temperature` to 0 for the Coordinator to ensure deterministic routing decisions.
B.Include the full conversation history, including all tool_use and tool_result blocks, in each subsequent request to the Coordinator so it can reason about prior delegations.
C.Define separate tools for each specialized agent (e.g., `delegate_to_researcher`, `delegate_to_writer`) with clear descriptions of their capabilities and expected inputs.
D.Implement a separate memory store (e.g., a database) that the Coordinator queries before each delegation to check if the task was already completed.
E.Use the `max_tokens` parameter to limit the Coordinator's response length, ensuring it does not generate overly long delegations.
AnswersB, C

The Messages API is stateless; the model does not retain memory between requests. To maintain context, the developer must include the entire conversation history, including tool_use and tool_result blocks, in each request. This allows the Coordinator to see what tasks have been delegated, what results were returned, and avoid redundant delegations.

Why this answer

Effective multi-agent coordination with the Anthropic SDK requires maintaining the full conversation history to provide context, and defining clear, well-described tools for each specialized agent. These practices enable the Coordinator to make informed delegation decisions and avoid redundancy. Other options are either not essential or potentially harmful.

Exam trap

The trap here is assuming that external memory or parameter tuning is necessary for multi-agent coordination, when the stateless API design means conversation history and tool definitions are the key mechanisms.

3
MCQmedium

Refer to the exhibit. Which step should you take first to resolve this tool invocation error?

A.Increase the temperature setting of the model.
B.Validate the tool schema against standard JSON Schema specifications.
C.Retry the request with a smaller context window.
D.Update the system prompt to be more descriptive.
AnswerB

The SDK requires tools to be defined as valid JSON Schema objects. Errors in this definition prevent the API from parsing the tool. Validating against the standard specification catches syntax issues that are often the root cause of '400 Bad Request' errors.

Why this answer

When encountering a schema error, validating the JSON against a strict JSON Schema standard is the most effective first step. Many errors stem from subtle syntax mistakes like missing commas, incorrect types, or invalid property names. Using a linter or schema validator ensures that the tool definition matches the requirements expected by the Anthropic SDK, which is essential for successful API calls.

Exam trap

Test-takers frequently assume they need to rewrite the entire application code or debug the model's weights instead of inspecting and validating the JSON schema format.

4
MCQeasy

A developer is designing an agent with the Anthropic SDK that must follow strict brand guidelines when drafting customer emails. The agent should never deviate from these rules regardless of how the user phrases a request. Where should the brand guidelines be placed to have the strongest effect?

A.In the assistant's previous reply, so the model imitates its own earlier tone.
B.In the first user message, so the model sees them before any other request.
C.In a tool description, so the model reads them whenever it considers using a tool.
D.In the system prompt, so they act as persistent instructions across the entire conversation.
AnswerD

The system prompt sets durable behavioral instructions that apply to every turn and carry more authority than user messages. Placing brand guidelines there ensures the agent treats them as non-negotiable constraints rather than suggestions that can be overridden by later user input.

Why this answer

The system prompt is the correct place for durable rules that must apply to every response, such as brand guidelines. It carries more weight than user turns and persists across the conversation, making it the strongest lever for preventing deviations regardless of how a request is phrased.

Exam trap

The trap here is treating the first user message as a lasting instruction, when user turns are requests that later turns and the model's own reasoning can override.

5
MCQmedium

Refer to the exhibit. An agent receives this response after attempting to use a 'fetch_url' tool. How will this specific block affect the agent's next reasoning step?

A.The model will ignore the result and repeat the exact same tool call.
B.The model will treat the error message as the successful content of the URL.
C.The model will interpret this as a signal to retry or handle the failure.
D.The SDK will automatically terminate the session to prevent further errors.
AnswerC

The 'is_error' field provides semantic context that the tool execution failed. This prompts Claude's reasoning engine to shift from 'processing data' to 'troubleshooting.' It might suggest checking the internet connection, trying a different URL, or informing the user that the resource is currently unavailable.

Why this answer

The 'is_error' flag is a critical signal to the model that the requested action did not succeed. By explicitly marking the result as an error, the SDK helps Claude understand that it needs to perform error recovery—such as retrying the request, checking the URL for typos, or reporting the failure to the user—rather than proceeding as if the data was retrieved.

Exam trap

Candidates mistakenly believe an error response terminates the agent's session. In reality, the SDK treats the 'is_error' flag as a cue for the model to initiate recovery or retry logic.

6
Multi-Selectmedium

When designing agentic loops with the Anthropic SDK, which TWO practices help prevent infinite tool-use cycles? (Select exactly 2)

Select 2 answers
A.Implementing a hard limit on the number of sequential tool calls.
B.Providing the agent with a 'terminate' or 'no-op' tool.
C.Increasing the max_tokens parameter to allow longer reasoning.
D.Using a higher temperature to encourage creativity.
E.Caching all tool outputs for faster retrieval.
AnswersA, B

Tracking the iteration count and forcing termination after a defined threshold prevents the agent from infinitely searching or processing data. This is a standard safety pattern that protects your infrastructure from runaway costs and ensures the agent provides an answer even if imperfect.

Why this answer

Preventing infinite loops is crucial for cost management and system stability. By enforcing step limits and providing clear stop conditions, developers ensure the agent acts as a bounded processor. These patterns are fundamental to building predictable AI agents that fulfill user requests without falling into recursive tool-calling patterns that exhaust token budgets and latency thresholds.

Exam trap

Candidates focus on complex logic to 'fix' the agent mid-loop, ignoring that simple constraints like hard limits or specific termination tools are the most effective ways to prevent infinite recursion.

7
MCQeasy

A developer's agent calls a weather API tool but Claude keeps emitting the tool call with a misspelled parameter name that the API rejects. The tool definition and the API schema disagree. What is the most likely cause?

A.The model's temperature is set too low, causing it to repeat an earlier mistake.
B.The system prompt does not explicitly forbid the model from inventing parameter names.
C.The tool's input_schema does not accurately describe the parameter names and types the handler expects.
D.The tool_result returned to the model is too long, so the model forgets the correct parameter names.
AnswerC

The model generates tool inputs based on the declared input_schema. If that schema lists parameter names or types that differ from what the handler and API require, the model will faithfully produce the wrong shape. Aligning the schema with the handler's expectations is the direct fix.

Why this answer

Tool inputs are generated from the declared input_schema, so any divergence between that schema and the handler's real expectations surfaces as malformed arguments. The model is not guessing; it is following the contract it was given. Correcting the schema to match the API and handler resolves the misspelled or mistyped parameter problem at its source.

Exam trap

The trap here is blaming model behavior or prompt wording when the real defect is a mismatch between the declared tool schema and the handler's actual contract.

8
MCQeasy

What is the primary role of the 'system' role in a message sequence for an agent?

A.To store the conversation history for later analysis.
B.To define the agent's goals, constraints, and operational context.
C.To handle errors generated by the agent's tools.
D.To provide the user's input to the assistant.
AnswerB

The system message is designed to define the agent's identity and operational rules. By setting these instructions here, developers provide a stable frame of reference that persists across the interaction, ensuring the model stays aligned with business and functional requirements.

Why this answer

The system role is used to set the behavioral boundaries, persona, and overall instructions for the agent. Unlike user or assistant roles, it operates at a higher level of abstraction, guiding the agent's decision-making and constraint adherence throughout the conversation. It is the foundation for defining the agent's purpose and operational scope before any specific task is processed.

Exam trap

Many candidates confuse the system role with conversational turns, incorrectly placing system instructions inside the alternating user and assistant message sequence.

9
MCQhard

An agent built with the Anthropic SDK is processing a long conversation and begins to exceed the model's context window. The developer wants to preserve recent turns and key facts while reducing token usage. Which approach best matches how the SDK and Claude are designed to handle this?

A.Summarize older portions of the conversation into a compact message and prepend it, keeping the most recent turns verbatim.
B.Rely on the model's built-in long-term memory to automatically recall earlier turns without resending them.
C.Increase the temperature setting so the model can compress the conversation on its own.
D.Remove all prior messages and send only the latest user turn to avoid any risk of exceeding the limit.
AnswerA

Claude has no persistent memory between API calls, so the developer must manage context explicitly. Replacing older turns with a summary preserves semantically important facts while freeing tokens for recent dialogue. This is the standard pattern for long-running agents because it keeps the conversation coherent without exceeding the context window.

Why this answer

Because the API is stateless, context management is the developer's responsibility. Summarizing older conversation segments while retaining recent turns verbatim balances token economy with continuity. This pattern is widely used in long-running agents to stay within the context window without losing the facts that matter.

Exam trap

The trap here is believing that Claude maintains conversation memory across API calls, when in fact every request must resend the context the model needs.

10
MCQeasy

In the context of the Anthropic Agent SDK, what is the primary role of the 'Orchestrator' component?

A.Generating the final CSS styles for the agent's user interface.
B.Managing the loop between model reasoning and tool execution.
C.Storing the model's weights on the local file system for offline use.
D.Compressing images before they are sent to the vision-capable model.
AnswerB

The primary function of the Orchestrator is to maintain the 'thought-action-observation' loop. It parses the model's 'tool_use' blocks, triggers the corresponding code, captures the output, and formats it into 'tool_result' blocks for the next turn, ensuring the agent continues working until the final goal is achieved.

Why this answer

The Orchestrator acts as the central brain of the agentic loop, managing the cycle of sending prompts to the model, receiving tool calls, executing those tools, and feeding the results back. It abstracts the complexity of message management and ensures that the conversation flows logically between the AI and the available external capabilities.

Exam trap

Candidates often confuse the 'Orchestrator' with the 'Model' itself. The Orchestrator is the framework component that manages the loop, not the LLM performing the reasoning.

11
MCQeasy

When defining a tool for an agent using the Anthropic SDK, which field is required to ensure the model understands the specific schema of the input arguments?

A.The 'examples' array within the tool definition.
B.The 'input_schema' property using JSON Schema format.
C.A 'system_prompt' specific to that individual tool.
D.The 'output_format' property for return values.
AnswerB

The input_schema property is the core component that tells Claude exactly what parameters a tool accepts. By using standard JSON Schema, developers can specify required fields, data types like strings or integers, and even complex nested objects, ensuring the model's tool_use block is perfectly formatted for the backend function.

Why this answer

The input_schema field is mandatory because it uses JSON Schema to define the structure, types, and constraints of the data the agent must provide. Without this schema, the model cannot reliably generate valid tool calls that match the underlying function's expectations, leading to runtime errors and failed executions in the agentic workflow.

Exam trap

Candidates frequently confuse the general description field with the specific parameter definition property required for structured inputs.

12
MCQhard

A developer is building an agent that runs shell commands to inspect a repository. They want the agent to iterate autonomously but prevent destructive commands like deleting files outside the project directory. Which combination best enforces this boundary while preserving autonomy?

A.Route shell commands through a permission callback that inspects each command and denies those targeting paths outside the project directory.
B.Restrict the agent to read-only tools and remove shell execution entirely from its toolset.
C.Lower the model's max_tokens so it cannot compose long destructive command strings.
D.Rely on the system prompt instructing the model to never run destructive commands.
AnswerA

A permission callback intercepts each tool invocation before execution, allowing programmatic inspection and denial of unsafe commands while permitting legitimate ones. This enforces a hard boundary in application code and lets the agent continue autonomous iteration within the allowed scope, matching the requirement to constrain without disabling.

Why this answer

Safety boundaries for autonomous agents must be enforced outside the model's discretion. A permission callback inspects every shell invocation before it runs and denies those reaching outside the project directory, which blocks destructive operations while still allowing the agent to iterate freely on permitted commands. Prompt guidance and token limits are advisory or orthogonal, and removing shell access discards needed capability.

Exam trap

The trap here is believing that a strong system prompt instruction provides a security guarantee equivalent to code-level enforcement.

13
MCQmedium

When deploying an agent that uses the Model Context Protocol (MCP), what is the primary security risk of allowing the agent to dynamically discover and connect to any local MCP server?

A.The agent might use too many tokens while browsing the server's tool list.
B.The agent could gain unauthorized access to local files or system resources.
C.The model might become confused by having too many tools available.
D.The MCP protocol might slow down the model's inference speed.
AnswerB

MCP servers run with the permissions of the user who started them. If an agent is allowed to connect to a server that has access to the entire file system or sensitive environment variables, a prompt injection or a reasoning error could lead to the agent deleting files or exfiltrating private data.

Why this answer

Dynamic discovery without strict authorization can expose sensitive local data or system capabilities to the agent. If an agent connects to a malicious or unintended MCP server, it could be tricked into executing harmful commands or leaking private information. Implementing a whitelist of trusted servers is a fundamental security practice for agentic systems.

Exam trap

Candidates often assume MCP is inherently secure and trust any local server. They overlook that dynamic discovery without a whitelist allows the agent to interact with malicious or unauthorized local processes.

14
MCQhard

In an agentic flow, what is the impact of providing redundant tool descriptions that overlap in functionality?

A.It improves the agent's ability to handle errors.
B.It decreases the agent's reliability and increases ambiguity.
C.It allows the agent to cache results more efficiently.
D.It forces the model to use all tools in every turn.
AnswerB

Ambiguity in tool definitions makes it difficult for the model to make consistent choices. This lack of clear differentiation leads to fragmented reasoning, where the agent may attempt to use multiple tools for the same task, wasting resources and reducing output quality.

Why this answer

Overlapping tool descriptions create ambiguity, leading to 'non-deterministic' selection behavior. When an agent is unsure which tool to choose for a specific task, it may pick the wrong one or fall into a loop of trying multiple tools unnecessarily. This reduces efficiency, increases token consumption, and degrades the user experience by introducing potential execution errors or delays in task completion.

Exam trap

Candidates assume that providing more information for tools is always better, failing to realize that redundant or overlapping descriptions confuse the model, leading to non-deterministic, unpredictable, and inefficient tool selection.

15
MCQmedium

A developer is building a Claude agent using the Anthropic Agent SDK. The agent must be able to fetch the current stock price for a given ticker symbol. The developer defines a tool named 'get_stock_price' with an input schema that requires a single string parameter 'ticker'. During testing, the agent responds with a final text answer containing a plausible-looking price, but the tool is never invoked. Which is the most likely cause?

A.The tool description field is missing or too vague, so the model does not understand when to use the tool and instead answers from its own knowledge.
B.The tool's JSON schema uses 'type': 'string' for the 'ticker' parameter, but the agent expects an 'enum' of valid tickers.
C.The tool's input schema declares 'ticker' as required, but the model cannot provide a value because the user did not specify a ticker symbol.
D.The agent's system prompt does not include the phrase 'You must use tools when available', so the model ignores the tool.
AnswerA

The model decides which tool to call based primarily on the tool's name and description. If the description is missing or does not clearly explain the tool's purpose, the model may not realize it should call the tool for stock prices and may instead generate a plausible answer from training data. A clear description is essential for reliable tool invocation.

Why this answer

The model selects tools based on their name and description. A missing or vague description means the model lacks the information needed to connect the user's request to the tool, so it answers from its own knowledge instead of calling the tool. Providing a clear, specific description that explains what the tool does and when to use it is critical for reliable tool invocation in the Anthropic Agent SDK.

Exam trap

The trap here is assuming that a tool will be called simply because it is defined, without ensuring its description clearly communicates its purpose to the model.

16
MCQhard

A developer writes an agent loop that handles Claude's tool_use blocks by executing each tool and appending a user message containing the tool_result blocks. In production, a request occasionally triggers a 400 error stating that the tool_use ids were not found. Reviewing the code, the developer sees the loop builds each new request by sending only the latest user message and the newest tool_result message, discarding earlier turns to save tokens. Which action resolves the error while preserving the agent's behavior?

A.Generate a new UUID for each tool_result block and set the tool_use_id field to that fresh value so the results appear unique to the API.
B.Switch the loop to the Batches API so that multi-turn tool exchanges are processed together and prior messages are retained on the server.
C.Send the complete conversation history on every request, including the assistant turn containing the tool_use blocks that the tool_result messages reference.
D.Reduce the number of tools passed in the tools parameter so that fewer tool_use blocks are generated and fewer ids need to be matched.
AnswerC

The API is stateless, so each request must carry the full prior conversation. A tool_result block is only valid when the same request also includes the assistant message holding the corresponding tool_use block. Trimming those earlier turns strips the referenced ids, producing exactly the 400 error described. Restoring the full history, or a window that still contains each referenced tool_use turn, fixes it.

Why this answer

Because the Messages API holds no server-side session, every request must include the prior assistant turn that emitted the tool_use blocks alongside the tool_result messages that cite those ids. Trimming history to save tokens removed the referenced blocks, so the API rejected the orphaned results. Sending the complete history, or a window that retains each referenced tool_use turn, restores valid correlation.

Exam trap

The trap here is treating the API as if it remembered earlier turns, so trimming history looks harmless until the referenced tool_use ids go missing.

17
MCQeasy

Why should you avoid including sensitive personal data (PII) in the tool results returned to an agent?

A.It significantly slows down the model inference time.
B.It reduces the model's reasoning capabilities.
C.It increases the risk of data leakage via the model's history.
D.The model cannot understand PII formats.
AnswerC

Data included in the conversation history becomes persistent in logs and context windows. If PII is included, it is effectively stored in an environment where it might be exposed, violating privacy policies and increasing the surface area for potential security breaches.

Why this answer

PII returned to an agent becomes part of the conversation history, which is often logged or cached for model context. This increases the risk of inadvertent data exposure. By scrubbing PII before passing tool results to the model, developers maintain security compliance and ensure that sensitive data is not unnecessarily processed or retained by AI infrastructure, aligning with enterprise data protection standards.

Exam trap

Test-takers often assume sensitive data is secure in model memory or logs, overlooking the risk that tool results persist in conversation history and logs.

18
Multi-Selecthard

Which THREE strategies are effective for improving the reliability of an agent in production environments? (Select exactly 3)

Select 3 answers
A.Implementing strict input and output schema validation.
B.Adding human-in-the-loop checkpoints for critical actions.
C.Continuous monitoring and logging of tool invocation success.
D.Increasing the model's temperature to 1.5 for variety.
E.Hardcoding every possible user query path.
AnswersA, B, C

Validation ensures that only correctly formatted data enters or leaves the system. This prevents type errors and malformed JSON from breaking the agentic loop, which is a major source of production outages in AI-based software architectures.

Why this answer

Production-grade agents require proactive management. Robust schema validation catches input errors early; comprehensive monitoring provides visibility into agent performance and failure modes; and human-in-the-loop patterns for high-stakes tasks provide a critical safety net. Together, these practices form a defense-in-depth strategy that ensures the agent performs reliably under real-world conditions where unpredictability is the norm.

Exam trap

Test-takers often rely solely on prompt engineering for production reliability, neglecting critical architectural safeguards like schema validation and human-in-the-loop checkpoints.

19
MCQmedium

An agent using the SDK encounters an error where it generates a tool call for a tool that does not exist in its configuration. Which adjustment to the agent's setup is most likely to resolve this hallucination?

A.Enabling 'force_tool_use' to ensure it only uses one of the existing tools.
B.Refining the system prompt to clearly define the boundaries of available tools.
C.Switching the model from Claude 3.5 Sonnet to Claude 3 Haiku.
D.Increasing the max_tokens parameter to allow for more reasoning.
AnswerB

A well-defined system prompt serves as a 'source of truth' for the agent. By explicitly stating 'You only have access to tools X, Y, and Z,' and describing their specific use cases, you reduce the likelihood of the model attempting to invent a 'convenient' tool that doesn't actually exist in the SDK.

Why this answer

Hallucinating non-existent tools usually occurs when the model is aware of a capability but hasn't been given the structured definition for it, or when the system prompt is ambiguous. Refining the system prompt to explicitly list the available tools and their purposes helps ground the model's reasoning in the provided technical context.

Exam trap

Candidates often try to fix hallucinations by adding more tools. This ignores the root cause: the model lacks clear guidance on which tools are actually available in the current context.

20
MCQhard

An agent is performing a 'Computer Use' task that requires taking multiple screenshots and moving the cursor. The model generates a tool_use block for 'screenshot' and 'mouse_move' in a single turn. How should the SDK-based orchestrator handle this response to ensure reliable execution?

A.Execute both tools in parallel to minimize latency for the user.
B.Wait for the model to issue a separate turn for each individual tool.
C.Process the tools sequentially and return all results in the next turn.
D.Only execute the first tool and ignore all subsequent blocks.
AnswerC

Sequential processing ensures that the environment reaches a stable state after each action. By executing the mouse move first and then taking the screenshot, the orchestrator provides Claude with accurate visual feedback of the result of its action, which is fundamental for the iterative loop of the computer use capability.

Why this answer

Reliable computer use requires strict sequential execution of actions because each step modifies the visual state of the environment. If the orchestrator attempts to parallelize these actions, the 'screenshot' might capture the screen before the 'mouse_move' is finished, leading to incorrect state feedback for the model and causing the agent to fail its task.

Exam trap

Test-takers often assume all tool calls in a single turn should be processed in parallel for speed, ignoring environment dependencies.

21
Multi-Selecthard

A developer is implementing a 'Human-in-the-loop' (HITL) pattern for an agent that performs financial transactions. Which TWO strategies are most important for maintaining the security and reliability of this agentic workflow?

Select 2 answers
A.Providing the human with a clear diff of the proposed transaction data.
B.Allowing the agent to bypass human approval if its confidence score is high.
C.Feeding the human's rejection feedback directly back into the agent's context.
D.Obfuscating the tool names from the human to prevent cognitive overload.
E.Using a shorter system prompt to ensure the agent acts more autonomously.
AnswersA, C

A clear visual representation of what the agent intends to do—such as the amount, recipient, and currency—allows the human to quickly verify the action. Without this transparency, the 'approval' becomes a blind click, defeating the purpose of having a human reviewer to prevent hallucinated or malicious tool arguments.

Why this answer

HITL is essential for high-stakes tasks where model errors could have significant real-world consequences. By introducing a manual approval step, developers can ensure that the agent remains within its defined boundaries. Clear communication of the agent's intent and a robust mechanism for human rejection are key pillars of this safety architecture.

Exam trap

Candidates often focus only on the approval step, forgetting that providing the human's rejection feedback back to the agent is critical for enabling the model to learn and correct its path.

22
MCQeasy

A developer is creating an agent that uses the Anthropic SDK to answer customer support questions. The agent has access to a tool that retrieves order status from an internal API. During testing, the developer notices that the agent sometimes provides an order status without calling the tool, resulting in incorrect information. What is the most likely cause of this behavior?

A.The agent's system prompt does not include the current date, so the model cannot determine order freshness.
B.The `tool_choice` parameter is set to `{"type": "auto"}`, which allows the model to ignore tools.
C.The tool's description is too vague, so the model does not understand when it should be used.
D.The model's temperature is set too high, causing it to hallucinate tool calls.
AnswerC

The model relies on the tool's name and description to decide when to invoke it. If the description is vague or does not clearly state that the tool retrieves order status, the model may not recognize the need to call it and instead fabricate an answer. Clear, specific descriptions are critical for correct tool use.

Why this answer

The most likely cause is a vague tool description. The model uses the description to understand the tool's purpose and when to invoke it. If the description does not clearly explain that the tool retrieves order status, the model may answer from its own knowledge, leading to incorrect information.

Improving the description will guide the model to use the tool appropriately.

Exam trap

The trap here is blaming model parameters like temperature or tool_choice, when the real issue is often the clarity of the tool's description and instructions.

23
MCQhard

A developer is creating a multi-agent system where a coordinator agent delegates subtasks to specialized agents. Each specialized agent has its own tools and system prompt. The coordinator needs to know when a subtask is complete and what result was produced. Which design best fits the Anthropic SDK's stateless model?

A.Have the coordinator and specialized agents share a single conversation history that all agents append to directly.
B.Have all specialized agents run in parallel and write their outputs to a shared memory store that the model reads automatically.
C.Have the coordinator invoke each specialized agent as a tool, passing the subtask as input and receiving the agent's final result as the tool output.
D.Have the coordinator emit a plain text message describing the subtask and rely on the specialized agent to detect it by polling.
AnswerC

Treating a specialized agent as a tool gives the coordinator a structured way to delegate and receive results within the same request cycle. The coordinator emits a tool_use block, the application runs the sub-agent to completion, and the result returns as a tool_result. This aligns cleanly with the stateless API and keeps orchestration logic in one place.

Why this answer

Because each API call is independent, delegation is best modeled as a tool call: the coordinator requests a sub-agent by name, the application runs it and returns the result as tool output. This creates an explicit contract for completion and results, and it keeps each specialized agent's tools and system prompt isolated.

Exam trap

The trap here is assuming agents can share live memory or poll each other, when the API is stateless and every interaction must be explicit in the request.

24
MCQmedium

Refer to the exhibit. A developer is configuring an MCP server to provide an agent with database access. What is the primary purpose of the 'args' field in this configuration block?

A.It defines the JSON Schema for the tools provided by the SQLite server.
B.It specifies the command-line flags and parameters used to initialize the server.
C.It lists the specific SQL queries the agent is permitted to execute.
D.It acts as a whitelist for authorized users of the SQLite server.
AnswerB

The 'args' array contains the specific flags—like the database path—required by the executable to function correctly. This is how the developer bridges the gap between the Agent SDK's request for a server and the specific local configuration needed to make that server's data accessible to the agent.

Why this answer

The 'args' field provides the necessary runtime parameters for the MCP server process. In this specific exhibit, it tells the 'uvx' command which package to run and which specific database file to mount. Correct configuration of these arguments is vital for the agent to successfully connect to the intended external resource.

Exam trap

Candidates often confuse 'args' with the tool's input parameters. In the context of MCP server configuration, 'args' refers to the command-line flags used to launch the server process itself.

25
MCQhard

You are debugging an agent that often fails to format its final response as JSON, despite being instructed in the system prompt. Which technique is most effective for ensuring consistent output structure?

A.Adding a 'Please provide JSON' phrase at the end of the prompt.
B.Utilizing a tool to force the output into a structured schema.
C.Lowering the system prompt length to reduce ambiguity.
D.Retrying the call automatically until valid JSON is returned.
AnswerB

Defining a tool that expects the final answer as its input forces the model to generate the JSON parameters that match the schema. This creates a hard constraint that the model must satisfy to execute the tool, ensuring the output is perfectly formatted.

Why this answer

Forcing the output structure through constrained generation is the most robust way to ensure valid JSON. While system prompts set expectations, they are soft constraints. Using tool-use or structured output features allows the agent to adhere to a schema, which guarantees the output is machine-readable and prevents parsing errors in downstream applications.

Exam trap

Candidates rely heavily on system prompt 'formatting' instructions, failing to realize that LLMs are not guaranteed to follow text-based constraints and require structured schema enforcement for reliable output.

26
MCQmedium

When sharing state between multiple agent turns, why is it recommended to use a managed session object instead of appending everything to a simple list of messages?

A.It guarantees that all messages are stored in a database.
B.It enables intelligent context pruning and summarization.
C.It automatically encrypts all user inputs for privacy.
D.It makes the model faster by skipping validation.
AnswerB

Managed sessions enable the application to intelligently decide which parts of history to drop or summarize. This keeps the prompt focused and within token limits, which is essential for maintaining model performance over long, multi-turn interactions where history might otherwise become unmanageable.

Why this answer

Managed state objects allow for intelligent context truncation and summarization. In complex agent workflows, message histories can quickly exceed the model's context window. A robust session manager handles pruning older turns, maintaining critical environment variables, and ensuring the model receives only the most relevant information for the current task, which is critical for long-running autonomous processes.

Exam trap

Candidates assume that storing all message history is sufficient, failing to account for the model's context window limits and the performance degradation caused by sending excessively long, unpruned message lists.

27
MCQmedium

An agent developer is building a workflow where an agent must query a private database. To ensure the agent only performs read operations, which component of the Anthropic Agent SDK pattern should be prioritized?

A.A complex system prompt with strict negative constraints.
B.The Agent SDK's built-in session state management.
C.A strictly defined tool schema limited to read-only functions.
D.The model's internal safety filtering layer.
AnswerC

Defining a tool schema that only supports specific read queries ensures the model lacks the functional capacity to perform write or delete operations. By limiting the toolset, the developer hardcodes the security boundary, which is the most reliable way to prevent unauthorized data modification.

Why this answer

Tool definitions are the primary mechanism for restricting agent capabilities. By explicitly defining the schema and purpose of the tool, the developer enforces the principle of least privilege. The agent only executes what is provided in the tools list, making it vital to sanitize inputs and restrict access permissions at the API level rather than relying solely on natural language instructions within the system prompt.

Exam trap

Candidates rely on system prompt instructions to 'restrict' the agent, forgetting that system prompts are suggestions, not security boundaries; the tool schema itself must be the primary restriction mechanism.

28
MCQeasy

A developer is building a Claude agent with the Anthropic SDK that must look up live order status. The agent has one tool named get_order_status, and its input_schema declares a required string property order_id. During testing, Claude returns a tool_use block with name "get_order_status" and input {"order_id": "A-4471"}. What must the developer's application do next to keep the agent loop running correctly?

A.Call the tool, then send the raw JSON output as a plain assistant text message so Claude can read the order details directly.
B.Append Claude's tool_use block to the conversation and immediately call the Messages API again with the same parameters to obtain the final answer.
C.Convert the tool_use block into a system message so the model treats the tool request as persistent instructions for the rest of the session.
D.Execute the lookup, then send a user-role message containing a tool_result block with the matching tool_use_id back to Claude.
AnswerD

This is the required half of the agent loop: the client executes the tool and returns its output to Claude as a tool_result content block inside a user-role message, with tool_use_id matching the originating tool_use block. Only then can Claude continue reasoning with the real data. This scenario's single tool call maps directly onto that pattern.

Why this answer

The agent loop alternates model reasoning with client-side tool execution. When Claude emits a tool_use block, the developer's code runs the named tool and returns the output as a tool_result content block in a user message, keyed by the same tool_use_id. That correlation lets Claude pair the result with its request and produce the final answer using real order data.

Exam trap

The trap here is assuming the model executes tools itself, when in fact the client application must run the tool and return a correlated tool_result block.

29
MCQmedium

A developer is building an agent using the Anthropic Python SDK. The agent's system prompt instructs it to answer questions about a company's internal policies by searching a vector database. The developer wants the agent to autonomously decide when to search and when to answer directly. Which combination of API features should the developer implement to achieve this?

A.Define a tool that queries the vector database, include it in the `tools` parameter of the Messages API request, and handle `tool_use` blocks in the response by executing the search and returning a `tool_result` block.
B.Use the `system` parameter to embed the entire vector database content as context, allowing the model to answer directly without tool use.
C.Implement a pre-processing step that always queries the vector database and appends the top result to the user's message before sending it to the model.
D.Set the `tool_choice` parameter to `{"type": "any"}` so the model always calls the vector search tool, and then parse the result to generate the final answer.
AnswerA

This approach correctly uses the Messages API's tool use capability: the model autonomously emits a `tool_use` block when it needs to search, and the developer provides the result via a `tool_result` block. The agent decides when to invoke the tool based on the system prompt and conversation context, fulfilling the requirement for autonomous decision-making.

Why this answer

The correct approach is to define the vector search as a tool, include it in the request, and handle the tool_use/tool_result cycle. This enables the model to decide when to search based on the conversation, which is the core of agentic behavior with the Anthropic SDK. Other options either force tool use, embed excessive context, or bypass the model's decision-making entirely.

Exam trap

The trap here is assuming that tool use must be forced or pre-processed, rather than allowing the model to autonomously decide when to invoke a tool based on its instructions.

30
MCQmedium

A developer is using the Anthropic SDK to build an agent that can answer questions by calling external APIs. The agent's tool returns a large JSON payload (over 100,000 tokens) as a `tool_result`. The developer notices that subsequent requests to the model fail with a context window error. What is the most effective way to resolve this issue?

A.Increase the `max_tokens` parameter in the request to accommodate the large tool result.
B.Set the `tool_choice` parameter to `{"type": "none"}` to prevent the model from calling the tool again.
C.Switch to a model with a larger context window, such as Claude 3.5 Sonnet, without modifying the tool result.
D.Truncate or summarize the tool result before including it in the conversation history.
AnswerD

The context window includes all messages, including tool results. A 100,000-token tool result will exceed the model's context limit. The most effective solution is to truncate or summarize the result to a manageable size, preserving only the necessary information. This reduces token usage and allows the conversation to continue without errors.

Why this answer

The most effective solution is to truncate or summarize the tool result before adding it to the conversation history. The context window includes all input tokens, so a massive tool result will cause errors. By reducing the size, the developer ensures the conversation stays within limits.

Other options do not address the root cause of the oversized input.

Exam trap

The trap here is confusing `max_tokens` with context window management, or assuming that switching models alone can handle arbitrarily large inputs.

31
MCQmedium

When an agent is asked to perform a complex task, which approach minimizes latency while ensuring accuracy?

A.Requesting the model to solve the entire problem in one turn.
B.Decomposing the task into smaller, chained agent actions.
C.Using the maximum possible context window for every request.
D.Adding 'think step-by-step' to the final response request.
AnswerB

Task decomposition allows the model to verify its progress at each step. By chaining actions, the agent manages complexity effectively, reducing the likelihood of catastrophic errors while making the entire process more transparent and easier to monitor for performance.

Why this answer

Breaking down a complex task into smaller, sequential tool-use steps allows the model to reason incrementally. This approach reduces the load per turn, makes errors easier to isolate, and improves overall accuracy by allowing the model to process feedback at each stage. While it increases the total number of turns, it is often faster than forcing a single, massive inference that may fail entirely.

Exam trap

Candidates frequently choose a single massive prompt to solve complex tasks, believing it saves time, rather than breaking the problem down into chained agent actions.

32
MCQhard

An agent is designed to manage a user's calendar. During a session, the user asks to 'Schedule a meeting for tomorrow at 2 PM.' The agent must first check for conflicts and then create the event. How should the developer handle the 'observation' phase in the SDK to ensure the agent doesn't double-book?

A.Use a single tool that both checks for conflicts and creates the event.
B.Feed the 'check_conflicts' tool_result back to the model before it issues 'create_event'.
C.Parallelize both calls to improve the speed of the calendar update.
D.Prompt the model to assume there are no conflicts to save tokens.
AnswerB

By returning the conflict data as a 'tool_result', you allow Claude to see the current state of the calendar. The model can then reason: 'I see a conflict at 2 PM, I should not call create_event; instead, I will suggest 3 PM to the user.' This creates a safer and more helpful agent.

Why this answer

The observation phase involves feeding the actual results of a tool (the calendar check) back into the agent's context. If the agent doesn't receive the output of the conflict check before it attempts to create the event, it is 'flying blind.' Ensuring the orchestrator waits for the first tool's result before proceeding is key to logical consistency.

Exam trap

Candidates often assume the model can issue multiple tool calls simultaneously without waiting for results, missing the crucial step of feeding the first observation back into the context.

33
Multi-Selectmedium

A developer is building an agent that must decide when to call tools versus when to respond directly to the user. The agent uses the Anthropic SDK with tool definitions supplied in the request. Which TWO behaviors correctly describe how the model handles tool use in this setup? (Choose two.)

Select 2 answers
A.The model can return a normal text response instead of a tool_use block when it determines no tool is required.
B.The model emits a tool_use block containing the tool name and input arguments when it decides a tool is needed.
C.The model requires the tool's input_schema to be omitted so it can choose parameters freely.
D.The model automatically retries a failed tool call until it succeeds without developer intervention.
E.The model executes the tool itself and returns the result directly in the same response.
AnswersA, B

Tool use is optional from the model's perspective. If the user's request can be answered from existing context, Claude may reply with text and no tool_use block. The developer's loop should handle both outcomes, which is why checking the stop reason and content blocks is essential.

Why this answer

Claude decides whether to call a tool and, if so, emits a tool_use block with the name and arguments; it may also answer directly with text when no tool is needed. The application, not the model, performs execution and returns results, which is why the agent loop must handle both tool_use and plain text outcomes.

Exam trap

The trap here is assuming the model runs the tool and returns its output, when it only requests the tool and waits for the application to supply the result.

34
MCQmedium

A developer is building a customer support agent using the Anthropic SDK. The agent must call a 'get_order_status' tool that requires an order ID. During testing, the agent sometimes invents plausible-looking order IDs instead of asking the user. Which change to the tool definition will most directly reduce this behavior?

A.Increase the 'max_tokens' setting so the model has more room to reason before emitting the tool_use block.
B.Set 'input_schema' to an empty object so the model is forced to ask the user for all parameters.
C.Add a detailed 'description' field to the tool that explains when to use it and explicitly instructs the model not to guess missing parameters.
D.Change the tool name to 'lookup_order' so it sounds more like a retrieval operation.
AnswerC

The tool description is the primary place to encode usage guidance, including when the tool is appropriate and how to handle missing required inputs. Stating that the model must not fabricate an order ID and should instead ask the user directly addresses the observed failure mode without altering the schema or adding external logic.

Why this answer

The tool description is the model's instruction manual for when and how to invoke a tool. By explicitly stating that the agent must request an order ID from the user rather than guessing, the developer directly targets the observed hallucination. Schema changes, token limits, and renaming do not convey that behavioral rule.

Exam trap

The trap here is assuming that changing a tool's name or schema shape will fix a behavioral problem that is actually caused by missing usage instructions in the description.

35
Multi-Selectmedium

Which THREE of the following are essential components of a well-defined tool for an agent? (Select exactly 3)

Select 3 answers
A.A clear, descriptive name and description.
B.A JSON schema defining the required parameters.
C.The implementation logic (function code) to perform the task.
D.A pre-trained model checkpoint for the tool.
E.A hardcoded response for every possible input.
AnswersA, B, C

The model relies entirely on the name and description to decide when a tool is appropriate for a given task. If these are vague or misleading, the model will struggle to select the correct tool at the right time, leading to execution errors.

Why this answer

Robust tools require clear documentation for the model, a strict schema for input validation, and a well-defined execution function. These three components work in concert to ensure the agent understands what the tool does, how to provide data to it, and how the system handles the resulting logic. Missing any of these leads to unpredictable agent behavior and failure to resolve tasks.

Exam trap

Candidates often select only the schema or the name and description, forgetting that the actual function implementation code is equally vital for the system to execute the requested task.

36
MCQhard

An agent built with the Claude Agent SDK runs a long research task and repeatedly hits the model's context window limit. The developer wants the agent to keep working without losing critical earlier findings. Which approach best addresses this?

A.Enable automatic context compaction so older turns are summarized into a condensed form while key findings are retained in the running context.
B.Raise the temperature so the model generates shorter responses and consumes fewer tokens per turn.
C.Restart the agent from scratch each time the limit is reached, relying on the model to re-derive earlier findings from the task prompt.
D.Increase the model's max_tokens parameter so each response can be longer and the context window is used more efficiently.
AnswerA

Context compaction summarizes or truncates older conversation content when the window fills, preserving essential information while freeing space for new turns. This lets a long-running agent continue past the raw token ceiling without discarding the findings it still needs, which is exactly the failure mode described in the scenario.

Why this answer

Long-running agents need a strategy for the finite context window. Compaction condenses older turns into summaries or retained highlights, freeing tokens while keeping the findings the agent depends on. Sampling parameters and response-length caps do not reclaim history, and restarting loses state, so compaction is the mechanism that lets the run continue coherently.

Exam trap

The trap here is confusing response-length controls like max_tokens or temperature with the separate problem of total accumulated conversation size.

37
MCQmedium

You are designing a multi-agent system where a 'Router' agent directs tasks to a 'Research' agent or a 'Writer' agent. What is the most efficient way to maintain state when the Research agent completes its task and needs to hand back control?

A.Persisting the Research agent's output to a global database for the Router.
B.Appending the Research agent's tool results to the main message thread.
C.Restarting the entire session with the Research output as a new prompt.
D.Using a separate API key for each agent to isolate their environments.
AnswerB

The Agent SDK thrives on message history; by appending the results of the specialized agent's work to the shared message thread, the Router can see exactly what was accomplished. This follows the standard Anthropic message protocol where tool outputs and assistant responses form a coherent narrative for the model.

Why this answer

Handoffs in multi-agent systems rely on passing the conversation history or a summarized state between specialized instances. This ensures that the Router has the necessary context to decide the next step without losing the progress made by the Research agent. Proper state management prevents redundant work and keeps the agentic flow aligned with the user goal.

Exam trap

Test-takers often suggest resetting the conversation or starting a new thread, which destroys the context needed for multi-agent coordination.

38
Multi-Selectmedium

When implementing a 'Computer Use' agent, which THREE capabilities are provided by the standardized Anthropic beta tools 'computer', 'text_editor', and 'bash'?

Select 3 answers
A.Capturing screenshots and performing mouse/keyboard interactions.
B.Rewriting entire binary files to optimize system performance.
C.Executing arbitrary shell commands in a controlled environment.
D.Viewing, creating, and editing files using specific line-based commands.
E.Automatically upgrading the host operating system to the latest version.
AnswersA, C, D

The 'computer' tool is specifically designed for GUI interaction. It provides the model with the ability to see the screen via screenshots and interact with it by sending clicks, key presses, and cursor movements, enabling the agent to navigate traditional desktop software as a human user would.

Why this answer

Anthropic provides specialized tools for computer interaction to ensure consistent behavior across different environments. These tools allow the agent to perform GUI actions, modify files with precision, and execute shell commands. Together, they form a comprehensive suite for agents that need to operate as a virtual developer or assistant on a computer system.

Exam trap

Candidates often confuse the 'computer' tool with generic API calls. They fail to recognize that these specific tools provide low-level OS access like screen capture and bash execution.

39
Multi-Selectmedium

A developer is designing a subagent architecture with the Claude Agent SDK. The main agent delegates a codebase audit to a specialized subagent to keep the primary conversation focused. Which TWO practices help ensure the delegation works correctly? (Choose two.)

Select 2 answers
A.Give the subagent a narrowly scoped task description and only the tools it needs for the audit.
B.Return a concise structured summary from the subagent to the main agent rather than its full transcript.
C.Configure the subagent with the same broad toolset as the main agent to maximize flexibility.
D.Have the subagent write its raw logs directly into the main agent's message history for transparency.
E.Share the main agent's entire conversation history with the subagent so it has maximum context.
AnswersA, B

Scoping the task and limiting tools reduces ambiguity and prevents the subagent from wandering into unrelated actions. A focused description plus a minimal toolset keeps the subagent's context small and its behavior predictable, which is the core reason to delegate to a subagent rather than expanding the main agent's responsibilities.

Why this answer

Effective delegation depends on isolation and distillation. Scoping the subagent's task and tools keeps it focused and safe, while returning a concise structured summary preserves the main agent's context budget and attention. Sharing full history, granting broad tools, or dumping raw logs all reintroduce the noise that subagents are meant to filter out.

Exam trap

The trap here is treating more context and more tools as strictly better, when delegation specifically benefits from narrower scope and summarized returns.

40
MCQeasy

Which of the following is a best practice when providing feedback to an agent after a failed tool call?

A.Ignore the error and let the agent retry with the same input.
B.Provide the specific error message returned by the tool.
C.Restart the entire conversation history from scratch.
D.Send a generic 'try again' message to the agent.
AnswerB

The error message contains the context needed for the model to re-evaluate its strategy. By surfacing the specific technical error, you enable the agent to self-correct, adjust its arguments, or switch to a different tool to achieve the desired goal.

Why this answer

Providing specific, actionable error messages is essential for recovery. An agent cannot fix a failed tool call if it does not understand why it failed. By feeding back the exact error message (e.g., 'invalid argument', 'permission denied'), you allow the model to adjust its future attempts, enabling the agent to learn from its errors and eventually succeed in the task without manual intervention.

Exam trap

Candidates often think a generic 'task failed' message is sufficient feedback, preventing the model from diagnosing and correcting its specific argument mistakes.

41
Multi-Selectmedium

Which TWO of the following are essential components of a 'tool_use' block generated by Claude?

Select 2 answers
A.A unique 'id' string used to match results to the specific request.
B.The full source code of the function being called.
C.The 'name' of the tool that matches a defined tool in the set.
D.The 'timestamp' of when the model decided to use the tool.
E.The 'confidence_score' the model assigns to this specific tool call.
AnswersA, C

The 'id' field is critical for maintaining the integrity of the conversation. It allows the SDK and the model to associate a 'tool_result' with its corresponding 'tool_use' request. This is especially important in complex interactions where multiple tools might be called or where the conversation spans many turns.

Why this answer

A 'tool_use' block must contain specific identifiers so that the SDK knows which tool to run and how to track its result. The 'id' uniquely identifies the specific call in the conversation history, while the 'name' maps the call to the actual function or service defined in the agent's configuration.

Exam trap

Candidates often overlook the 'id' field, assuming the tool name is sufficient. They fail to understand that the 'id' is required to map asynchronous results back to specific calls.

42
MCQmedium

Which component is responsible for orchestrating the loop between the model's output and the execution of tools in the Anthropic SDK?

A.The Claude model itself.
B.The application code handling the API response cycle.
C.The Anthropic API server-side logic.
D.The system prompt instructions.
AnswerB

The developer writes the loop logic that inspects the model's response for tool-use blocks, executes the corresponding functions, and feeds the results back into the history. This is the standard orchestration pattern for agentic workflows using the Anthropic SDK.

Why this answer

The orchestration loop is typically managed by the developer's application code using the SDK's response handling logic. The SDK provides the tools and the model generates requests, but the 'loop' itself—checking for tool calls, executing them, and sending the results back—must be implemented in the host application. This pattern is central to building autonomous agents that can process tasks iteratively.

Exam trap

Candidates often assume that the Anthropic model or the SDK automatically executes the tool calls autonomously without requiring developer-written application code.

Ready to test yourself?

Try a timed practice session using only Agents And The Agent Sdk questions.