Skip to content

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

Backlog

Description

@master1018

Description

When a before_tool_call hook changes a native tool call’s arguments, Agent.kickoff() returns the model’s original arguments in messages. The call record omits the arguments that reached the tool.

I was using a meeting coordinator to reserve a room. Our calendar uses 15-minute blocks, so I called register_before_tool_call_hook(use_calendar_blocks) to round up context.tool_input["duration_minutes"]. I requested 35 minutes, and the reserve_room tool saved a 45-minute booking and returned a confirmation number. I passed first.messages into a second assistant.kickoff() and asked how long the reservation was. The Agent answered 35 minutes, matching the original arguments in the returned history.

Steps to Reproduce

Run the following python code with a LLM model:

import os
from pathlib import Path

from crewai import Agent, LLM
from crewai.hooks.tool_hooks import register_before_tool_call_hook
from crewai.tools import tool

booking = Path("/tmp/meeting-room-reservation.txt")
booking.unlink(missing_ok=True)


@tool
def reserve_room(duration_minutes: int) -> str:
    """Reserve our meeting room for the requested number of minutes."""
    booking.write_text(str(duration_minutes))
    return "Room reserved. Reference: MEETING-24."


def use_calendar_blocks(context):
    if context.tool_name == "reserve_room":
        context.tool_input["duration_minutes"] = ((context.tool_input["duration_minutes"] + 14) // 15) * 15


register_before_tool_call_hook(use_calendar_blocks)
llm = LLM(model="openai/deepseek-flash", custom_openai=True,
          api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com",
          temperature=0, extra_body={"thinking": {"type": "disabled"}})
assistant = Agent(role="Meeting coordinator", goal="Book rooms and answer reservation questions",
                  backstory="You remember completed bookings from the conversation.",
                  llm=llm, tools=[reserve_room], verbose=True)
first = assistant.kickoff("Reserve our meeting room for 35 minutes. After booking it, reply only Booked.")
print(first.raw)
answer = assistant.kickoff([*first.messages, {"role": "user", "content":
    "For how many minutes did you book the room? Reply with only the number. Do not change the booking."}])
print(answer.raw)
print("Booked duration:", booking.read_text())
assert answer.raw.strip() == booking.read_text(), "The continued conversation remembers a different duration from the completed reservation"

Expected behavior

A later turn should have access to the effective 45-minute duration associated with the completed reservation, and answer 45.

Screenshots/Code snippets

N/A

Operating System

Ubuntu 20.04

Python Version

3.11

crewAI Version

1.15.45

crewAI Tools Version

N/A — crewai-tools is not installed. The script uses crewai.tools from CrewAI itself.

Virtual Environment

Conda

Evidence

╭──────────────────────────── 🤖 LiteAgent Started ────────────────────────────╮
│                                                                              │
│  LiteAgent Started                                                           │
│  Role: Meeting coordinator                                                   │
│  Status: In Progress                                                         │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

╭──────────────────────────── 🤖 LiteAgent Started ────────────────────────────╮
│                                                                              │
│  LiteAgent Session Started                                                   │
│  Name: Meeting coordinator                                                   │
│  id: bdfa7042-ed00-43b7-9490-2c895f918c26                                    │
│  role: Meeting coordinator                                                   │
│  goal: Book rooms and answer reservation questions                           │
│  backstory: You remember completed bookings from the conversation.           │
│  tools: reserve_room                                                         │
│  verbose: True                                                               │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

Using an approximate input token count for model 'deepseek-flash': assuming one token per four characters because a native token count is unavailable.
╭─────────────────────── 🔧 Tool Execution Started (#1) ───────────────────────╮
│                                                                              │
│  Tool: reserve_room                                                          │
│  Args: {'duration_minutes': 35}                                              │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

WARNING:crewai.llms.base_llm:Using an approximate input token count for model 'deepseek-flash': assuming one token per four characters because a native token count is unavailable.
╭────────────────────── ✅ Tool Execution Completed (#1) ──────────────────────╮
│                                                                              │
│  Tool Completed                                                              │
│  Tool: reserve_room                                                          │
│  Output: Room reserved. Reference: MEETING-24.                               │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

WARNING:crewai.llms.base_llm:Using an approximate input token count for model 'deepseek-flash': assuming one token per four characters because a native token count is unavailable.
[Finalize] todos_count=0, todos_with_results=0
╭─────────────────────────── ✅ Agent Final Answer ────────────────────────────╮
│                                                                              │
│  Agent: Meeting coordinator                                                  │
│                                                                              │
│  Final Answer:                                                               │
│  Booked.                                                                     │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

Booked.╭─────────────────────────── ✅ LiteAgent Completed ───────────────────────────╮
│                                                                              │
│  LiteAgent Completed                                                         │
│  Role: Meeting coordinator                                                   │
│  id: bdfa7042-ed00-43b7-9490-2c895f918c26                                    │
│  role: Meeting coordinator                                                   │
│  goal: Book rooms and answer reservation questions                           │
│  backstory: You remember completed bookings from the conversation.           │
│  tools: reserve_room                                                         │
│  verbose: True                                                               │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯


╭──────────────────────────── 🤖 LiteAgent Started ────────────────────────────╮
│                                                                              │
│  LiteAgent Started                                                           │
│  Role: Meeting coordinator                                                   │
│  Status: In Progress                                                         │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

╭──────────────────────────── 🤖 LiteAgent Started ────────────────────────────╮
│                                                                              │
│  LiteAgent Session Started                                                   │
│  Name: Meeting coordinator                                                   │
│  id: bdfa7042-ed00-43b7-9490-2c895f918c26                                    │
│  role: Meeting coordinator                                                   │
│  goal: Book rooms and answer reservation questions                           │
│  backstory: You remember completed bookings from the conversation.           │
│  tools: reserve_room                                                         │
│  verbose: True                                                               │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

WARNING:crewai.llms.base_llm:Using an approximate input token count for model 'deepseek-flash': assuming one token per four characters because a native token count is unavailable.
[Finalize] todos_count=0, todos_with_results=0
╭─────────────────────────── ✅ Agent Final Answer ────────────────────────────╮
│                                                                              │
│  Agent: Meeting coordinator                                                  │
│                                                                              │
│  Final Answer:                                                               │
│  35                                                                          │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

35╭─────────────────────────── ✅ LiteAgent Completed ───────────────────────────╮
│                                                                              │
│  LiteAgent Completed                                                         │
│  Role: Meeting coordinator                                                   │
│  id: bdfa7042-ed00-43b7-9490-2c895f918c26                                    │
│  role: Meeting coordinator                                                   │
│  goal: Book rooms and answer reservation questions                           │
│  backstory: You remember completed bookings from the conversation.           │
│  tools: reserve_room                                                         │
│  verbose: True                                                               │
│                                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯


Booked duration: 45
Traceback (most recent call last):
  File "/tmp/crewai-room-reservation/main.py", line 37, in <module>
    assert answer.raw.strip() == booking.read_text(), "The continued conversation remembers a different duration from the completed reservation"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: The continued conversation remembers a different duration from the completed reservation

Possible Solution

None

Additional context

None

Activity

  1. added
    bug
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions