Study notes · 4.4% of the exam

Tool Implementation

Define, describe and run tools for Claude: write schemas and descriptions, drive the agentic loop, handle errors and parallel calls, choose client or server tools, add approval gates, and keep tool sets small and context-efficient.

Key points

  1. 1

    A tool definition has a name, a detailed description and an input_schema (JSON Schema). The description is the most important factor in tool performance: say what the tool does, when to use it and when not to, what it returns, caveats, and the format of each parameter.

  2. 2

    Use schema features to constrain inputs, such as enum for fixed value sets and clear formats like ISO 8601 dates. Set strict: true when tool inputs must always conform to the schema (correct types, required fields present).

  3. 3

    Agentic loop for client tools: while the response has stop_reason: "tool_use", run each requested tool, send the results back as tool_result blocks in a new user message, and call the API again. Any other stop reason ends the loop.

  4. 4

    Every tool_use block needs a matching tool_result with the same tool_use_id. For parallel calls, return all results in one user message, with the tool_result blocks before any text.

  5. 5

    Report tool failures in the tool_result with is_error: true and an actionable message (what failed, and whether a retry or a different input might work). Do not drop the result or return an empty success.

  6. 6

    tool_choice: auto (the default; Claude decides), any (must use some tool), tool (must use the named tool), none (no tool calls). Forced options are not supported on every model or setting. disable_parallel_tool_use limits Claude to one call per turn.

  7. 7

    Where tools run: user-defined and Anthropic-schema client tools (such as bash and text editor) execute in your app. Server tools (web search, web fetch, code execution, tool search) run on Anthropic's infrastructure with no handler code.

  8. 8

    A server tool's loop can stop with stop_reason: "pause_turn" when it hits its iteration limit. Resend the conversation, including the paused response, so Claude can continue.

  9. 9

    The harness, not the model, decides whether a requested call runs. Auto-run read-only tools, hold side-effecting or irreversible tools for human approval, log the decisions, and return a denial as the tool_result so Claude can adapt.

  10. 10

    In the Agent SDK, allowed_tools and disallowed_tools plus permission modes handle clear cases, and the canUseTool callback handles the rest at runtime, which is the place for an approval UI.

  11. 11

    Keep the tool set small and non-overlapping, and consolidate near-duplicates into one tool with parameters. Selection accuracy drops as the number of tools grows, and every definition costs context.

  12. 12

    Context tools: tool search loads definitions on demand for large catalogs, programmatic tool calling lets Claude call tools from code so intermediate results stay out of context, prompt caching cuts the cost of a stable tool set, and context editing trims old tool results.

  13. 13

    Return concise, high-signal results with human-readable names alongside IDs, rather than raw API dumps.

Test yourself on Tool Implementation

Ten questions, with the answer and explanation after each one.