You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agents): rename CacheHandler input parameter to tool_input - #9528
This pull request has 2 commits after the last Strix review (174297a). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.
✅ No open security findings.
PR summary: Renames the second parameter of `CacheHandler.add` and `CacheHandler.read` from `input` to `tool_input` to stop shadowing the builtin, updates all keyword callers and the related cache tests, and removes the obsolete TODO notes. No behavior change.
Review summary
This PR is a mechanical rename: CacheHandler.add/read now call their second parameter tool_input instead of input, and every in-tree keyword call site (agent executor, tools handler, tool-usage, agent utils, project memoize helpers) plus the related test was updated. Reviewing all seven changed files and the code they reach found no security issue. The cache key expression is byte-identical before and after, all call sites are consistent, and the caching gates around the read (tool availability, before/after tool hooks, should_cache, the declared-failure skip in add) are untouched. Independent tracing also cleared the surrounding cache design: keys cannot collide across distinct tool/argument pairs on the read path, entries are only written from a real execution of that exact call, the cache is opt-in and per-instance with no cross-run or cross-tenant scope, and a cache hit neither bypasses a usage-limit control at the invocation point nor any hook or permission check. Non-security note for the author: two assertions in lib/crewai/tests/test_crew.py still expect the old input= keyword and will fail, and the duck-typed cache double in lib/crewai/tests/tools/test_tool_failure.py keeps the old signature (currently unreachable on the guarded path) — worth updating so the cache-key assertions keep their coverage.
Ruled out (6)
Can one tool's cached result be returned for a different tool or different arguments through a cache-key collision in the `f"{tool}-{tool_input}"` string? The read key's tool half comes from `sanitize_tool_name`, whose output is `[a-z0-9_]` only, and its argument half is always `json.dumps(dict)` or empty, so distinct (tool, arguments) pairs cannot share a key; normalization-equivalent names only collide with byte-identical arguments, which tool sele…
Can cached tool output written for one agent, user or tenant be read by another, including through the cache-reading tool that takes a model-supplied tool name? The cache-reading tool is never registered into an agent toolset and holds its own empty `CacheHandler`, and every handler is a per-instance `PrivateAttr` on a Crew, Agent or LiteAgent with no process-wide instance, so no cross-owner read path exists.
Does the rename break custom cache handlers, and could the resulting swallowed error hide a blocked hook or denied permission? No attacker-controlled input decides whether an out-of-tree handler still declares the old parameter name, the affected party is the deployer's own run, and the swallowed `add` failure happens after the before/after tool hooks and guardrails have run, so it cannot mask a block or denial.
Can a cache hit bypass the per-tool usage limit and let an attacker amplify resource use or evade a quota? A cache hit performs no tool invocation, and the budget is enforced atomically at the invocation point in `BaseTool.run`/`arun`, while the ReAct path applies `_check_usage_limit` after the cache read, so no external work or quota is consumed through the cache.
Can a reused, cache-enabled Crew serve one caller's tool output to a later caller? Caching is opt-in with a documented identical-arguments replay contract, `kickoff_for_each` starts from a copy that gets a fresh handler, and any disclosure needs an application that shares one cache-enabled Crew across a trust boundary while running tools whose output is not determined by their ar…
Do before-tool hooks and guardrails still run when a tool result is served from cache after the rename? `run_before_tool_call_hooks` executes before the cache read on both native paths and `run_after_tool_call_hooks` still runs on a cache hit, so hook and guardrail enforcement is unchanged.
Review 1 on this PR · 174297a · requested Nov 18 02:02 UTC when the PR was opened
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Fixes #9336
Summary
CacheHandler.add and CacheHandler.read named a parameter input, which
shadows the builtin. Rename it to tool_input and update the keyword
callers.
Verification
uv run pytest lib/crewai/tests/tools/test_tool_failure.py::TestFailuresAreNotCached -q --allowed-hosts=127.0.0.1
Additional context
None.