feat: Add multi-round dialogue functionality (fixes #2250)

- Add max_dialogue_rounds parameter to Task class with default of 10
- Update _handle_regular_feedback method to support multiple rounds
- Update _ask_human_input method to display current round information
- Pass max_dialogue_rounds parameter through agent execution flow
- Add tests for Task class max_dialogue_rounds parameter

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-28 10:13:52 +00:00
parent 86825e1769
commit 1225071e00
5 changed files with 76 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
import unittest
from unittest.mock import patch
from crewai.task import Task
class TestMultiRoundDialogue(unittest.TestCase):
"""Test the multi-round dialogue functionality."""
def test_task_max_dialogue_rounds_default(self):
"""Test that Task has a default max_dialogue_rounds of 10."""
# Create a task with default max_dialogue_rounds
task = Task(
description="Test task",
expected_output="Test output",
human_input=True
)
# Verify the default value
self.assertEqual(task.max_dialogue_rounds, 10)
def test_task_max_dialogue_rounds_custom(self):
"""Test that Task accepts a custom max_dialogue_rounds."""
# Create a task with custom max_dialogue_rounds
task = Task(
description="Test task",
expected_output="Test output",
human_input=True,
max_dialogue_rounds=5
)
# Verify the custom value
self.assertEqual(task.max_dialogue_rounds, 5)
if __name__ == "__main__":
unittest.main()