mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 07:38:29 +00:00
fixing tests
This commit is contained in:
@@ -401,7 +401,7 @@ def show_agent_logs(
|
||||
)
|
||||
if task_description:
|
||||
# Filter out reasoning plan from display (but keep it in actual task for LLM)
|
||||
display_description = _filter_reasoning_plan_from_display(task_description)
|
||||
display_description = _filter_auxiliary_from_display(task_description)
|
||||
printer.print(
|
||||
content=f"\033[95m## Task:\033[00m \033[92m{display_description}\033[00m"
|
||||
)
|
||||
@@ -437,22 +437,42 @@ def show_agent_logs(
|
||||
)
|
||||
|
||||
|
||||
def _filter_reasoning_plan_from_display(task_description: str) -> str:
|
||||
"""Filter out reasoning plan from task description for display purposes only.
|
||||
def _filter_auxiliary_from_display(task_description: str) -> str:
|
||||
"""Remove standard auxiliary sections (e.g., date injection, reasoning plan) from task description for display.
|
||||
|
||||
This keeps the reasoning plan in the actual task description for the LLM to use,
|
||||
but removes it from the display logs to avoid duplication with reasoning panels.
|
||||
This function standardizes the removal of auxiliary information such as the injected current date
|
||||
and the reasoning plan from the task description, ensuring that only the core task is shown in display logs.
|
||||
The actual task description (with all sections) is still used for LLM input.
|
||||
|
||||
Args:
|
||||
task_description: The full task description that may contain a reasoning plan
|
||||
task_description (str): The full task description, possibly containing auxiliary sections.
|
||||
|
||||
Returns:
|
||||
Task description with reasoning plan removed for display purposes
|
||||
str: The task description with auxiliary sections removed for display purposes.
|
||||
|
||||
Example:
|
||||
>>> desc = "Do X\\n\\nCurrent Date: 2024-06-01\\n\\nReasoning Plan:\\nStep 1..."
|
||||
>>> _filter_auxiliary_from_display(desc)
|
||||
'Do X'
|
||||
"""
|
||||
# Look for the reasoning plan section and remove it for display
|
||||
if "\n\nReasoning Plan:\n" in task_description:
|
||||
return task_description.split("\n\nReasoning Plan:\n")[0]
|
||||
return task_description
|
||||
# Define patterns for auxiliary sections to remove, in order.
|
||||
auxiliary_patterns = [
|
||||
(r"\n\nCurrent Date: [^\n]*", "date injection"),
|
||||
(r"\n\nReasoning Plan:\n.*", "reasoning plan"),
|
||||
]
|
||||
|
||||
cleaned_description = task_description
|
||||
|
||||
for pattern, _ in auxiliary_patterns:
|
||||
# For the reasoning plan, remove everything from the marker to the end.
|
||||
if "Reasoning Plan" in pattern:
|
||||
match = re.search(r"\n\nReasoning Plan:\n", cleaned_description)
|
||||
if match:
|
||||
cleaned_description = cleaned_description[: match.start()]
|
||||
else:
|
||||
cleaned_description = re.sub(pattern, "", cleaned_description)
|
||||
|
||||
return cleaned_description.strip()
|
||||
|
||||
|
||||
def load_agent_from_repository(from_repository: str) -> Dict[str, Any]:
|
||||
|
||||
@@ -29,7 +29,8 @@ def test_agent_with_reasoning(mock_llm_responses):
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
verbose=True
|
||||
verbose=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -61,7 +62,8 @@ def test_agent_with_reasoning_not_ready_initially(mock_llm_responses):
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
max_reasoning_attempts=2,
|
||||
verbose=True
|
||||
verbose=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -102,7 +104,8 @@ def test_agent_with_reasoning_max_attempts_reached():
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
max_reasoning_attempts=2,
|
||||
verbose=True
|
||||
verbose=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -138,7 +141,8 @@ def test_agent_reasoning_input_validation():
|
||||
goal="To test the reasoning feature",
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True
|
||||
reasoning=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="Both task and agent must be provided"):
|
||||
@@ -161,7 +165,8 @@ def test_agent_reasoning_error_handling():
|
||||
goal="To test the reasoning feature",
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True
|
||||
reasoning=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -196,7 +201,8 @@ def test_agent_with_function_calling():
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
verbose=True
|
||||
verbose=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -234,7 +240,8 @@ def test_agent_with_function_calling_fallback():
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
verbose=True
|
||||
verbose=True,
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -270,7 +277,8 @@ def test_agent_with_reasoning_non_verbose_mode(mock_llm_responses):
|
||||
backstory="I am a test agent created to verify the reasoning feature works correctly.",
|
||||
llm=llm,
|
||||
reasoning=True,
|
||||
verbose=False # Non-verbose mode
|
||||
verbose=False, # Non-verbose mode
|
||||
inject_date=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
|
||||
Reference in New Issue
Block a user