CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
fix(agent): reject positional-only params in @tool
Claude4a49147516af
diff --git a/cubepi/agent/tool_decorator.py b/cubepi/agent/tool_decorator.pyindex 3acbbac..e671eb6 100644--- a/cubepi/agent/tool_decorator.py+++ b/cubepi/agent/tool_decorator.py@@ -61,6 +61,15 @@ def _build_params_model(f"@tool function {fn.__name__!r} cannot use *args/**kwargs; ""declare explicit parameters so an input schema can be generated.")+ if p.kind is inspect.Parameter.POSITIONAL_ONLY:+ # Tool-call arguments arrive as named JSON fields and the generated+ # executor invokes the function with fn(**kwargs), which can't fill+ # a positional-only parameter.+ raise TypeError(+ f"@tool parameter {p.name!r} of {fn.__name__!r} is "+ "positional-only; tool-call arguments arrive by name, so "+ "declare it as a normal parameter (remove the '/')."+ )if p.name not in hints and p.annotation is inspect.Parameter.empty:raise TypeError(f"@tool parameter {p.name!r} of {fn.__name__!r} needs a type "diff --git a/tests/agent/test_tool_decorator.py b/tests/agent/test_tool_decorator.pyindex 6e2604c..d6f65b9 100644--- a/tests/agent/test_tool_decorator.py+++ b/tests/agent/test_tool_decorator.py@@ -152,6 +152,14 @@ class TestErrors:async def bad(*args: str) -> str:return ""+ def test_positional_only_param_rejected(self):+ with pytest.raises(TypeError, match="positional-only"):++ @tool+ async def bad(id: str, /) -> str:+ "Positional-only is not callable with **kwargs."+ return id+async def test_bad_return_type_rejected(self):@toolasync def bad(value: str) -> int: # type: ignore[return-value]