[BUG] Agent.kickoff() history omits tool arguments applied by before_tool_call hooks
Los mantenedores suelen responder en 1 día
@oOtiti ya está trabajando en esto.
Desde el 25/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 63/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- ai-infra-agents, backend
Línea de trabajo
Start by tracing how Agent.kickoff() records native tool calls in first.messages, then follow the before_tool_call hook path to see where the changed context.tool_input is passed to the tool. Check the relevant tests for tool hooks and kickoff history, and add coverage for a hook that changes an argument. Done means the returned history contains the effective arguments used by the tool, so a later kickoff can answer with 45 minutes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 61.2k
- Forks
- 9.2k
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 180
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de crewAIInc/crewAI
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerPosiblemente ocupada @HashimSyedUBC la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingPosiblemente ocupada @basil-k-aji-dev la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
[BUG] Native Azure provider ignores the seed settingPosiblemente ocupada @basil-k-aji-dev la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
crewAIInc/crewAI#9787 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summaryPosiblemente ocupada @basil-k-aji-dev la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de crewAIInc/crewAI
Issues similares
-
bug harness
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
mruangutai/harness#2687 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
modal-labs/modal-client#4158 ·
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
The-Swarm-Corporation/swarms-rs#168 ·
Los mantenedores suelen responder en 1 día
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
linuxserver/docker-healthchecks#137 · 1 comentario ·