From bd84f76d26a4b07af9a45b3fe3de2f78d656a799 Mon Sep 17 00:00:00 2001 From: JA VI <127710324+JaDi03@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:17:45 -0600 Subject: [PATCH] fix: keep the agent's strict tools within the API limit --- agent/tools/definitions.py | 6 +++++- tests/test_tool_definitions.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/test_tool_definitions.py diff --git a/agent/tools/definitions.py b/agent/tools/definitions.py index 0a91c33..29788cf 100644 --- a/agent/tools/definitions.py +++ b/agent/tools/definitions.py @@ -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, diff --git a/tests/test_tool_definitions.py b/tests/test_tool_definitions.py new file mode 100644 index 0000000..98cebed --- /dev/null +++ b/tests/test_tool_definitions.py @@ -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"])