Python 88.3%
TypeScript 7.6%
Shell 4.1%
1#!/usr/bin/env python32"""Generate the Anthropic tool-ecosystem fragments (tools / parameters / objects / compatibility).3Facts come from sources/anthropic/pages/** (docs snapshot 2026-09-18) and the live probes in tmp-live/tools/ (2026-09-18).4"""5from __future__ import annotations6import json7from datetime import date8from pathlib import Path910ROOT = Path(__file__).resolve().parents[2]11TODAY = "2026-09-18"12RET = "2026-09-18"13D = "https://platform.claude.com/docs/en/agents-and-tools/tool-use/"14S = {15 "overview": D + "overview", "reference": D + "tool-reference", "define": D + "define-tools", "handle": D + "handle-tool-calls",16 "parallel": D + "parallel-tool-use", "strict": D + "strict-tool-use", "fgts": D + "fine-grained-tool-streaming",17 "ptc": D + "programmatic-tool-calling", "search": D + "tool-search-tool", "computer": D + "computer-use-tool",18 "editor": D + "text-editor-tool", "bash": D + "bash-tool", "memory": D + "memory-tool", "websearch": D + "web-search-tool",19 "webfetch": D + "web-fetch-tool", "codeexec": D + "code-execution-tool", "server": D + "server-tools", "advisor": D + "advisor-tool",20 "browser": D + "browser-use-tool", "caching": D + "tool-use-with-prompt-caching", "how": D + "how-tool-use-works",21 "mcp": "https://platform.claude.com/docs/en/agents-and-tools/mcp-connector",22 "stop": "https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons",23 "stream": "https://platform.claude.com/docs/en/build-with-claude/streaming",24 "count": "https://platform.claude.com/docs/en/build-with-claude/token-counting",25 "skills": "https://platform.claude.com/docs/en/build-with-claude/skills-guide",26 "create": "https://platform.claude.com/docs/en/api/messages/create",27 "beta_create": "https://platform.claude.com/docs/en/api/beta/messages/create",28 "release": "https://platform.claude.com/docs/en/release-notes/api",29 "betas": "https://platform.claude.com/docs/en/api/beta-headers",30}313233def src(*keys):34 return [{"url": S[k], "retrieved_at": RET} for k in keys]353637def ver(method="live_api", result="success", status=200, note=""):38 return {"method": method, "verified_at": TODAY, "result": result, "http_status": status, "request_note": note}394041DOCS_ONLY = ver("docs_only", "success", None, "not exercised live in this run")42SDK = ver("sdk_types", "success", None, "type string present in sources/anthropic/openapi/{python,node}-sdk-api.md")4344# ---- models (live /v1/models ids 2026-09-18 + documented-only mythos ids) ----45LIVE_MODELS = ["claude-fable-5-1", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-opus-4-7",46 "claude-sonnet-4-6", "claude-opus-4-6", "claude-opus-4-5-20251101", "claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929"]47DOC_ONLY_MODELS = ["claude-mythos-5-1", "claude-mythos-5"]48ALL = LIVE_MODELS + DOC_ONLY_MODELS49PTC_MODELS = ["claude-fable-5-1", "claude-mythos-5-1", "claude-fable-5", "claude-mythos-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7",50 "claude-opus-4-6", "claude-opus-4-5-20251101", "claude-sonnet-5", "claude-sonnet-4-6", "claude-sonnet-4-5-20250929"]51CODEEXEC_MODELS = PTC_MODELS + ["claude-haiku-4-5-20251001"]52TOOLSET_MODELS = ["claude-fable-5-1", "claude-mythos-5-1", "claude-fable-5", "claude-mythos-5", "claude-opus-5", "claude-sonnet-5", "claude-opus-4-8"]53COMPUTER_20251124_MODELS = TOOLSET_MODELS + ["claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-4-6", "claude-opus-4-5-20251101"]54COMPUTER_20250124_MODELS = ["claude-sonnet-4-5-20250929", "claude-haiku-4-5-20251001"]55TOOL_SEARCH_MODELS = ["claude-fable-5-1", "claude-mythos-5-1", "claude-fable-5", "claude-mythos-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7",56 "claude-opus-4-6", "claude-sonnet-4-6", "claude-opus-4-5-20251101", "claude-sonnet-4-5-20250929", "claude-haiku-4-5-20251001"]57WEBFETCH_DYN_MODELS = ["claude-fable-5-1", "claude-mythos-5-1", "claude-fable-5", "claude-mythos-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6",58 "claude-sonnet-5", "claude-sonnet-4-6"]59ADVISOR_PAIRS = { # executor -> advisors (docs table)60 "claude-haiku-4-5-20251001": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-5", "claude-sonnet-4-6"],61 "claude-sonnet-4-6": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-5", "claude-sonnet-4-6"],62 "claude-sonnet-5": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-sonnet-5"],63 "claude-opus-4-6": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-5"],64 "claude-opus-4-7": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7"],65 "claude-opus-4-8": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7"],66 "claude-opus-5": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5"],67 "claude-fable-5": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5"],68 "claude-mythos-5": ["claude-mythos-5-1", "claude-fable-5-1", "claude-mythos-5", "claude-fable-5", "claude-opus-5"],69 "claude-fable-5-1": ["claude-mythos-5-1", "claude-fable-5-1"],70 "claude-mythos-5-1": ["claude-mythos-5-1", "claude-fable-5-1"],71}72TOOL_SYSTEM_PROMPT_TOKENS = { # model -> (auto/none, any/tool)73 "claude-opus-5": (286, 406), "claude-opus-4-8": (290, 410), "claude-opus-4-7": (675, 804), "claude-opus-4-6": (497, 589),74 "claude-opus-4-5-20251101": (496, 588), "claude-sonnet-5": (354, 474), "claude-sonnet-4-6": (497, 589),75 "claude-sonnet-4-5-20250929": (496, 588), "claude-haiku-4-5-20251001": (496, 588),76}77GENERIC_PROPS = {78 "cache_control": {"type": "object", "description": "Prompt-cache breakpoint {type: ephemeral, ttl?: 5m|1h}. Not allowed together with defer_loading:true (live 400)."},79 "strict": {"type": "boolean", "description": "Grammar-constrained schema validation of the tool name and input. Not on mcp_toolset / computer_toolset / browser_toolset; not with code_execution callers (live 400)."},80 "defer_loading": {"type": "boolean", "description": "Exclude from the initial system prompt; loaded when tool search returns a tool_reference. Max 10,000 deferred tools/request."},81 "allowed_callers": {"type": "array", "items": {"enum": ["direct", "code_execution_20250825", "code_execution_20260120", "code_execution_20260521"]}, "description": "Who may call the tool. Default [\"direct\"] (web_search/web_fetch _20260209+ default to [\"code_execution_20260120\"])."},82 "input_examples": {"type": "array", "items": {"type": "object"}, "description": "Schema-validated example inputs (user-defined + Anthropic-schema client tools only; not toolsets/server tools)."},83}84COMMON_ENDPOINTS = ["POST /v1/messages", "POST /v1/messages/batches"]85EX_HDR = {"curl": "examples/anthropic/tools/{d}/{n}.sh", "python": "examples/anthropic/tools/{d}/{n}.py", "typescript": "examples/anthropic/tools/{d}/{n}.ts"}868788def ex(d, n="basic"):89 return {k: v.format(d=d, n=n) for k, v in EX_HDR.items()}909192def tool(name, type_, category, description, models, params, result_shape, *, beta=None, status=None, streaming=None,93 tool_choice="auto/any/tool/none (tool_choice.type=tool may name this tool)", parallel="yes (several tool_use blocks per turn; one tool_result each, all in one user message)",94 billing="Standard input/output tokens (definition + tool_use + tool_result blocks) plus the per-model tool-use system prompt.",95 limitations=None, security=None, examples=None, verification=None, sources=None, endpoints=None, extra=None):96 rec = {"provider": "anthropic", "name": name, "type": type_, "category": category, "description": description,97 "compatible_models": models, "compatible_endpoints": endpoints or COMMON_ENDPOINTS, "parameters_schema": params,98 "tool_choice_support": tool_choice, "parallel": parallel, "streaming_events": streaming or99 ["content_block_start (tool_use, input: {})", "content_block_delta (input_json_delta.partial_json)", "content_block_stop", "message_delta (stop_reason: tool_use)"],100 "result_shape": result_shape, "billing": billing, "limitations": limitations or [], "security": security or [],101 "beta_header": beta, "status": status or ["DOCUMENTED"], "examples": examples or {}, "verification": verification or DOCS_ONLY,102 "sources": sources or src("reference"), "last_verified": TODAY}103 if extra:104 rec.update(extra)105 return rec106107108TOOLS = []109110# ---------- user-defined (custom) tool ----------111TOOLS.append(tool(112 "Custom (user-defined) client tool", "custom", "client",113 "Tool you define with name/description/input_schema (JSON Schema). Claude returns a tool_use block (id toolu_…, name, input, caller) with stop_reason tool_use; your code runs it and replies with a tool_result block. `type` may be omitted or set to \"custom\".",114 ALL,115 {"type": "object", "required": ["name", "input_schema"], "properties": {116 "type": {"enum": ["custom"], "description": "Optional; the only value is custom."},117 "name": {"type": "string", "pattern": "^[a-zA-Z0-9_-]{1,128}$", "description": "Unique within the request; must not collide with a toolset member family name (computer/browser) when that toolset is declared."},118 "description": {"type": "string", "description": "Strongly recommended, 3-4+ sentences: what, when (and when not), parameter semantics, caveats."},119 "input_schema": {"type": "object", "description": "JSON Schema, type must be object; properties/required. Strict mode uses the structured-outputs JSON Schema subset (additionalProperties:false etc.)."},120 "eager_input_streaming": {"type": "boolean", "description": "true = fine-grained (unbuffered, unvalidated) input streaming for this tool. User-defined tools only. Replaces the legacy fine-grained-tool-streaming-2025-05-14 header."},121 **GENERIC_PROPS}},122 {"tool_use": {"type": "tool_use", "id": "toolu_01…", "name": "<tool name>", "input": {"...": "object matching input_schema"}, "caller": {"type": "direct"}},123 "tool_result (you send)": {"type": "tool_result", "tool_use_id": "toolu_01…", "content": "string | [text|image|document|search_result|tool_reference blocks]", "is_error": "optional bool", "cache_control": "optional"},124 "live_note": "Every tool_use block returned live on 2026-09-18 carried caller:{type:direct} (haiku 4.5, sonnet 4.6, sonnet 5)."},125 status=["DOCUMENTED", "LIVE_VERIFIED"],126 billing=f"Tokens only. Tool-use system prompt overhead per model (auto/none vs any/tool): {json.dumps(TOOL_SYSTEM_PROMPT_TOKENS)}. Live count_tokens on haiku 4.5: 11 tokens without tools, 581 with one small get_weather tool (auto), 673 with tool_choice any (+92). input_examples add ~20-200 tokens each.",127 limitations=["Name regex ^[a-zA-Z0-9_-]{1,128}$", "tool_result blocks must be first in the next user message; text only after them (live 400 otherwise: 'tool_use ids were found without tool_result blocks immediately after')",128 "tool_choice any/tool: unsupported with manual extended thinking (thinking.type=enabled) and returns 400 on Claude Fable 5.1 / Mythos 5.1 (docs)",129 "strict:true incompatible with allowed_callers containing a code_execution caller (live 400)", "Circular $ref schemas cannot be enabled for programmatic calling (400 'Circular $ref detected')"],130 security=["Treat tool_result content as untrusted (indirect prompt injection); keep it inside tool_result, not system/user text.", "Do not put PHI in strict schemas (compiled grammars are cached up to 24h)."],131 examples=ex("custom-tools"),132 verification=ver(note="a1_forced_tool..a10_input_examples, b1-b3 streaming, j1-j3 count_tokens on claude-haiku-4-5-20251001 (tmp-live/tools/)"),133 sources=src("define", "handle", "parallel", "strict", "fgts", "overview", "create"),134 extra={"tool_choice": {"auto": "default when tools present; may answer in text; disable_parallel_tool_use:true => at most one call (live verified)",135 "any": "must call some tool; disable_parallel_tool_use:true => exactly one call (live verified: haiku invented location '<UNKNOWN>' when forced on 'Say hello')",136 "tool": "{type:tool, name} forces that tool (live verified); assistant prefilled so no text before tool_use",137 "none": "no tool calls (live verified; default when no tools)"}}))138139# ---------- Anthropic-schema client tools ----------140TOOLS.append(tool(141 "Bash tool", "bash_20250124", "anthropic-defined-client",142 "Schema-less client tool: Claude emits {command} or {restart:true}; you run it in a persistent bash session you own and return stdout+stderr as tool_result.",143 ALL,144 {"type": "object", "required": ["type", "name"], "properties": {"type": {"const": "bash_20250124"}, "name": {"const": "bash"}, **GENERIC_PROPS},145 "tool_use.input": {"command": {"type": "string", "description": "required unless restart"}, "restart": {"type": "boolean"}}},146 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "bash", "input": {"command": "echo OK"}, "caller": {"type": "direct"}}, "tool_result": "string or text blocks; is_error:true on failure"},147 status=["DOCUMENTED", "LIVE_VERIFIED"],148 billing="Definition adds ~325 input tokens (Opus 5/4.8/4.7) or ~244 (Opus 4.6, Sonnet 4.6 and earlier) + tool-use system prompt. Live count_tokens haiku 4.5: 751 tokens total for one short message + bash tool (vs 11 without tools).",149 limitations=["No interactive commands, no GUI, no streaming of output; API does not truncate oversized results (request rejected) — truncate client-side.",150 "bash_20241022 (Sonnet 3.5 only, retired) needs anthropic-beta computer-use-2024-10-22."],151 security=["Run in an isolated container/VM as least-privileged user; allowlist commands; ulimit; log; redact secrets from output."],152 examples=ex("bash"), verification=ver(note="h7_bash_20250124 (haiku) -> tool_use input {command:'echo OK'}; j4 count_tokens"),153 sources=src("bash", "reference", "create"), extra={"name_constraint": "name must be exactly 'bash'", "versions": {"bash_20250124": "current, no beta header", "bash_20241022": "legacy, beta computer-use-2024-10-22, retired model only"}}))154155for t, models, note, st in [156 ("text_editor_20250728", ALL, "Current version for Claude 4+ (adds max_characters). Live: the only text_editor version accepted by claude-haiku-4-5 (20250124 and 20250429 -> 400 'does not support tool types').", ["DOCUMENTED", "LIVE_VERIFIED"]),157 ("text_editor_20250429", [], "Claude 4 version (removed undo_edit). Rejected live by haiku 4.5; schema-accepted by the GA endpoint. Model list: docs only say 'Claude 4'.", ["DOCUMENTED", "LEGACY"]),158 ("text_editor_20250124", [], "For earlier models (Claude Sonnet 3.7, retired). Rejected live by haiku 4.5. Includes undo_edit command.", ["DOCUMENTED", "LEGACY"]),159]:160 TOOLS.append(tool(161 f"Text editor tool ({t})", t, "anthropic-defined-client",162 "Schema-less client tool for viewing/creating/editing files: commands view (path, view_range?), str_replace (path, old_str, new_str), create (path, file_text), insert (path, insert_line, insert_text)" + (", undo_edit" if t == "text_editor_20250124" else "") + ". " + note,163 models,164 {"type": "object", "required": ["type", "name"], "properties": {"type": {"const": t}, "name": {"const": "str_replace_based_edit_tool" if t != "text_editor_20250124" else "str_replace_editor"},165 **({"max_characters": {"type": "integer", "description": "Truncation length for view (20250728+ only)"}} if t == "text_editor_20250728" else {}), **GENERIC_PROPS},166 "tool_use.input": {"command": {"enum": ["view", "str_replace", "create", "insert"] + (["undo_edit"] if t == "text_editor_20250124" else [])}, "path": "string", "view_range": "[start,end] 1-indexed, -1 = EOF", "old_str": "string", "new_str": "string", "file_text": "string", "insert_line": "int (0 = top)", "insert_text": "string"}},167 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "str_replace_based_edit_tool", "input": {"command": "view", "path": "/tmp"}, "caller": {"type": "direct"}},168 "tool_result": "file contents (recommended with 'N: ' line numbers) / 'Successfully replaced text at exactly one location.' / errors with is_error:true"},169 status=st, billing="~700 additional input tokens for the definition (docs figure for text_editor_20250429 on Claude 4.x). Live count_tokens haiku 4.5 with text_editor_20250728: 1252 tokens (vs 11 without tools).",170 limitations=["Name is fixed (live 400: \"tools.0.text_editor_20250728.name: Input should be 'str_replace_based_edit_tool'\")", "str_replace must match exactly one location (your implementation enforces)."],171 security=["Validate paths (no traversal), backups, permission checks."],172 examples=ex("text-editor"), verification=ver(note="h6_text_editor_20250728 (haiku) view /tmp; h9 wrong name 400; k15/k16 older versions 400 on haiku") if t == "text_editor_20250728" else ver("live_api", "failure", 400, "k15/k16: haiku 4.5 rejects this version"),173 sources=src("editor", "reference", "create"), extra={"name_constraint": "str_replace_based_edit_tool (20250429+) / str_replace_editor (20250124, 20241022)"}))174175TOOLS.append(tool(176 "Memory tool", "memory_20250818", "anthropic-defined-client",177 "Client-side file-like memory under /memories. Commands: view (path, view_range?), create (path, file_text), str_replace (path, old_str, new_str?), insert (path, insert_line, insert_text), delete (path), rename (old_path, new_path). The API injects a memory protocol into the system prompt telling Claude to view /memories first.",178 ALL,179 {"type": "object", "required": ["type", "name"], "properties": {"type": {"const": "memory_20250818"}, "name": {"const": "memory"}, **GENERIC_PROPS},180 "tool_use.input": {"command": {"enum": ["view", "create", "str_replace", "insert", "delete", "rename"]}, "path": "string under /memories", "view_range": "[start,end]", "file_text": "string", "old_str": "string", "new_str": "string (optional for str_replace = delete)", "insert_line": "int", "insert_text": "string", "old_path": "string", "new_path": "string"}},181 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "memory", "input": {"command": "view", "path": "/memories"}, "caller": {"type": "direct"}},182 "tool_result strings (reference)": {"view dir": "Here're the files and directories up to 2 levels deep in {path}, excluding hidden items and node_modules:\\n{size}\\t{path}…", "view file": "Here's the content of {path} with line numbers:\\n{6-wide line no}\\t{content}", "create": "File created successfully at: {path}", "str_replace": "The memory file has been edited.", "insert": "The file {path} has been edited.", "delete": "Successfully deleted {path}", "rename": "Successfully renamed {old_path} to {new_path}"}},183 status=["DOCUMENTED", "LIVE_VERIFIED"], billing="Tokens only. Live count_tokens haiku 4.5: 1576 tokens with the memory tool (vs 11 without) — includes injected memory protocol.",184 limitations=["Client-side storage only; no beta header since 2026-02-17 (was beta context-management-2025-06-27 era)", "Files >999,999 lines should return an error; view truncates >16,000 chars per tool description"],185 security=["Path traversal protection mandatory (validate /memories prefix, canonicalize, reject ../ and %2e%2e%2f)", "Strip sensitive data before writing; cap file sizes; expire stale memories."],186 examples=ex("memory"), verification=ver(note="h8_memory_20250818 (haiku) -> tool_use {command:view,path:/memories}; j6 count_tokens"),187 sources=src("memory", "reference"), extra={"name_constraint": "name must be exactly 'memory'", "sdk_helpers": "BetaLocalFilesystemMemoryTool / BetaAbstractMemoryTool (Python), betaMemoryTool (TS)"}))188189# computer use versions190CU_ACTIONS_20250124 = ["key", "hold_key", "type", "cursor_position", "mouse_move", "left_mouse_down", "left_mouse_up", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "triple_click", "scroll", "wait", "screenshot"]191CU_ACTIONS_20251124 = CU_ACTIONS_20250124 + ["zoom (when enable_zoom:true)"]192CU_MEMBERS_20260801 = ["screenshot", "zoom", "left_click", "right_click", "middle_click", "double_click", "triple_click", "left_click_drag", "mouse_move", "left_mouse_down", "left_mouse_up", "cursor_position", "scroll", "type", "key", "hold_key", "wait"]193CU_INPUTS = {"screenshot": {}, "zoom": {"region": "[x0,y0,x1,y1]"}, "left_click": {"coordinate?": "[x,y]", "text?": "modifier keys shift|ctrl|alt|super joined with +"},194 "right_click|middle_click|double_click|triple_click": "same as left_click", "left_click_drag": {"start_coordinate": "[x,y]", "coordinate": "[x,y]", "text?": "modifiers"},195 "mouse_move": {"coordinate": "[x,y]"}, "left_mouse_down|left_mouse_up": {}, "cursor_position": {}, "scroll": {"scroll_direction": "up|down|left|right", "scroll_amount": "int clicks", "coordinate?": "[x,y]", "text?": "modifiers"},196 "type": {"text": "string"}, "key": {"text": "key or chord e.g. Return, ctrl+s", "repeat?": "1-100 (toolset only)"}, "hold_key": {"text": "key", "duration": "seconds <=300"}, "wait": {"duration": "seconds <=300"}}197TOOLS.append(tool(198 "Computer use toolset (GA)", "computer_toolset_20260801", "anthropic-defined-client",199 "Client toolset: one entry (no name) declares 17 member tools; Claude calls members as tool_use blocks with name=<member> and toolset_name:'computer'; inputs have no action field. Coordinates are in the pixel space of the screenshots you return (no display_* params). Several member calls per turn = batch action: run in order, stop at first failure, answer skipped ones with is_error and the exact text 'Not executed: an earlier computer action in this turn failed.'",200 TOOLSET_MODELS,201 {"type": "object", "required": ["type"], "properties": {"type": {"const": "computer_toolset_20260801"},202 "configs": {"type": "object", "description": "member name -> {enabled?: bool (default true, incl. zoom), defer_loading?: bool}; unknown member or other fields rejected; disabling all members rejected"},203 "cache_control": GENERIC_PROPS["cache_control"], "allowed_callers": {"enum": [["direct"]], "description": "only [\"direct\"]"}},204 "rejected": ["name", "display_width_px", "display_height_px", "display_number", "enable_zoom", "strict", "input_examples", "defer_loading on the entry", "tool_choice type tool naming it", "legacy fine-grained-tool-streaming-2025-05-14 header", "a second computer entry or another tool named computer"],205 "members": CU_MEMBERS_20260801, "member_inputs": CU_INPUTS},206 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "screenshot", "toolset_name": "computer", "input": {}, "caller": {"type": "direct"}},207 "tool_result": {"type": "tool_result", "tool_use_id": "toolu_…", "toolset_name": "computer (required echo)", "content": "[{type:image,…}] for screenshot/zoom; text such as 'OK' otherwise; only text and image blocks allowed"},208 "live": "h4 on claude-sonnet-5: content = [thinking(empty, adaptive default), tool_use{name:screenshot,toolset_name:computer,input:{}}], input_tokens 4189 with zoom disabled"},209 status=["DOCUMENTED", "LIVE_VERIFIED"], tool_choice="auto/any/none; tool_choice type=tool naming the toolset or a member is rejected",210 parallel="batch actions: several member tool_use blocks per turn, executed sequentially in order; disable_parallel_tool_use:true limits to one",211 streaming=["content_block_start tool_use (toolset_name present)", "each member input arrives as ONE complete input_json_delta", "content_block_stop"],212 billing="~4,500 input tokens for the toolset definition + tool-use system prompt (≈4,520 on Fable 5/Mythos 5/Opus 5/Opus 4.8, ≈4,590 on Sonnet 5; disabling zoom saves ≈410). Screenshots billed as image input (~1,000-1,800 tokens each).",213 limitations=["Not available in Managed Agents; Claude API + Google Cloud only (other platforms: earlier beta versions)", "Images must already fit the model image limits (2576 px long edge / 4784 visual tokens on Opus 4.7+); API does not downscale — oversized tool_result image rejected", ">20 images per request triggers stricter per-side limits", "Prompt-injection classifiers scan screenshots (opt-out via support)"],214 security=["Dedicated VM/container, no credentials, domain allowlist, human confirmation for consequential actions; screenshots are untrusted content"],215 examples={"curl": "examples/anthropic/computer-use/computer_toolset_20260801.sh", "python": "examples/anthropic/computer-use/computer_use_loop.py", "typescript": "examples/anthropic/computer-use/computer_use_loop.ts"},216 verification=ver(note="h4_computer_toolset_20260801_sonnet5 (200, tool_use screenshot); h5 haiku 400 'does not support tool types: computer_toolset_20260801'; k22 name on toolset entry 400"),217 sources=src("computer", "reference", "release", "create"), extra={"beta_history": "GA 2026-08-19 (release notes); successor of computer_20251124/computer_20250124"}))218TOOLS.append(tool(219 "Computer use tool (beta, computer_20251124)", "computer_20251124", "anthropic-defined-client",220 "Single schema-less tool named 'computer'; Claude emits input {action: <name>, …}. Adds zoom (enable_zoom:true) over computer_20250124. Requires anthropic-beta: computer-use-2025-11-24 on every request (without it the GA schema rejects the type tag — live 400).",221 COMPUTER_20251124_MODELS,222 {"type": "object", "required": ["type", "name", "display_width_px", "display_height_px"], "properties": {"type": {"const": "computer_20251124"}, "name": {"const": "computer"},223 "display_width_px": {"type": "integer", "minimum": 1}, "display_height_px": {"type": "integer", "minimum": 1},224 "display_number": {"type": "integer", "minimum": 0, "description": "X11 display number"}, "enable_zoom": {"type": "boolean", "default": False}, **GENERIC_PROPS},225 "actions": CU_ACTIONS_20251124, "action_inputs": CU_INPUTS},226 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "computer", "input": {"action": "screenshot"}, "caller": {"type": "direct"}},227 "tool_result": {"type": "tool_result", "tool_use_id": "toolu_…", "content": [{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}]}},228 beta="computer-use-2025-11-24", status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"],229 billing="System prompt overhead 466-499 tokens + ~735 tokens per tool definition (measured with computer_20250124). Live sonnet 4.6: input_tokens 1843 for 'Take a screenshot.'",230 limitations=["Beta header required (k17b: sonnet 4.6 without header -> 400 unknown type tag)", "Haiku 4.5 / Sonnet 4.5 not supported (k17: 400 'does not support tool types: computer_20251124')", "API downscales? No: you should resize screenshots to model limits; coordinates scale accordingly"],231 security=["Same as toolset"], examples={"curl": "examples/anthropic/computer-use/computer_20251124.sh", "python": "examples/anthropic/computer-use/computer_use_loop.py", "typescript": "examples/anthropic/computer-use/computer_use_loop.ts"},232 verification=ver(note="h1 (sonnet 4.6, screenshot tool_use) + h2 (1x1 PNG tool_result -> text, stop max_tokens@50); k17 haiku 400; k17b no-header 400"),233 sources=src("computer", "beta_create", "reference")))234TOOLS.append(tool(235 "Computer use tool (beta, computer_20250124)", "computer_20250124", "anthropic-defined-client",236 "Earlier beta version for Claude Sonnet 4.5, Haiku 4.5 (and retired Opus 4.1/Sonnet 4/Opus 4). Requires anthropic-beta: computer-use-2025-01-24. Actions include hold_key, left_mouse_down/up, scroll, triple_click, wait (added 2025-01-24). No zoom.",237 COMPUTER_20250124_MODELS,238 {"type": "object", "required": ["type", "name", "display_width_px", "display_height_px"], "properties": {"type": {"const": "computer_20250124"}, "name": {"const": "computer"}, "display_width_px": {"type": "integer", "minimum": 1}, "display_height_px": {"type": "integer", "minimum": 1}, "display_number": {"type": "integer", "minimum": 0}, **GENERIC_PROPS}, "actions": CU_ACTIONS_20250124},239 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "computer", "input": {"action": "screenshot"}, "caller": {"type": "direct"}}},240 beta="computer-use-2025-01-24", status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"],241 billing="~735 tokens per definition + 466-499 system prompt tokens (docs). Live count_tokens haiku 4.5: 1826 tokens for one short message + computer_20250124 (vs 11 without tools).",242 verification=ver(note="h3_computer_20250124_haiku -> tool_use {action:screenshot}; j8 count_tokens 1826"), sources=src("computer", "beta_create", "release"),243 examples={"curl": "examples/anthropic/computer-use/computer_20250124_haiku.sh"}))244TOOLS.append(tool(245 "Computer use tool (legacy, computer_20241022)", "computer_20241022", "anthropic-defined-client",246 "Original computer use tool for Claude Sonnet 3.5 (retired). Beta header computer-use-2024-10-22. Not accepted for current models.",247 [], {"type": "object", "properties": {"type": {"const": "computer_20241022"}, "name": {"const": "computer"}, "display_width_px": "int", "display_height_px": "int", "display_number": "int"}},248 {"tool_use": {"name": "computer", "input": {"action": "…"}}}, beta="computer-use-2024-10-22", status=["DOCUMENTED", "LEGACY", "RETIRED"], verification=SDK, sources=src("release", "reference")))249250BROWSER_MEMBERS = {"navigation_and_capture": ["navigate(url, tab_id?)", "screenshot(tab_id?)", "zoom(region, tab_id?)"],251 "pointer": ["left_click(target, modifiers?, tab_id?)", "right_click", "middle_click", "double_click", "triple_click", "hover(target)", "left_click_drag(from, target)", "left_mouse_down(target)", "left_mouse_up(target)", "mouse_move(target)", "scroll(target, scroll_direction, scroll_amount?)", "scroll_to(target: RefTarget)"],252 "keyboard_and_timing": ["type(text)", "key(text, repeat?)", "hold_key(text, duration<=30)", "wait(duration<=30)"],253 "page_reading": ["read_page(filter?, depth?, ref?)", "find(query)", "get_page_text()"],254 "forms_and_files": ["form_input(target: RefTarget, value)", "file_upload(target, paths?, document_ids?) [disabled by default]"],255 "diagnostics_and_scripting": ["read_console() [disabled]", "read_network() [disabled]", "javascript_exec(text) [disabled]"],256 "tab_management": ["new_tab()", "list_tabs()", "switch_tab(tab_id)", "close_tab(tab_id)"]}257TOOLS.append(tool(258 "Browser use toolset", "browser_toolset_20260801", "anthropic-defined-client",259 "Client toolset (no name) with 31 member tools (27 enabled by default; javascript_exec, file_upload, read_console, read_network opt-in via configs). Members act on page structure (refs from read_page/find) or viewport coordinates. tool_use blocks carry toolset_name:'browser'. Results may include a browser_state block (tabs inventory + state_changes); tab-management members return exactly one browser_state block. Batch halt text: 'Not executed: an earlier action in this turn failed.'",260 TOOLSET_MODELS,261 {"type": "object", "required": ["type"], "properties": {"type": {"const": "browser_toolset_20260801"}, "configs": {"type": "object", "description": "member -> {enabled?, defer_loading?}"}, "cache_control": GENERIC_PROPS["cache_control"], "allowed_callers": {"enum": [["direct"]]}},262 "members": BROWSER_MEMBERS, "targets": {"Target": "CoordinateTarget {coordinate:[x,y]} | RefTarget {ref:'ref_N'}"}},263 {"tool_use": {"type": "tool_use", "id": "toolu_…", "name": "navigate", "toolset_name": "browser", "input": {"url": "https://example.com"}, "caller": {"type": "direct"}},264 "tool_result": {"type": "tool_result", "tool_use_id": "…", "toolset_name": "browser", "content": "[text | image | browser_state] only"},265 "browser_state": {"type": "browser_state", "tabs": [{"tab_id": "tab-1", "title": "…", "url": "…", "active": True}], "state_changes": [{"type": "tab_opened", "tab_id": "tab-2"}, {"type": "download_started|download_completed|download_failed", "…": "…"}]},266 "live": "k19 on claude-sonnet-5: [thinking, tool_use navigate{url}, tool_use screenshot{}] both toolset_name:browser; input_tokens 6689"},267 status=["DOCUMENTED", "LIVE_VERIFIED"], tool_choice="auto/any/none (type=tool naming toolset/member rejected)", parallel="batch actions, sequential execution",268 streaming=["tool_use content_block_start with toolset_name; one complete input_json_delta per member"],269 billing="Toolset definition ≈6,000+ input tokens (live 6689 total for a one-line prompt on Sonnet 5); screenshots as image input.",270 limitations=["Claude API + Google Cloud only; not on AWS/Bedrock/Foundry; not in Managed Agents", "browser_state limits: <=100 tabs, <=200 state_changes, strings <=4096 chars, no control chars; never on is_error results"],271 security=["Page content, tab titles/URLs and download metadata are prompt-injection surfaces; sanitize URLs; confirm consequential actions"],272 examples={"curl": "examples/anthropic/computer-use/browser_toolset_20260801.sh"}, verification=ver(note="k19_browser_toolset_sonnet5 -> navigate + screenshot member calls"),273 sources=src("browser", "reference", "release", "create")))274275# ---------- server tools ----------276WS_RESULT = {"server_tool_use": {"type": "server_tool_use", "id": "srvtoolu_…", "name": "web_search", "input": {"query": "…"}},277 "web_search_tool_result": {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_…", "content": "[{type:web_search_result,url,title,encrypted_content,page_age}] | {type:web_search_tool_result_error,error_code}"},278 "citations": {"type": "web_search_result_location", "url": "…", "title": "…", "encrypted_index": "…", "cited_text": "<=150 chars"},279 "usage": {"server_tool_use": {"web_search_requests": 1}},280 "error_codes": ["too_many_requests", "invalid_tool_input", "max_uses_exceeded", "query_too_long", "request_too_large", "unavailable"]}281WS_PARAMS = {"type": "object", "required": ["type", "name"], "properties": {282 "type": {"const": "web_search_20250305"}, "name": {"const": "web_search"},283 "max_uses": {"type": "integer", "exclusiveMinimum": 0, "description": "Cap searches per request; exceeding -> max_uses_exceeded result error"},284 "allowed_domains": {"type": "array", "items": {"type": "string"}, "description": "bare domains (+optional path); mutually exclusive with blocked_domains (live 400)"},285 "blocked_domains": {"type": "array", "items": {"type": "string"}},286 "user_location": {"type": "object", "properties": {"type": {"const": "approximate"}, "city": "string", "region": "string", "country": "ISO 3166-1 alpha-2 (live 400: 'String should have at most 2 characters')", "timezone": "IANA tz"}},287 **{k: GENERIC_PROPS[k] for k in ("cache_control", "defer_loading", "strict", "allowed_callers")}}}288for t, extra_props, desc, st, verif in [289 ("web_search_20250305", {}, "Basic web search executed by Anthropic. Citations always on. ZDR-eligible. No beta header (GA since 2026-02-17; launched 2025-05-07).", ["DOCUMENTED", "LIVE_VERIFIED"],290 ver(note="c4_web_search_forced (haiku, max_uses 1): server_tool_use + web_search_tool_result[5 web_search_result] + text with web_search_result_location citations; usage.server_tool_use.web_search_requests=1; c1: model answered without searching (0 searches); c3 both domain lists 400")),291 ("web_search_20260209", {}, "Adds dynamic filtering: allowed_callers defaults to [\"code_execution_20260120\"] so Claude searches from inside an auto-provisioned code execution container and filters results before they enter context. Not ZDR-eligible unless allowed_callers:[\"direct\"]. Models without programmatic tool calling (Haiku 4.5) must set allowed_callers:[\"direct\"] (live 400 otherwise).", ["DOCUMENTED", "LIVE_VERIFIED"],292 ver(note="c2 haiku without allowed_callers -> 400 'does not support programmatic tool calling…set allowed_callers=[\"direct\"]'; c5 with [\"direct\"] -> 200")),293 ("web_search_20260318", {"response_inclusion": {"enum": ["full", "excluded"], "default": "full", "description": "excluded drops nested server_tool_use/result pairs consumed by a completed code execution call"}}, "Adds response_inclusion control over web_search_20260209. Released 2026-06-11.", ["DOCUMENTED"], DOCS_ONLY),294]:295 p = json.loads(json.dumps(WS_PARAMS)); p["properties"]["type"] = {"const": t}; p["properties"].update(extra_props)296 if t != "web_search_20250305":297 p["properties"]["allowed_callers"] = dict(GENERIC_PROPS["allowed_callers"], default=["code_execution_20260120"])298 TOOLS.append(tool(299 f"Web search tool ({t})", t, "server", desc, ALL if t == "web_search_20250305" else ALL, p, WS_RESULT,300 status=st, tool_choice="auto (server tool; tool_choice tool naming web_search not documented)", parallel="server-side loop, up to 10 iterations then stop_reason pause_turn; may be paired with client tools in one turn (server_tool_use without result until you return tool_result blocks)",301 streaming=["content_block_start server_tool_use", "input_json_delta (query)", "content_block_stop", "content_block_start web_search_tool_result (whole block, no deltas)", "text deltas with citations_delta"],302 billing="$10 per 1,000 searches (usage.server_tool_use.web_search_requests) + tokens for results in context (encrypted_content counts as input on later turns). Errors are not billed. Code execution used for dynamic filtering is free. Live c4: 10,491 input tokens for one search on haiku.",303 limitations=["Org-level Console setting can disable web search (400 'web search is not enabled')", "Request-level allowed_domains must be a subset of org allowlist", "Wildcards only in path", "Not on Amazon Bedrock; Vertex + Foundry-on-Azure only basic version", "encrypted_content must be round-tripped unchanged (400 otherwise)"],304 security=["Search results are untrusted content; homograph domains bypass filters (use ASCII)"],305 examples={"curl": "examples/anthropic/web-search/web_search.sh", "python": "examples/anthropic/web-search/web_search.py", "typescript": "examples/anthropic/web-search/web_search.ts"},306 verification=verif, sources=src("websearch", "server", "reference", "create", "release"),307 extra={"name_constraint": "name must be 'web_search'", "zdr": "eligible only for web_search_20250305 or later versions with allowed_callers:[\"direct\"]",308 "dynamic_filtering_models": PTC_MODELS if t != "web_search_20250305" else []}))309310WF_RESULT = {"server_tool_use": {"type": "server_tool_use", "id": "srvtoolu_…", "name": "web_fetch", "input": {"url": "https://…"}},311 "web_fetch_tool_result": {"type": "web_fetch_tool_result", "tool_use_id": "srvtoolu_…", "content": {"type": "web_fetch_result", "url": "…", "retrieved_at": "ISO-8601", "content": {"type": "document", "source": {"type": "text|base64", "media_type": "text/plain|application/pdf", "data": "…"}, "title": "…", "citations": {"enabled": True}}}, "caller": {"type": "direct"}},312 "error": {"type": "web_fetch_tool_result", "tool_use_id": "…", "content": {"type": "web_fetch_tool_result_error", "error_code": "url_not_in_prior_context"}, "caller": {"type": "direct"}},313 "citations": {"type": "char_location", "document_index": 0, "document_title": "…", "start_char_index": 0, "end_char_index": 0, "cited_text": "…"},314 "usage": {"server_tool_use": {"web_search_requests": 0, "web_fetch_requests": 1}},315 "error_codes": ["invalid_tool_input", "url_too_long (250 chars)", "url_not_allowed", "url_not_in_prior_context", "url_not_accessible", "too_many_requests", "unsupported_content_type", "max_uses_exceeded", "unavailable"],316 "live_note": "d1/k21: the web_fetch_tool_result block carried caller:{type:direct} (not shown in docs example)"}317WF_PARAMS = {"type": "object", "required": ["type", "name"], "properties": {318 "type": {"const": "web_fetch_20250910"}, "name": {"const": "web_fetch"},319 "max_uses": {"type": "integer", "exclusiveMinimum": 0, "description": "No default limit; failed fetches count"},320 "allowed_domains": {"type": "array", "items": {"type": "string"}, "description": "domain-only matching (paths never match)"}, "blocked_domains": {"type": "array", "items": {"type": "string"}},321 "citations": {"type": "object", "properties": {"enabled": {"type": "boolean", "default": False}}},322 "max_content_tokens": {"type": "integer", "exclusiveMinimum": 0, "description": "approximate cap on text content (not PDFs); live 400 for 0"},323 "url_sources": {"type": "object", "description": "Which sources make URLs fetchable: user_input: all|none; client_tool_results / server_tool_results: all|none|only{tools:[{type:tool_reference,name}]}|except{tools}"},324 **{k: GENERIC_PROPS[k] for k in ("cache_control", "defer_loading", "strict", "allowed_callers")}}}325for t, extra_props, desc, st, verif in [326 ("web_fetch_20250910", {}, "Basic web fetch (text/HTML/PDF) executed by Anthropic. Only URLs already present in user messages, client tool results or prior search/fetch results can be fetched. ZDR-eligible. GA (no beta header) since 2026-02-17; launched in beta 2025-09-10 (web-fetch-2025-09-10).", ["DOCUMENTED", "LIVE_VERIFIED"],327 ver(note="d1 (haiku, example.com, citations enabled): server_tool_use + web_fetch_tool_result{web_fetch_result, document text/plain, title 'Example Domain', retrieved_at} + usage.server_tool_use.web_fetch_requests=1; k21: url_not_in_prior_context error block; k29 max_content_tokens 0 -> 400")),328 ("web_fetch_20260209", {}, "Adds dynamic filtering (code execution provisioned automatically; allowed_callers default [\"code_execution_20260120\"]). Not ZDR-eligible by default.", ["DOCUMENTED"], DOCS_ONLY),329 ("web_fetch_20260309", {"use_cache": {"type": "boolean", "default": True, "description": "false bypasses the fetch cache (slower)"}}, "Adds use_cache (cache bypass).", ["DOCUMENTED"], DOCS_ONLY),330 ("web_fetch_20260318", {"use_cache": {"type": "boolean", "default": True}, "response_inclusion": {"enum": ["full", "excluded"], "default": "full"}}, "Adds response_inclusion. Released 2026-06-11. Live: accepted on haiku with allowed_callers:[\"direct\"], response_inclusion:excluded, use_cache:false (k30, 200).", ["DOCUMENTED", "LIVE_VERIFIED"],331 ver(note="k30_web_fetch_20260318_direct_haiku 200 (no fetch performed)")),332]:333 p = json.loads(json.dumps(WF_PARAMS)); p["properties"]["type"] = {"const": t}; p["properties"].update(extra_props)334 if t != "web_fetch_20250910":335 p["properties"]["allowed_callers"] = dict(GENERIC_PROPS["allowed_callers"], default=["code_execution_20260120"])336 TOOLS.append(tool(337 f"Web fetch tool ({t})", t, "server", desc, ALL, p, WF_RESULT, status=st,338 tool_choice="auto", parallel="server-side loop (pause_turn); mixed with client tools -> deferred until tool_result returned",339 streaming=["content_block_start server_tool_use", "input_json_delta (url)", "content_block_start web_fetch_tool_result (whole)"],340 billing="No per-call charge; tokens of fetched content only (~2,500 tokens per 10 kB page; 500 kB PDF ≈125k tokens). usage.server_tool_use.web_fetch_requests counts fetches. Live d1: 3,319 input tokens for example.com.",341 limitations=["No JavaScript rendering", "URL max 250 chars", "Only text, HTML, PDF", "Not on Bedrock/Vertex; Foundry-on-Azure only basic version", "Org-level domain settings apply"],342 security=["Data exfiltration risk: URLs only from prior context; restrict with allowed_domains/max_uses; publishers may log URL parameters"],343 examples={"curl": "examples/anthropic/web-fetch/web_fetch.sh", "python": "examples/anthropic/web-fetch/web_fetch.py", "typescript": "examples/anthropic/web-fetch/web_fetch.ts"},344 verification=verif, sources=src("webfetch", "server", "reference", "create"),345 extra={"name_constraint": "name must be 'web_fetch'", "dynamic_filtering_models": WEBFETCH_DYN_MODELS if t != "web_fetch_20250910" else []}))346347CE_RESULT = {"server_tool_use (bash)": {"type": "server_tool_use", "id": "srvtoolu_…", "name": "bash_code_execution", "input": {"command": "python3 -c \"print(2+2)\""}},348 "bash_code_execution_tool_result": {"type": "bash_code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": {"type": "bash_code_execution_result", "stdout": "4\n", "stderr": "", "return_code": 0, "content": [{"type": "code_execution_output", "file_id": "file_…"}]}},349 "server_tool_use (editor)": {"type": "server_tool_use", "name": "text_editor_code_execution", "input": {"command": "view|create|str_replace", "path": "…", "file_text": "…", "old_str": "…", "new_str": "…"}},350 "text_editor_code_execution_tool_result": {"content": "text_editor_code_execution_view_result{file_type,content,num_lines,start_line,total_lines} | text_editor_code_execution_create_result{is_file_update} | text_editor_code_execution_str_replace_result{old_start,old_lines,new_start,new_lines,lines[]}"},351 "server_tool_use (PTC python cell)": {"type": "server_tool_use", "name": "code_execution", "input": {"code": "python source"}},352 "code_execution_tool_result": {"type": "code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": {"type": "code_execution_result", "stdout": "…", "stderr": "…", "return_code": 0, "content": [], "abort_reason": None}},353 "errors": {"type": "*_tool_result_error", "error_code": ["unavailable", "execution_time_exceeded", "invalid_tool_input", "too_many_requests", "output_file_too_large (bash)", "file_not_found (text_editor)"]},354 "top_level container": {"id": "container_…", "expires_at": "ISO-8601 (rolling, ~5h ahead live)", "skills": "[…] when skills loaded"},355 "live_note": "e1/e2/e3 (haiku): usage.server_tool_use had web_search_requests/web_fetch_requests only — no code_execution_requests field despite docs; g2 (sonnet 4.6 PTC): code_execution_result carried undocumented abort_reason:null"}356CE_PARAMS = {"type": "object", "required": ["type", "name"], "properties": {"type": {"const": "code_execution_20250825"}, "name": {"const": "code_execution"}, **{k: GENERIC_PROPS[k] for k in ("cache_control", "defer_loading", "strict", "allowed_callers")}},357 "request_level": {"container": "string container id | {id?, skills?: [{type: anthropic|custom, skill_id, version}] (max 20 skills)}", "messages[].content[] container_upload": {"type": "container_upload", "file_id": "file_… (Files API)"}}}358for t, desc, st, verif, models in [359 ("code_execution_20250825", "Sandboxed container (Python 3.11, Linux x86_64, 1 CPU, 5 GiB RAM, 5 GiB disk, no internet). Exposes sub-tools bash_code_execution and text_editor_code_execution. Files in via container_upload blocks (Files API), out via $OUTPUT_DIR -> file_id entries. Container reuse via top-level `container`; 30-day expiry, checkpoint after ~5 min idle. No beta header (GA 2026-02-17; legacy header code-execution-2025-08-25 still accepted).", ["DOCUMENTED", "LIVE_VERIFIED"],360 ver(note="e1 (haiku): bash_code_execution + bash_code_execution_tool_result stdout '4', container{id,expires_at}; e2 reused same container id (expires_at advanced); k25 name 'code' -> 400 \"Input should be 'code_execution'\""), CODEEXEC_MODELS),361 ("code_execution_20260120", "Same runtime + REPL state persistence across container reuse + programmatic tool calling (allowed_callers on other tools; Python cells as server_tool_use name code_execution with input.code). Required minimum for web_search/web_fetch _20260209+. On Haiku 4.5 behaves like 20250825.", ["DOCUMENTED", "LIVE_VERIFIED"],362 ver(note="g1/g2 on claude-sonnet-4-6: server_tool_use{name:code_execution,input:{code}} + tool_use{caller:{type:code_execution_20260120,tool_id}} -> after tool_result: code_execution_tool_result{code_execution_result stdout}"), CODEEXEC_MODELS),363 ("code_execution_20260521", "Same runtime as 20260120; tool description discloses the 90 s wall-clock limit per Python cell (detection_timeout status in output). Released 2026-06-11.", ["DOCUMENTED", "LIVE_VERIFIED"],364 ver(note="e3 (haiku): accepted; bash_code_execution ran print(3*3) -> '9'"), CODEEXEC_MODELS),365 ("code_execution_20250522", "Legacy Python-only version (beta header code-execution-2025-05-22); result type code_execution_result. Still accepted by the GA schema (live tag list) but docs say migrate.", ["DOCUMENTED", "LEGACY"], SDK, CODEEXEC_MODELS),366]:367 p = json.loads(json.dumps(CE_PARAMS)); p["properties"]["type"] = {"const": t}368 TOOLS.append(tool(369 f"Code execution tool ({t})", t, "server", desc, models, p, CE_RESULT, status=st, tool_choice="auto", parallel="server-side loop; pause_turn possible; mixed with client tools -> result deferred",370 streaming=["content_block_start server_tool_use (bash_code_execution / text_editor_code_execution / code_execution)", "input_json_delta", "result block arrives whole in one content_block_start"],371 billing="Free when web_search_20260209+/web_fetch_20260209+ is in the request. Otherwise billed per container-hour: 5-minute minimum per session, 1,550 free hours/org/month, then $0.05/hour/container; files preloaded bill time even if the tool is not called. Tokens as usual (live e1: 4,611 input tokens on haiku for a one-line prompt).",372 limitations=["No internet in the sandbox; only pre-installed libs (pandas, numpy, scipy, sklearn, statsmodels, matplotlib, seaborn, pyarrow, openpyxl, pillow, python-docx/pptx, pypdf, sympy…)", "Not on Bedrock/Vertex; Foundry requires Hosted-on-Anthropic", "Not ZDR-eligible; container data retained up to 30 days", "Haiku 4.5: no PTC / REPL persistence"],373 security=["Isolated container; outputs (files) carry C2PA credentials for media", "Distinguish from client bash tool in system prompt (separate environments)"],374 examples={"curl": "examples/anthropic/code-execution/code_execution.sh", "python": "examples/anthropic/code-execution/code_execution.py", "typescript": "examples/anthropic/code-execution/code_execution.ts"},375 verification=verif, sources=src("codeexec", "ptc", "skills", "reference", "create", "release"),376 extra={"name_constraint": "name must be 'code_execution'", "sub_tools": ["bash_code_execution", "text_editor_code_execution", "code_execution (PTC Python cell, 20260120+)"],377 "internal_type_ids_seen_live": ["bash_code_execution_20250825", "text_editor_code_execution_20250825", "python_with_tools_code_execution_20250825", "python_with_tools_code_execution_20260120", "python_with_tools_code_execution_20260521"],378 "internal_type_ids_note": "Listed in the per-model 'Did you mean' 400 message (h5/k15/k17) but rejected as request tool types by the schema (k11/k12/k12b 400) — internal identifiers only. LIVE_DISCOVERED."}))379380TS_RESULT = {"server_tool_use": {"type": "server_tool_use", "id": "srvtoolu_…", "name": "tool_search_tool_regex", "input": {"pattern": "weather", "limit": 10}},381 "tool_search_tool_result": {"type": "tool_search_tool_result", "tool_use_id": "srvtoolu_…", "content": {"type": "tool_search_tool_search_result", "tool_references": [{"type": "tool_reference", "tool_name": "get_weather"}]}},382 "error": {"content": {"type": "tool_search_tool_result_error", "error_code": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded", "error_message": "…"}},383 "then": "tool_use for the discovered tool (execute + tool_result as usual). Never send a tool_result for the srvtoolu_ id (live k24: 400 'unexpected tool_use_id found in tool_result blocks').",384 "custom_search": {"type": "tool_result", "tool_use_id": "toolu_…", "content": [{"type": "tool_reference", "tool_name": "…"}]}}385for t, alias, desc, note in [386 ("tool_search_tool_regex_20251119", "tool_search_tool_regex", "Claude writes Python re.search() patterns (case-insensitive, <=200 chars) over tool names/descriptions/argument names+descriptions.", "f1 (haiku): pattern 'weather', limit 10 -> tool_reference get_weather -> tool_use get_weather"),387 ("tool_search_tool_bm25_20251119", "tool_search_tool_bm25", "Claude writes natural-language queries (<=500 chars); BM25 ranking.", "f2 (haiku): query 'stock price AAPL Apple' -> tool_reference get_stock_price -> tool_use"),388]:389 TOOLS.append(tool(390 f"Tool search tool ({alias})", t, "server",391 f"Server tool that discovers deferred tools (defer_loading:true) and expands them inline as tool_reference blocks (prompt cache preserved). {desc} Default 5 results, Claude may set limit 1-10,000. Undated alias `{alias}` accepted as type (live f3, 200). GA since 2026-02-17 (beta 2025-11-24, header advanced-tool-use-2025-11-20).",392 TOOL_SEARCH_MODELS,393 {"type": "object", "required": ["type", "name"], "properties": {"type": {"enum": [t, alias]}, "name": {"const": alias}, **{k: GENERIC_PROPS[k] for k in ("cache_control", "defer_loading", "strict", "allowed_callers")}},394 "constraints": ["never set defer_loading:true on the search tool itself (400 'At least one tool must have defer_loading=false')", "deferred tool + cache_control -> 400 (live k23)", "max 10,000 deferred tools"]},395 TS_RESULT, status=["DOCUMENTED", "LIVE_VERIFIED"], tool_choice="auto", parallel="server-side; results expand automatically",396 streaming=["server_tool_use start + input_json_delta (pattern/query/limit)", "tool_search_tool_result whole block"],397 billing="Not metered as a server tool (no usage.server_tool_use field); loaded definitions count as input tokens. Live f1: 1,635 input tokens with 6 deferred tools + search tool (vs 581 for one plain tool).",398 limitations=["Sonnet 5 absent from the docs compatibility table (probably an omission — release notes say Sonnet 5 supports the same tools as Sonnet 4.6); Opus 4.1 and earlier unsupported", "Bedrock: InvokeModel only"],399 examples={"curl": "examples/anthropic/tools/tool-search/basic.sh", "python": "examples/anthropic/tools/tool-search/basic.py", "typescript": "examples/anthropic/tools/tool-search/basic.ts"},400 verification=ver(note=note), sources=src("search", "reference", "caching", "create"), extra={"name_constraint": f"name must be '{alias}'"}))401402TOOLS.append(tool(403 "Advisor tool (beta)", "advisor_20260301", "server",404 "Executor model consults a higher-capability advisor model mid-generation: executor emits server_tool_use{name:advisor,input:{}}; Anthropic runs a separate inference on `model`; result comes back as advisor_tool_result (advisor_result{text} for most advisors, advisor_redacted_result{encrypted_content} for Fable/Mythos/Opus 5 advisors). Requires anthropic-beta: advisor-tool-2026-03-01 (live 400 without: unknown type tag). Beta since 2026-04-09.",405 list(ADVISOR_PAIRS.keys()),406 {"type": "object", "required": ["type", "name", "model"], "properties": {"type": {"const": "advisor_20260301"}, "name": {"const": "advisor"}, "model": {"type": "string", "description": "advisor model id; must be >= Sonnet 4.6 and at least as capable as the executor (see pairs)"},407 "max_uses": {"type": "integer", "description": "per-request cap -> advisor_tool_result_error max_uses_exceeded"}, "max_tokens": {"type": "integer", "minimum": 1024, "description": "caps advisor output (thinking+text) per call; adds stop_reason to result"},408 "caching": {"type": ["object", "null"], "description": "{type: ephemeral, ttl: 5m|1h} on/off switch for advisor-side caching"}, **GENERIC_PROPS},409 "executor_advisor_pairs": ADVISOR_PAIRS},410 {"server_tool_use": {"type": "server_tool_use", "id": "srvtoolu_…", "name": "advisor", "input": {}},411 "advisor_tool_result": {"type": "advisor_tool_result", "tool_use_id": "srvtoolu_…", "content": "{type:advisor_result,text,stop_reason?} | {type:advisor_redacted_result,encrypted_content,stop_reason?} | {type:advisor_tool_result_error,error_code}"},412 "error_codes": ["max_uses_exceeded", "too_many_requests", "overloaded", "prompt_too_long", "execution_time_exceeded", "model_not_found", "unavailable"],413 "usage.iterations": [{"type": "message", "input_tokens": 0, "output_tokens": 0}, {"type": "advisor_message", "model": "claude-opus-5", "input_tokens": 0, "output_tokens": 0}],414 "live_note": "k18 (haiku executor, sonnet 4.6 advisor, 'Reply with OK'): 200, no advisor call, usage.iterations present with one message iteration"},415 beta="advisor-tool-2026-03-01", status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], tool_choice="auto", parallel="server-side; pause_turn possible while advisor pending",416 streaming=["server_tool_use start/stop then quiet (ping every ~30 s) until advisor_tool_result arrives whole in one content_block_start", "message_delta with usage.iterations"],417 billing="Advisor sub-inference billed at the advisor model's rates, reported in usage.iterations[] (type advisor_message); top-level usage = executor only; top-level max_tokens does not bound the advisor.",418 limitations=["Claude API + Claude Platform on AWS only (beta)", "Invalid executor/advisor pair -> 400", "count_tokens covers only the executor's first sampling call"],419 examples={"curl": "examples/anthropic/tools/advisor/basic.sh"}, verification=ver(note="k18_advisor_haiku_exec 200; k18b without header 400"), sources=src("advisor", "reference", "release", "count")))420421TOOLS.append(tool(422 "MCP connector toolset (beta)", "mcp_toolset", "mcp",423 "Connects the Messages API to a remote MCP server (Streamable HTTP or SSE, https only, tool calls only). Two parts: request-level mcp_servers[] {type:url,url,name,authorization_token?} and a tools[] entry {type:mcp_toolset, mcp_server_name, default_config?, configs?, cache_control?}. Claude's calls appear as mcp_tool_use blocks (id mcptoolu_…, server_name) followed by mcp_tool_result blocks executed by Anthropic. Requires anthropic-beta: mcp-client-2025-11-20 (deprecated mcp-client-2025-04-04 with mcp_servers[].tool_configuration still works live). Not date-versioned; versioning via header.",424 ALL,425 {"type": "object", "required": ["type", "mcp_server_name"], "properties": {"type": {"const": "mcp_toolset"}, "mcp_server_name": {"type": "string", "description": "must match exactly one mcp_servers[].name; each server referenced by exactly one toolset"},426 "default_config": {"type": "object", "properties": {"enabled": {"type": "boolean", "default": True}, "defer_loading": {"type": "boolean", "default": False}}},427 "configs": {"type": "object", "description": "tool name -> {enabled?, defer_loading?} overrides (unknown names: warning only)"}, "cache_control": GENERIC_PROPS["cache_control"]},428 "mcp_servers[]": {"type": {"const": "url"}, "url": "https://… (Streamable HTTP or SSE)", "name": "unique id", "authorization_token": "OAuth bearer token obtained by you", "tool_configuration": "DEPRECATED (2025-04-04 header): {enabled?, allowed_tools?[]}"}, "limits": {"mcp_servers maxItems": 20}},429 {"mcp_tool_use": {"type": "mcp_tool_use", "id": "mcptoolu_…", "name": "read_wiki_structure", "server_name": "deepwiki", "input": {"repoName": "…"}},430 "mcp_tool_result": {"type": "mcp_tool_result", "tool_use_id": "mcptoolu_…", "is_error": False, "content": [{"type": "text", "text": "…"}]},431 "live_note": "i1 (haiku, https://mcp.deepwiki.com/mcp): mcp_tool_use had no caller field; i2 without header -> 400 'mcp_servers: this parameter requires anthropic-beta: mcp-client-2026-09-15 (or mcp-client-2025-11-20)' but k13 sending mcp-client-2026-09-15 -> 400 'Unexpected value(s)…for the anthropic-beta header' (header advertised yet not accepted, 2026-09-18)"},432 beta="mcp-client-2025-11-20", status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], tool_choice="auto", parallel="server-executed; an mcp_tool_use without result in a tool_use-stop response is deferred like server_tool_use",433 streaming=["content_block_start mcp_tool_use + input_json_delta", "mcp_tool_result whole block"],434 billing="Tokens only (tool definitions fetched from the server count as input; Batches priced the same). Live i1: 2,367 input tokens.",435 limitations=["Remote HTTP servers only (no stdio); OAuth flow is your responsibility", "Not ZDR-eligible", "MCP tools cannot be called programmatically (PTC) and mcp_toolset does not accept strict/allowed_callers", "count_tokens rejects requests with mcp_servers", "Not on Bedrock/Vertex"],436 security=["Only connect to trusted servers; tool results are untrusted content"],437 examples={"curl": "examples/anthropic/mcp/mcp_connector.sh", "python": "examples/anthropic/mcp/mcp_connector.py", "typescript": "examples/anthropic/mcp/mcp_connector.ts", "server": "examples/anthropic/mcp/mini-mcp-server.ts"},438 verification=ver(note="i1_mcp_connector_deepwiki 200 (mcp_tool_use + mcp_tool_result); i2 no header 400; k13b legacy header 200; k13 2026-09-15 header 400"),439 sources=src("mcp", "reference", "beta_create", "betas"), extra={"beta_history": {"mcp-client-2025-04-04": "deprecated (tool_configuration on server def)", "mcp-client-2025-11-20": "current", "mcp-client-2026-09-15": "LIVE_DISCOVERED in an error message; not accepted on 2026-09-18"}}))440441TOOLS.append(tool(442 "Programmatic tool calling (allowed_callers / caller)", "allowed_callers:code_execution_20260120", "programmatic",443 "Not a tool type but a mode: any custom (or Anthropic-schema client) tool with allowed_callers containing code_execution_20260120 (or code_execution_20260521, interchangeable) becomes an async Python function inside the code_execution_20260120+ sandbox. Claude writes a cell (server_tool_use name code_execution, input.code); when the cell calls your tool the API pauses with stop_reason tool_use and a tool_use block whose caller is {type:code_execution_20260120, tool_id:<srvtoolu id>}. You reply with ONLY tool_result blocks (string/text content), the same tools array and the top-level container id; the cell resumes and eventually a code_execution_tool_result arrives.",444 PTC_MODELS,445 {"allowed_callers": GENERIC_PROPS["allowed_callers"], "requires": "tools[] includes {type: code_execution_20260120|code_execution_20260521, name: code_execution}", "container": "required on continuation requests while a programmatic call is pending"},446 {"tool_use (programmatic)": {"type": "tool_use", "id": "toolu_…", "name": "query_database", "input": {"sql": "SELECT 1 AS one"}, "caller": {"type": "code_execution_20260120", "tool_id": "srvtoolu_…"}},447 "tool_use (direct)": {"caller": {"type": "direct"}},448 "completion": {"type": "code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": {"type": "code_execution_result", "stdout": "[{'one': 1}]\n", "stderr": "", "return_code": 0, "content": [], "abort_reason": None}},449 "timeout": "TimeoutError in stderr after ~270 s waiting for your result; idle containers reclaimed after ~5 min"},450 status=["DOCUMENTED", "LIVE_VERIFIED"], tool_choice="tool_choice may not name a tool whose allowed_callers omits direct (live 400)", parallel="disable_parallel_tool_use:true unsupported with PTC; several programmatic calls may be pending at once (answer all in one user message)",451 streaming=["server_tool_use code_execution start + input_json_delta(code)", "tool_use with caller", "later: code_execution_tool_result whole block"],452 billing="Code execution pricing (free with web_search/web_fetch _20260209+). Programmatic tool results are NOT counted as input/output tokens; only the final code output and Claude's text are. Live g1+g2 on sonnet 4.6: 3,147 + 3,262 input tokens.",453 limitations=["Haiku 4.5 unsupported (live 400 naming the tools)", "strict:true tools cannot have code_execution callers (live 400)", "No MCP tools, no computer/browser toolsets", "Recursive $ref schemas rejected", "tool_result content must be string/text only; no text after tool_results", "Not on Bedrock/Vertex; Foundry Hosted-on-Anthropic only; not ZDR"],454 security=["allowed_callers is guidance, not a hard block: still handle direct tool_use for every tool", "Tool results are strings that Claude's code may parse/exec — beware injection"],455 examples={"curl": "examples/anthropic/tools/programmatic-tool-calling/basic.sh", "python": "examples/anthropic/tools/programmatic-tool-calling/basic.py", "typescript": "examples/anthropic/tools/programmatic-tool-calling/basic.ts"},456 verification=ver(note="g1/g2 claude-sonnet-4-6 full round trip; g3 haiku 400; g4 tool_choice 400; k28 strict 400"), sources=src("ptc", "reference", "server", "stop"),457 extra={"release_history": "beta 2025-11-24 (advanced-tool-use-2025-11-20) -> GA 2026-02-17; code_execution_20260120 SDK support 2026-06-18"}))458459# ---------- write tools ----------460out_tools = {"$fragment": "tools/anthropic-tools", "generated_by": "tmp/tu/gen_fragments.py (agent: anthropic tool-use ecosystem)", "generated_at": TODAY,461 "notes": ["Exact `type` strings accepted by the GA POST /v1/messages schema on 2026-09-18 (live 400 tag list, identical for all 11 models): bash_20250124, browser_toolset_20260801, code_execution_20250522, code_execution_20250825, code_execution_20260120, code_execution_20260521, computer_toolset_20260801, custom, memory_20250818, text_editor_20250124, text_editor_20250429, text_editor_20250728, tool_search_tool_bm25, tool_search_tool_bm25_20251119, tool_search_tool_regex, tool_search_tool_regex_20251119, web_fetch_20250910, web_fetch_20260209, web_fetch_20260309, web_fetch_20260318, web_search_20250305, web_search_20260209, web_search_20260318.",462 "Beta-gated types (need anthropic-beta): computer_20251124 (computer-use-2025-11-24), computer_20250124 (computer-use-2025-01-24), advisor_20260301 (advisor-tool-2026-03-01), mcp_toolset (mcp-client-2025-11-20).",463 "Per-model gating happens after schema validation ('<model> does not support tool types: …')."],464 "records": TOOLS}465(ROOT / "generated/fragments/tools").mkdir(parents=True, exist_ok=True)466(ROOT / "generated/fragments/tools/anthropic-tools.json").write_text(json.dumps(out_tools, indent=1, ensure_ascii=False))467468# ---------- parameters ----------469P = []470471472def param(endpoint, name, typ, desc, *, loc="body", required=False, default=None, enum=None, minimum=None, maximum=None, models=None, beta=None, status=None, source="create"):473 P.append({"provider": "anthropic", "endpoint": endpoint, "parameter": name, "location": loc, "type": typ, "required": required, "default": default,474 "minimum": minimum, "maximum": maximum, "enum": enum, "description": desc, "compatible_models": models or [], "beta_header": beta,475 "status": status or ["DOCUMENTED"], "source": S[source]})476477478M = "POST /v1/messages"479LV = ["DOCUMENTED", "LIVE_VERIFIED"]480param(M, "tools", "array", "Tool definitions (custom + Anthropic-provided). Union of custom tool objects and dated `type` objects. Tools are rendered into a system prompt whose token cost depends on model and tool_choice.", status=LV)481param(M, "tools[].type", "string", "Omitted or 'custom' for user-defined tools; otherwise an exact versioned type string (see tools fragment notes).", enum=["custom", "bash_20250124", "text_editor_20250124", "text_editor_20250429", "text_editor_20250728", "memory_20250818", "computer_toolset_20260801", "browser_toolset_20260801", "computer_20251124", "computer_20250124", "web_search_20250305", "web_search_20260209", "web_search_20260318", "web_fetch_20250910", "web_fetch_20260209", "web_fetch_20260309", "web_fetch_20260318", "code_execution_20250522", "code_execution_20250825", "code_execution_20260120", "code_execution_20260521", "tool_search_tool_regex_20251119", "tool_search_tool_regex", "tool_search_tool_bm25_20251119", "tool_search_tool_bm25", "advisor_20260301", "mcp_toolset"], status=LV)482param(M, "tools[].name", "string", "Custom: ^[a-zA-Z0-9_-]{1,128}$. Fixed for Anthropic tools: bash, str_replace_based_edit_tool (str_replace_editor for 20250124), memory, computer, web_search, web_fetch, code_execution, tool_search_tool_regex, tool_search_tool_bm25, advisor. Absent on computer_toolset/browser_toolset/mcp_toolset entries.", required=True, status=LV)483param(M, "tools[].description", "string", "Plaintext description; the most important lever for tool selection.", source="define")484param(M, "tools[].input_schema", "object", "JSON Schema (type object) for custom tools. Strict mode: structured-outputs subset.", required=True, source="define")485param(M, "tools[].input_examples", "array", "Schema-validated example inputs (~20-200 tokens each). Not on server tools or toolsets. Invalid example -> 400.", status=LV, source="define")486param(M, "tools[].strict", "boolean", "Grammar-constrained validation of tool name+input. Not on mcp_toolset/computer_toolset/browser_toolset; not with code_execution callers (400).", default=False, status=LV, source="strict")487param(M, "tools[].cache_control", "object", "{type: ephemeral, ttl?: 5m|1h}; put on the last tool to cache the whole tools prefix. Not with defer_loading:true (400).", status=LV, source="caching")488param(M, "tools[].defer_loading", "boolean", "Exclude from initial system prompt; loaded on tool_reference from tool search. Max 10,000 deferred tools. At least one tool must be non-deferred (400).", default=False, status=LV, source="search")489param(M, "tools[].allowed_callers", "array", "Any of direct | code_execution_20250825 | code_execution_20260120 | code_execution_20260521. Default [direct]; web_search/web_fetch _20260209+ default [code_execution_20260120]. Toolsets accept only [direct].", enum=["direct", "code_execution_20250825", "code_execution_20260120", "code_execution_20260521"], status=LV, source="ptc")490param(M, "tools[].eager_input_streaming", "boolean", "Custom tools only. true = fine-grained tool streaming (no buffering/validation of input JSON). Replaces beta header fine-grained-tool-streaming-2025-05-14.", default=False, status=LV, source="fgts")491param(M, "tools[].max_characters", "integer", "text_editor_20250728+: truncation length for view.", source="editor")492param(M, "tools[].display_width_px", "integer", "computer_20251124 / computer_20250124 (beta): display width; required. Rejected on computer_toolset_20260801.", required=True, minimum=1, beta="computer-use-2025-11-24 | computer-use-2025-01-24", status=LV, source="beta_create")493param(M, "tools[].display_height_px", "integer", "computer_2025*: display height; required.", required=True, minimum=1, beta="computer-use-2025-11-24 | computer-use-2025-01-24", status=LV, source="beta_create")494param(M, "tools[].display_number", "integer", "computer_2025*: X11 display number.", minimum=0, beta="computer-use-2025-11-24 | computer-use-2025-01-24", source="beta_create")495param(M, "tools[].enable_zoom", "boolean", "computer_20251124 only: enable the zoom action.", default=False, beta="computer-use-2025-11-24", source="beta_create")496param(M, "tools[].configs", "object", "computer_toolset_20260801 / browser_toolset_20260801: member name -> {enabled?, defer_loading?}. mcp_toolset: tool name -> {enabled?, defer_loading?}.", status=LV, source="reference")497param(M, "tools[].max_uses", "integer", "web_search / web_fetch / advisor: per-request cap; exceeding yields a *_tool_result_error max_uses_exceeded.", minimum=1, status=LV, source="websearch")498param(M, "tools[].allowed_domains", "array", "web_search / web_fetch: bare domains (+path for search). Mutually exclusive with blocked_domains (400). Must be within org allowlist.", status=LV, source="server")499param(M, "tools[].blocked_domains", "array", "web_search / web_fetch: domains to exclude.", source="server")500param(M, "tools[].user_location", "object", "web_search: {type: approximate, city?, region?, country? (2-letter, else 400), timezone?}.", status=LV, source="websearch")501param(M, "tools[].response_inclusion", "string", "web_search_20260318 / web_fetch_20260318: drop result blocks consumed by completed code execution.", default="full", enum=["full", "excluded"], status=LV, source="websearch")502param(M, "tools[].citations", "object", "web_fetch: {enabled: bool}; off by default (web search citations are always on).", default={"enabled": False}, status=LV, source="webfetch")503param(M, "tools[].max_content_tokens", "integer", "web_fetch: approximate cap on fetched text tokens (not PDFs). Must be > 0 (live 400).", minimum=1, status=LV, source="webfetch")504param(M, "tools[].url_sources", "object", "web_fetch: {user_input: all|none, client_tool_results: all|none|only{tools}|except{tools}, server_tool_results: …}.", source="create")505param(M, "tools[].use_cache", "boolean", "web_fetch_20260309+: false bypasses the fetch cache.", default=True, status=LV, source="webfetch")506param(M, "tools[].model", "string", "advisor_20260301: advisor model id (must form a valid executor/advisor pair).", required=True, beta="advisor-tool-2026-03-01", status=LV, source="advisor")507param(M, "tools[].max_tokens", "integer", "advisor_20260301: cap on advisor output per call (min 1024).", minimum=1024, beta="advisor-tool-2026-03-01", source="advisor")508param(M, "tools[].caching", "object", "advisor_20260301: {type: ephemeral, ttl: 5m|1h} advisor-side caching switch.", beta="advisor-tool-2026-03-01", source="advisor")509param(M, "tools[].mcp_server_name", "string", "mcp_toolset: must match one mcp_servers[].name.", required=True, beta="mcp-client-2025-11-20", status=LV, source="mcp")510param(M, "tools[].default_config", "object", "mcp_toolset: {enabled? (default true), defer_loading? (default false)} applied to all tools of the server.", beta="mcp-client-2025-11-20", status=LV, source="mcp")511param(M, "tool_choice", "object", "How Claude uses tools: {type: auto|any|tool|none, name?, disable_parallel_tool_use?}. Default auto when tools present, none otherwise. any/tool unsupported with manual thinking and on Fable 5.1/Mythos 5.1 (400).", status=LV, source="define")512param(M, "tool_choice.type", "string", "auto | any | tool | none", enum=["auto", "any", "tool", "none"], status=LV)513param(M, "tool_choice.name", "string", "Required when type=tool. Cannot name a tool whose allowed_callers omits direct (400) nor a toolset/member.", status=LV)514param(M, "tool_choice.disable_parallel_tool_use", "boolean", "auto: at most one tool_use; any/tool: exactly one. Unsupported with programmatic tool calling. Changing it invalidates the messages cache.", default=False, status=LV, source="parallel")515param(M, "container", "string|object", "Code execution container to reuse: id string, or {id?, skills?: [{type: anthropic|custom, skill_id, version}]} (max 20 skills). Required while a programmatic tool call is pending.", status=LV, source="codeexec")516param(M, "container.skills[]", "object", "{type: anthropic|custom, skill_id (1-64 chars), version ('latest' or version id)} — loads a Skill into the code execution container (Skills API CRUD is documented separately).", source="skills")517param(M, "mcp_servers", "array", "Remote MCP servers (max 20): [{type: url, url (https), name, authorization_token?}]. Requires beta header.", beta="mcp-client-2025-11-20", status=LV, source="mcp")518param(M, "mcp_servers[].tool_configuration", "object", "DEPRECATED (mcp-client-2025-04-04): {enabled?, allowed_tools?[]}. Still accepted live with the old header.", beta="mcp-client-2025-04-04", status=["DOCUMENTED", "DEPRECATED", "LIVE_VERIFIED"], source="mcp")519param(M, "messages[].content[] (tool_result)", "object", "{type: tool_result, tool_use_id, content?: string|[text|image|document|search_result|tool_reference], is_error?: bool, toolset_name?: computer|browser (required echo for toolset members), cache_control?}. Must come first in the user message following the tool_use; only tool_result blocks when a server/programmatic call is pending.", status=LV, source="handle")520param(M, "messages[].content[] (container_upload)", "object", "{type: container_upload, file_id} — preload a Files API file into the code execution container.", source="codeexec")521param(M, "messages[].content[] (tool_use, replayed)", "object", "Assistant tool_use blocks (and server_tool_use / *_tool_result / mcp_tool_use / mcp_tool_result / tool_search_tool_result) must be replayed verbatim, including encrypted_content / encrypted_index.", status=LV, source="websearch")522param("POST /v1/messages/count_tokens", "tools", "array", "Client tools and the advisor tool are counted; server tools (web_search, web_fetch, code_execution, tool_search) and mcp_servers -> 400 'Server tools are not supported in the count_tokens endpoint'.", status=LV, source="count")523param("POST /v1/messages/count_tokens", "tool_choice", "object", "Counted (live: any adds +92 tokens over auto on haiku 4.5).", status=LV, source="count")524param(M, "anthropic-beta", "string", "Header. Tool-related values: computer-use-2025-11-24, computer-use-2025-01-24, computer-use-2024-10-22 (legacy), advisor-tool-2026-03-01, mcp-client-2025-11-20, mcp-client-2025-04-04 (deprecated), fine-grained-tool-streaming-2025-05-14 (legacy no-op-ish), code-execution-2025-05-22 / code-execution-2025-08-25 (legacy opt-ins), web-fetch-2025-09-10 (legacy), advanced-tool-use-2025-11-20 (legacy for tool search/PTC), context-management-2025-06-27 (memory era).", loc="header", status=LV, source="betas")525(ROOT / "generated/fragments/parameters").mkdir(parents=True, exist_ok=True)526(ROOT / "generated/fragments/parameters/anthropic-tools.json").write_text(json.dumps(P, indent=1, ensure_ascii=False))527528# ---------- objects (blocks) ----------529O = []530531532def obj(name, type_, desc, fields, example, *, status=None, sources=("handle",), example_source="docs"):533 O.append({"provider": "anthropic", "api_family": "messages", "name": name, "object": type_, "schema_name": None, "description": desc, "fields": fields,534 "status": status or ["DOCUMENTED"], "example": example, "example_source": example_source, "sources": src(*sources)})535536537obj("Tool use block (assistant)", "tool_use", "Claude's request to run a client tool.", {"type": "tool_use", "id": "toolu_…", "name": "string", "input": "object", "caller": "{type: direct} | {type: code_execution_20260120, tool_id: srvtoolu_…}", "toolset_name": "computer|browser (toolset members only)", "cache_control": "optional"},538 {"type": "tool_use", "id": "toolu_01DSKX54Pm98m42E64kMCrww", "name": "get_weather", "input": {"location": "Paris"}, "caller": {"type": "direct"}}, status=LV, sources=("handle", "ptc"), example_source="live a1 2026-09-18")539obj("Tool result block (user)", "tool_result", "Your answer to a tool_use block.", {"type": "tool_result", "tool_use_id": "toolu_…", "content": "string | [text|image|document|search_result|tool_reference|browser_state]", "is_error": "bool", "toolset_name": "computer|browser", "cache_control": "optional"},540 {"type": "tool_result", "tool_use_id": "toolu_01", "content": [{"type": "text", "text": "15 degrees"}]}, status=LV)541obj("Caller (direct)", "direct", "caller variant for model-initiated calls.", {"type": "direct"}, {"type": "direct"}, status=LV, sources=("ptc",), example_source="live")542obj("Caller (code execution)", "code_execution_20260120", "caller variant for programmatic calls; tool_id = the code_execution server_tool_use id. Always tagged 20260120 even if 20260521 was declared.", {"type": "code_execution_20260120", "tool_id": "srvtoolu_…"},543 {"type": "code_execution_20260120", "tool_id": "srvtoolu_01XRkMSA5mTTPpoGGMHeLMyb"}, status=LV, sources=("ptc",), example_source="live g1")544obj("Server tool use block", "server_tool_use", "Anthropic-executed tool call (id prefix srvtoolu_). Names: web_search, web_fetch, bash_code_execution, text_editor_code_execution, code_execution, tool_search_tool_regex, tool_search_tool_bm25, advisor.", {"type": "server_tool_use", "id": "srvtoolu_…", "name": "string", "input": "object", "caller": "optional (nested dynamic-filtering calls)"},545 {"type": "server_tool_use", "id": "srvtoolu_01WafKETTQ3UTdLCrTvD3nMs", "name": "web_search", "input": {"query": "Bank of Canada policy interest rate current"}}, status=LV, sources=("server",), example_source="live c4")546obj("Web search tool result", "web_search_tool_result", "Search results or error, paired by tool_use_id.", {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_…", "content": "[web_search_result] | web_search_tool_result_error"},547 {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_01WafKETTQ3UTdLCrTvD3nMs", "content": [{"type": "web_search_result", "title": "Bank of Canada interest rate decisions - The Globe and Mail", "url": "https://www.theglobeandmail.com/topics/bank-of-canada/", "encrypted_content": "EuAQ…", "page_age": "2 weeks ago"}]}, status=LV, sources=("websearch",), example_source="live c4 (truncated)")548obj("Web search result item", "web_search_result", "One search hit.", {"type": "web_search_result", "url": "string", "title": "string", "encrypted_content": "opaque, must be round-tripped", "page_age": "string|null"},549 {"type": "web_search_result", "url": "https://en.wikipedia.org/wiki/Claude_Shannon", "title": "Claude Shannon - Wikipedia", "encrypted_content": "…", "page_age": "April 30, 2025"}, status=LV, sources=("websearch",))550obj("Web search tool result error", "web_search_tool_result_error", "Error variant of web_search_tool_result.content.", {"type": "web_search_tool_result_error", "error_code": "too_many_requests|invalid_tool_input|max_uses_exceeded|query_too_long|request_too_large|unavailable"},551 {"type": "web_search_tool_result_error", "error_code": "max_uses_exceeded"}, sources=("websearch",))552obj("Web search citation", "web_search_result_location", "Citation attached to a text block after web search.", {"type": "web_search_result_location", "url": "string", "title": "string", "encrypted_index": "opaque", "cited_text": "<=150 chars"},553 {"type": "web_search_result_location", "cited_text": "The Bank of Canada’s benchmark interest rate, known as the policy rate, is at 2.25 per cent. ", "url": "https://www.theglobeandmail.com/topics/bank-of-canada/", "title": "Bank of Canada interest rate decisions - The Globe and Mail", "encrypted_index": "Eo8B…"}, status=LV, sources=("websearch",), example_source="live c4")554obj("Web fetch tool result", "web_fetch_tool_result", "Fetched document or error.", {"type": "web_fetch_tool_result", "tool_use_id": "srvtoolu_…", "content": "web_fetch_result | web_fetch_tool_result_error", "caller": "{type: direct} (seen live)"},555 {"type": "web_fetch_tool_result", "tool_use_id": "srvtoolu_01Wyo96U86ZBHpoxvWHigCfL", "content": {"type": "web_fetch_result", "url": "https://example.com", "retrieved_at": "2026-09-18T21:31:53.465000+00:00", "content": {"type": "document", "source": {"type": "text", "media_type": "text/plain", "data": "…"}, "title": "Example Domain", "citations": {"enabled": True}}}, "caller": {"type": "direct"}}, status=LV, sources=("webfetch",), example_source="live d1")556obj("Web fetch result", "web_fetch_result", "Successful fetch payload.", {"type": "web_fetch_result", "url": "string", "retrieved_at": "ISO-8601", "content": "document block (source text/plain or base64 application/pdf, title?, citations?)"},557 {"type": "web_fetch_result", "url": "https://example.com/paper.pdf", "content": {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "JVBERi0…"}, "citations": {"enabled": True}}, "retrieved_at": "2025-08-25T10:30:02Z"}, sources=("webfetch",))558obj("Web fetch tool result error", "web_fetch_tool_result_error", "Error variant.", {"type": "web_fetch_tool_result_error", "error_code": "invalid_tool_input|url_too_long|url_not_allowed|url_not_in_prior_context|url_not_accessible|too_many_requests|unsupported_content_type|max_uses_exceeded|unavailable"},559 {"type": "web_fetch_tool_result_error", "error_code": "url_not_in_prior_context"}, status=LV, sources=("webfetch",), example_source="live k21")560obj("Bash code execution tool result", "bash_code_execution_tool_result", "Result of the code_execution bash sub-tool.", {"type": "bash_code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": "bash_code_execution_result | bash_code_execution_tool_result_error"},561 {"type": "bash_code_execution_tool_result", "tool_use_id": "srvtoolu_017wgbCMpCoaqP1rGX7nhccu", "content": {"type": "bash_code_execution_result", "stdout": "4\n", "stderr": "", "return_code": 0, "content": []}}, status=LV, sources=("codeexec",), example_source="live e1")562obj("Bash code execution result", "bash_code_execution_result", "stdout/stderr/return_code + captured $OUTPUT_DIR files.", {"type": "bash_code_execution_result", "stdout": "string", "stderr": "string", "return_code": "int", "content": "[{type: code_execution_output, file_id}]"},563 {"type": "bash_code_execution_result", "stdout": "hi\n", "stderr": "", "return_code": 0, "content": []}, status=LV, sources=("codeexec",), example_source="live e2")564obj("Text editor code execution tool result", "text_editor_code_execution_tool_result", "Result of the code_execution file sub-tool.", {"type": "text_editor_code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": "text_editor_code_execution_view_result{file_type,content,num_lines,start_line,total_lines} | …_create_result{is_file_update} | …_str_replace_result{old_start,old_lines,new_start,new_lines,lines[]} | text_editor_code_execution_tool_result_error{error_code}"},565 {"type": "text_editor_code_execution_tool_result", "tool_use_id": "srvtoolu_01C4D5E6F7G8H9I0J1K2L3M4", "content": {"type": "text_editor_code_execution_view_result", "file_type": "text", "content": "{\n \"setting\": \"value\"\n}", "num_lines": 3, "start_line": 1, "total_lines": 3}}, sources=("codeexec",))566obj("Code execution tool result (Python cell / legacy)", "code_execution_tool_result", "Result of a code_execution Python cell (PTC, 20260120+) or of the legacy 20250522 tool.", {"type": "code_execution_tool_result", "tool_use_id": "srvtoolu_…", "content": "code_execution_result{stdout,stderr,return_code,content[],abort_reason?} | code_execution_tool_result_error{error_code}"},567 {"type": "code_execution_tool_result", "tool_use_id": "srvtoolu_01XRkMSA5mTTPpoGGMHeLMyb", "content": {"type": "code_execution_result", "stdout": "[{'one': 1}]\n", "stderr": "", "return_code": 0, "content": [], "abort_reason": None}}, status=["DOCUMENTED", "LIVE_VERIFIED", "LIVE_DISCOVERED"], sources=("ptc", "codeexec"), example_source="live g2 (abort_reason undocumented)")568obj("Code execution tool result error", "code_execution_tool_result_error", "Error variant (also bash_/text_editor_ prefixed).", {"type": "code_execution_tool_result_error", "error_code": "unavailable|execution_time_exceeded|invalid_tool_input|too_many_requests|output_file_too_large|file_not_found"},569 {"type": "bash_code_execution_tool_result_error", "error_code": "unavailable"}, sources=("codeexec",))570obj("Container (response)", "container", "Top-level response field when code execution ran.", {"id": "container_…", "expires_at": "ISO-8601 rolling (~5 h ahead live); 30-day hard limit not reported", "skills": "[{type, skill_id, version}]|null"},571 {"id": "container_01YXRh6bhAJd4WeWsdo29Bgg", "expires_at": "2026-09-19T02:49:11.949149Z"}, status=LV, sources=("codeexec", "create"), example_source="live e1")572obj("Container upload block (user)", "container_upload", "Preload a Files API file into the container.", {"type": "container_upload", "file_id": "file_…"}, {"type": "container_upload", "file_id": "file_011CNha8iCJcU1wXNR6q4V8w"}, sources=("codeexec",))573obj("Tool search tool result", "tool_search_tool_result", "Discovered tool references (server-side format).", {"type": "tool_search_tool_result", "tool_use_id": "srvtoolu_…", "content": "tool_search_tool_search_result{tool_references[]} | tool_search_tool_result_error{error_code,error_message}"},574 {"type": "tool_search_tool_result", "tool_use_id": "srvtoolu_0174JggKYYgM6KLN5X3WkG8N", "content": {"type": "tool_search_tool_search_result", "tool_references": [{"type": "tool_reference", "tool_name": "get_weather"}]}}, status=LV, sources=("search",), example_source="live f1")575obj("Tool reference block", "tool_reference", "Pointer to a deferred tool; the API expands it into the full definition. Also valid inside a custom tool_result for client-side tool search.", {"type": "tool_reference", "tool_name": "string"}, {"type": "tool_reference", "tool_name": "get_weather"}, status=LV, sources=("search",))576obj("Tool search tool result error", "tool_search_tool_result_error", "Error variant (200 response).", {"type": "tool_search_tool_result_error", "error_code": "invalid_tool_input|unavailable|too_many_requests|execution_time_exceeded", "error_message": "string"},577 {"type": "tool_search_tool_result_error", "error_code": "invalid_tool_input", "error_message": "Invalid regular expression pattern: missing ) at position 1"}, sources=("search",))578obj("MCP tool use block", "mcp_tool_use", "Claude calling a remote MCP tool via the connector (id prefix mcptoolu_).", {"type": "mcp_tool_use", "id": "mcptoolu_…", "name": "string", "server_name": "string", "input": "object"},579 {"type": "mcp_tool_use", "id": "mcptoolu_01SvS54EZae5f3nhQCKNuBu5", "name": "read_wiki_structure", "input": {"repoName": "anthropics/anthropic-sdk-python"}, "server_name": "deepwiki"}, status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], sources=("mcp",), example_source="live i1")580obj("MCP tool result block", "mcp_tool_result", "Result returned by the MCP server (executed by Anthropic).", {"type": "mcp_tool_result", "tool_use_id": "mcptoolu_…", "is_error": "bool", "content": "string | [text …]"},581 {"type": "mcp_tool_result", "tool_use_id": "mcptoolu_01SvS54EZae5f3nhQCKNuBu5", "is_error": False, "content": [{"type": "text", "text": "Available pages for anthropics/anthropic-sdk-python:\n\n- 1 Overview\n- 2 Installation and Setup\n…"}]}, status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], sources=("mcp",), example_source="live i1 (truncated)")582obj("Advisor tool result", "advisor_tool_result", "Advisor guidance block.", {"type": "advisor_tool_result", "tool_use_id": "srvtoolu_…", "content": "advisor_result{text,stop_reason?} | advisor_redacted_result{encrypted_content,stop_reason?} | advisor_tool_result_error{error_code}"},583 {"type": "advisor_tool_result", "tool_use_id": "srvtoolu_abc123", "content": {"type": "advisor_result", "text": "Use a channel-based coordination pattern…"}}, status=["DOCUMENTED", "BETA"], sources=("advisor",))584obj("Usage server_tool_use", "usage.server_tool_use", "Server tool counters in usage.", {"web_search_requests": "int", "web_fetch_requests": "int", "code_execution_requests": "int (documented; NOT present live 2026-09-18)"},585 {"server_tool_use": {"web_search_requests": 0, "web_fetch_requests": 1}}, status=["DOCUMENTED", "LIVE_VERIFIED"], sources=("websearch", "webfetch", "codeexec"), example_source="live d1")586obj("Usage iterations (advisor)", "usage.iterations[]", "Per-iteration token breakdown when the advisor tool is present.", {"type": "message|advisor_message", "model": "advisor model (advisor_message only)", "input_tokens": "int", "output_tokens": "int", "cache_read_input_tokens": "int", "cache_creation_input_tokens": "int"},587 {"iterations": [{"type": "message", "input_tokens": 990, "output_tokens": 5, "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0}]}, status=["DOCUMENTED", "BETA", "LIVE_VERIFIED"], sources=("advisor",), example_source="live k18")588obj("Browser state block (user)", "browser_state", "Tab inventory returned with browser toolset results.", {"type": "browser_state", "tabs": "[{tab_id, title, url, active?}] (<=100)", "state_changes": "[{type: tab_opened, tab_id} | {type: download_started|download_completed|download_failed, …}] (<=200, omit when empty)"},589 {"type": "browser_state", "tabs": [{"tab_id": "tab-1", "title": "Documentation", "url": "https://example.com/docs", "active": True}]}, sources=("browser",))590obj("Computer use action schemas", "computer.actions", "Per-version action/member inputs.", {"computer_20250124": {"input.action": CU_ACTIONS_20250124, "params": CU_INPUTS}, "computer_20251124": {"input.action": CU_ACTIONS_20251124, "params": CU_INPUTS}, "computer_toolset_20260801": {"member tool names": CU_MEMBERS_20260801, "params": CU_INPUTS, "key.repeat": "1-100"}},591 {"type": "tool_use", "id": "toolu_01Ppr3sZ3TnE9m6VUu4RyH2K", "name": "type", "toolset_name": "computer", "input": {"text": "pictures of cats"}}, status=LV, sources=("computer",))592obj("Streaming: input_json_delta", "input_json_delta", "content_block_delta payload carrying partial JSON of tool_use/server_tool_use/mcp_tool_use input.", {"type": "input_json_delta", "partial_json": "string fragment (first is often \"\")"},593 {"type": "content_block_delta", "index": 0, "delta": {"type": "input_json_delta", "partial_json": "{\"locat"}}, status=LV, sources=("stream", "fgts"), example_source="live b1")594(ROOT / "generated/fragments/objects").mkdir(parents=True, exist_ok=True)595(ROOT / "generated/fragments/objects/anthropic-tool-blocks.json").write_text(json.dumps({"domain": "anthropic-tool-blocks", "generated_at": TODAY, "count": len(O), "records": O}, indent=1, ensure_ascii=False))596597# ---------- compatibility matrix ----------598C = []599600601def compat(tool_type, model, supported, beta=None, note="", status=None):602 C.append({"provider": "anthropic", "tool_type": tool_type, "model": model, "supported": supported, "beta_header": beta, "notes": note, "status": status or (["DOCUMENTED"] if model in LIVE_MODELS else ["DOCUMENTED", "ACCOUNT_RESTRICTED"])})603604605LIVE_OK = {("custom", "claude-haiku-4-5-20251001"), ("custom", "claude-sonnet-4-6"), ("bash_20250124", "claude-haiku-4-5-20251001"), ("text_editor_20250728", "claude-haiku-4-5-20251001"), ("memory_20250818", "claude-haiku-4-5-20251001"),606 ("web_search_20250305", "claude-haiku-4-5-20251001"), ("web_search_20260209", "claude-haiku-4-5-20251001"), ("web_fetch_20250910", "claude-haiku-4-5-20251001"), ("web_fetch_20260318", "claude-haiku-4-5-20251001"),607 ("code_execution_20250825", "claude-haiku-4-5-20251001"), ("code_execution_20260521", "claude-haiku-4-5-20251001"), ("code_execution_20260120", "claude-sonnet-4-6"), ("tool_search_tool_regex_20251119", "claude-haiku-4-5-20251001"), ("tool_search_tool_bm25_20251119", "claude-haiku-4-5-20251001"),608 ("computer_20251124", "claude-sonnet-4-6"), ("computer_20250124", "claude-haiku-4-5-20251001"), ("computer_toolset_20260801", "claude-sonnet-5"), ("browser_toolset_20260801", "claude-sonnet-5"), ("mcp_toolset", "claude-haiku-4-5-20251001"), ("advisor_20260301", "claude-haiku-4-5-20251001"), ("programmatic_tool_calling", "claude-sonnet-4-6")}609LIVE_NO = {("computer_toolset_20260801", "claude-haiku-4-5-20251001"), ("computer_20251124", "claude-haiku-4-5-20251001"), ("text_editor_20250124", "claude-haiku-4-5-20251001"), ("text_editor_20250429", "claude-haiku-4-5-20251001"), ("programmatic_tool_calling", "claude-haiku-4-5-20251001")}610for m in ALL:611 def st(tt, sup):612 if (tt, m) in LIVE_OK and sup: return ["DOCUMENTED", "LIVE_VERIFIED"]613 if (tt, m) in LIVE_NO and not sup: return ["DOCUMENTED", "LIVE_VERIFIED"]614 return None615 compat("custom", m, True, note="tool_choice any/tool return 400 on claude-fable-5-1 / mythos-5-1" if "5-1" in m else "", status=st("custom", True))616 compat("bash_20250124", m, True, status=st("bash_20250124", True))617 compat("text_editor_20250728", m, True, status=st("text_editor_20250728", True))618 compat("text_editor_20250429", m, m not in ("claude-haiku-4-5-20251001",) and None or False, note="docs: Claude 4 version; live: rejected by haiku 4.5; other current models untested (schema accepts the tag)", status=st("text_editor_20250429", False) if m == "claude-haiku-4-5-20251001" else ["UNVERIFIED"])619 compat("text_editor_20250124", m, False, note="for retired Claude Sonnet 3.7 era; live 400 on haiku 4.5", status=st("text_editor_20250124", False) if m == "claude-haiku-4-5-20251001" else ["DOCUMENTED"])620 compat("memory_20250818", m, True, status=st("memory_20250818", True))621 for ws in ("web_search_20250305", "web_search_20260209", "web_search_20260318"):622 dyn = ws != "web_search_20250305"623 compat(ws, m, True, note=("dynamic filtering requires programmatic tool calling: " + ("supported" if m in PTC_MODELS else "NOT supported -> must set allowed_callers:[\"direct\"]")) if dyn else "", status=st(ws, True))624 for wf in ("web_fetch_20250910", "web_fetch_20260209", "web_fetch_20260309", "web_fetch_20260318"):625 dyn = wf != "web_fetch_20250910"626 compat(wf, m, True, note=("dynamic filtering models per web-fetch docs: " + ("yes" if m in WEBFETCH_DYN_MODELS else "not listed -> use allowed_callers:[\"direct\"]")) if dyn else "", status=st(wf, True))627 for ce in ("code_execution_20250825", "code_execution_20260120", "code_execution_20260521"):628 compat(ce, m, m in CODEEXEC_MODELS, note="Haiku 4.5: no PTC / REPL persistence (behaves like 20250825)" if m == "claude-haiku-4-5-20251001" and ce != "code_execution_20250825" else "", status=st(ce, m in CODEEXEC_MODELS))629 compat("code_execution_20250522", m, None, note="legacy Python-only; schema still accepts tag; per-model support unverified", status=["DOCUMENTED", "LEGACY", "UNVERIFIED"])630 for ts in ("tool_search_tool_regex_20251119", "tool_search_tool_bm25_20251119"):631 sup = m in TOOL_SEARCH_MODELS632 compat(ts, m, True if m == "claude-sonnet-5" else sup, note="Sonnet 5 missing from docs table (assumed supported: 'same tools as Sonnet 4.6')" if m == "claude-sonnet-5" else "", status=st(ts, sup) if m != "claude-sonnet-5" else ["UNVERIFIED"])633 compat("programmatic_tool_calling", m, m in PTC_MODELS, note="allowed_callers with code_execution_20260120+ caller", status=st("programmatic_tool_calling", m in PTC_MODELS))634 compat("computer_toolset_20260801", m, m in TOOLSET_MODELS, status=st("computer_toolset_20260801", m in TOOLSET_MODELS))635 compat("browser_toolset_20260801", m, m in TOOLSET_MODELS, status=st("browser_toolset_20260801", m in TOOLSET_MODELS))636 compat("computer_20251124", m, m in COMPUTER_20251124_MODELS, beta="computer-use-2025-11-24", status=st("computer_20251124", m in COMPUTER_20251124_MODELS))637 compat("computer_20250124", m, m in COMPUTER_20250124_MODELS, beta="computer-use-2025-01-24", note="also retired Opus 4.1 / Sonnet 4 / Opus 4", status=st("computer_20250124", m in COMPUTER_20250124_MODELS))638 compat("advisor_20260301 (as executor)", m, m in ADVISOR_PAIRS, beta="advisor-tool-2026-03-01", note="advisors: " + ", ".join(ADVISOR_PAIRS.get(m, [])), status=st("advisor_20260301", m in ADVISOR_PAIRS))639 compat("mcp_toolset", m, True, beta="mcp-client-2025-11-20", note="no per-model restriction documented", status=st("mcp_toolset", True))640 compat("eager_input_streaming (fine-grained tool streaming)", m, True, note="all models, all platforms (docs)")641 if m in TOOL_SYSTEM_PROMPT_TOKENS:642 a, b = TOOL_SYSTEM_PROMPT_TOKENS[m]643 compat("tool_use_system_prompt_tokens", m, True, note=f"auto/none: {a} tokens; any/tool: {b} tokens")644matrix = {"$fragment": "compatibility/anthropic-tool-model-matrix", "generated_at": TODAY, "models_live": LIVE_MODELS, "models_docs_only": DOC_ONLY_MODELS,645 "legend": {"supported": "true|false|null(unknown)", "status": "DOCUMENTED = from docs; LIVE_VERIFIED = probed 2026-09-18; UNVERIFIED = docs unclear; ACCOUNT_RESTRICTED = model id not in our /v1/models list"},646 "schema_accepted_type_tags_live": ["bash_20250124", "browser_toolset_20260801", "code_execution_20250522", "code_execution_20250825", "code_execution_20260120", "code_execution_20260521", "computer_toolset_20260801", "custom", "memory_20250818", "text_editor_20250124", "text_editor_20250429", "text_editor_20250728", "tool_search_tool_bm25", "tool_search_tool_bm25_20251119", "tool_search_tool_regex", "tool_search_tool_regex_20251119", "web_fetch_20250910", "web_fetch_20260209", "web_fetch_20260309", "web_fetch_20260318", "web_search_20250305", "web_search_20260209", "web_search_20260318"],647 "haiku_4_5_supported_types_live": ["bash_20250124", "bash_code_execution_20250825", "code_execution_20250522", "code_execution_20250825", "code_execution_20260120", "code_execution_20260521", "computer_20250124", "memory_20250818", "python_with_tools_code_execution_20250825", "python_with_tools_code_execution_20260120", "python_with_tools_code_execution_20260521", "text_editor_20250728", "text_editor_code_execution_20250825", "tool_search_tool_bm25_20251119", "tool_search_tool_regex_20251119", "web_fetch_20250910", "web_fetch_20260209", "web_fetch_20260309", "web_fetch_20260318", "web_search_20250305", "web_search_20260209", "web_search_20260318"],648 "records": C}649(ROOT / "generated/fragments/compatibility").mkdir(parents=True, exist_ok=True)650(ROOT / "generated/fragments/compatibility/anthropic-tool-model-matrix.json").write_text(json.dumps(matrix, indent=1, ensure_ascii=False))651print("tools", len(TOOLS), "params", len(P), "objects", len(O), "compat", len(C))652