perf(core): cache BaseTool.tool_call_schema and args as cached_property

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sydney Runkle
2026-04-21 08:42:20 -04:00
parent 0a33f779c5
commit 8669f02748

View File

@@ -552,6 +552,7 @@ class ChildTool(BaseTool):
model_config = ConfigDict(
arbitrary_types_allowed=True,
ignored_types=(functools.cached_property,),
)
@property
@@ -564,7 +565,7 @@ class ChildTool(BaseTool):
keys = {k for k in self.args if k != "kwargs"}
return len(keys) == 1
@property
@functools.cached_property
def args(self) -> dict:
"""Get the tool's input arguments schema.
@@ -583,7 +584,7 @@ class ChildTool(BaseTool):
json_schema = input_schema.model_json_schema()
return cast("dict", json_schema["properties"])
@property
@functools.cached_property
def tool_call_schema(self) -> ArgsSchema:
"""Get the schema for tool calls, excluding injected arguments.