Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion agent/tools/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

from typing import Any

MAX_STRICT_TOOLS = 20 # the Claude API refuses a request with more strict tools than this


def _tool(name: str, description: str, **properties: dict[str, Any]) -> dict[str, Any]:
"""Strict only when it takes inputs: strict checks the inputs, and the API allows at most
MAX_STRICT_TOOLS strict tools per request."""
return {
"name": name,
"description": description,
"strict": True,
"strict": bool(properties),
"input_schema": {
"type": "object",
"properties": properties,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_tool_definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""The agent's tools are a request the Claude API accepts: on 2026-10-14 a 21st strict tool made
every session fail with 'Too many strict tools'."""

from agent.tools.definitions import MAX_STRICT_TOOLS, TOOLS


def test_no_more_strict_tools_than_the_api_accepts():
assert sum(1 for t in TOOLS if t["strict"]) <= MAX_STRICT_TOOLS


def test_every_tool_with_inputs_is_strict():
assert all(t["strict"] for t in TOOLS if t["input_schema"]["properties"])
Loading