Skip to content

fix(agents): rename CacheHandler input parameter to tool_input - #9528

Open
HanYuanLu wants to merge 3 commits into
crewAIInc:mainfrom
HanYuanLu:fix/issue-9336
Open

HanYuanLu wants to merge 3 commits into
crewAIInc:mainfrom
HanYuanLu:fix/issue-9336

Conversation

@HanYuanLu

Copy link
Copy Markdown
Contributor

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

  • Tests added or updated for the changed behavior
  • Relevant tests and quality checks pass locally

uv run pytest lib/crewai/tests/tools/test_tool_failure.py::TestFailuresAreNotCached -q --allowed-hosts=127.0.0.1

Additional context

None.

@strix-security

strix-security Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

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


Reviewed by Strix
Re-run review · Configure security review settings · Try a deeper review with @strix-security /deep

@HanYuanLu HanYuanLu closed this Nov 20, 2026
@HanYuanLu HanYuanLu reopened this Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: CacheHandler 'input' parameter shadows builtin

1 participant