Files
langgraph/libs
Sydney RunkleandClaude Sonnet 4.6 aa992adf57 perf(prebuilt): cache _get_all_injected_args by tool object identity
`_get_all_injected_args` runs `get_input_schema()`, `get_type_hints`,
and `inspect.signature` on every tool for every `ToolNode` construction.
When the same tool objects are passed to repeated `create_agent` calls
(the common case), this work was repeated from scratch each time.

Add a module-level cache keyed by `id(tool)`. The cache entry stores a
strong reference to the tool alongside the result, which prevents GC
from reusing the id for a different object and making an incorrect cache
hit. The `entry[0] is tool` identity check provides a second safety
guard.

`BaseTool` (Pydantic v2 BaseModel) is not hashable, so `@lru_cache`
cannot be used directly — hence the id-based dict approach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 16:13:24 -04:00
..