Skip to content

fix(agent): record hook-adjusted native tool arguments - #9778

Open
sll00 (oOtiti) wants to merge 2 commits into
crewAIInc:mainfrom
oOtiti:fix/9775-kickoff-tool-history
Open

sll00 (oOtiti) wants to merge 2 commits into
crewAIInc:mainfrom
oOtiti:fix/9775-kickoff-tool-history

Conversation

@oOtiti

Copy link
Copy Markdown

Related issue

Fixes #9775

Summary

When a before-tool-call hook adjusts a model-supplied argument, native tool history now records the value used for execution or cache lookup. The executor takes this snapshot before the tool runs and pairs it with the matching history entry in serial and parallel batches.

An offline two-kickoff reproduction changes a reservation from 35 to 45 minutes. The tool receives 45 on both revisions. With this change, the returned history and the next kickoff also see 45.

Verification

  • Regression tests cover sync and async kickoff, serial and parallel tool calls, and post-hook changes.
  • The native tool hook suite passes all 25 tests. Ruff, formatting, mypy, and the commit message check pass.

The related Windows/Python 3.13 suite reports 85 passes and one existing failure. The POSIX /tmp assertion also fails on the unchanged base in the same environment.

Additional context

Hook-added top-level arguments stay in the tool execution context. Provider-specific raw tool call parts are preserved.

AI-assisted contribution prepared with Codex. Please apply the required llm-generated label if it has not been set. This external contributor account does not have permission to apply upstream labels.

@strix-security

strix-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Strix Security Review

✅ No open security findings.

PR summary: This PR makes native tool-call history record the arguments actually used for execution, including values adjusted by before-tool-call hooks, instead of echoing the model's original arguments. It also adds regression tests for sync/async kickoff and serial/parallel tool batches.

Review summary

Reviewed the change in lib/crewai/src/crewai/agents/agent_executor.py that records hook-adjusted native tool arguments into the assistant tool-call history, plus its regression tests. The new history_arguments snapshot only copies values for top-level keys the model itself supplied, is discarded when the tool neither ran nor hit cache, and is written back on the main thread after the batch completes, so it adds no attacker-reachable injection, disclosure, or crash path. Coverage spanned pairing of results with reported tool calls in serial and parallel batches, hook dispatch behaviour, cache keying on the post-hook argument string, and persistence of the mutated message history. No security issues found; two correctness observations (provider-specific raw tool-call parts bypassing the recorded arguments, and the strict result/call pairing) are not reachable by an attacker.

Ruled out (4)
  • Can hook-injected values under a model-supplied argument name leak into model history and be replayed to the provider?
    Recording the post-hook value of a model-supplied argument is the change's stated purpose, hook-added top-level keys stay out, and the only leak case is a deployer hook that deliberately commits sensitive data into a model-controlled argument field, exposing no separate victim.
  • Can the strict zip pairing of execution results with reported tool calls misattribute arguments or crash a run?
    Every future in the parallel path either writes an ordered result or re-raises, and the sequential loop appends both lists in the same iteration, so the lengths and order always match; a mismatch would in any case be a crash-only reliability issue.
  • Does recording the post-hook argument string give an attacker a way to poison tool-result caching or bypass usage limits?
    The cache read/write key and the argument used for repetition and usage checks are computed exactly as before this PR; only a copy of the value written into the stored message changed.
  • Do hook-adjusted argument values newly reach persisted run transcripts or checkpoints with sensitive data?
    Only values already present in the model's own tool call are carried forward, and the same post-hook arguments were already exposed to the tool-usage events and failure handlers that included them in the run record.

Review 1 on this PR · 9f78fc3 · requested Nov 25 09:04 UTC when the PR was opened


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

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.

[BUG] Agent.kickoff() history omits tool arguments applied by before_tool_call hooks

1 participant