Files
crewAI/lib
Devin AI 999f9bee87 fix: clear agent executor messages when reused across tasks
Fixes #4319

When the same agent is reused across multiple sequential tasks (common
pattern in Flow with @listen decorators), the agent executor's message
history was not cleared between tasks. This caused messages to accumulate,
leading to:
- Duplicate system messages
- Context pollution
- Eventually crashes with 'Invalid response from LLM call - None or empty'

The fix clears the messages list and resets the iterations counter in
_update_executor_parameters() when the agent executor is reused for a
new task.

Added tests to verify:
- Messages are cleared when agent executor is reused between tasks
- Iterations counter is reset
- State isolation works across multiple crew kickoffs

Co-Authored-By: João <joao@crewai.com>
2026-01-31 15:55:48 +00:00
..