mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-21 22:08:21 +00:00
Address PR feedback: Add type hints and improve docstrings
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -873,7 +873,19 @@ class Crew(BaseModel):
|
||||
tools = self._inject_delegation_tools(tools, self.manager_agent, self.agents)
|
||||
return tools
|
||||
|
||||
def _get_context(self, task: Task, task_outputs: List[TaskOutput]):
|
||||
def _get_context(self, task: Task, task_outputs: List[TaskOutput]) -> str:
|
||||
"""Get context for task execution.
|
||||
|
||||
Determines whether to use the task's explicit context or aggregate outputs from previous tasks.
|
||||
When task.context is an empty list, it will use the task_outputs instead.
|
||||
|
||||
Args:
|
||||
task: The task to get context for
|
||||
task_outputs: List of previous task outputs
|
||||
|
||||
Returns:
|
||||
String containing the aggregated context
|
||||
"""
|
||||
context = (
|
||||
aggregate_raw_outputs_from_tasks(task.context)
|
||||
if task.context and len(task.context) > 0
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""Test that context=[] is respected and doesn't include previous task outputs."""
|
||||
import pytest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from crewai import Agent, Crew, Process, Task
|
||||
from crewai.tasks.task_output import OutputFormat, TaskOutput
|
||||
from crewai.utilities.formatter import (
|
||||
@@ -9,8 +10,19 @@ from crewai.utilities.formatter import (
|
||||
aggregate_raw_outputs_from_tasks,
|
||||
)
|
||||
|
||||
|
||||
def test_context_empty_list():
|
||||
"""Test that context=[] is respected and doesn't include previous task outputs."""
|
||||
"""Test that context=[] is respected and doesn't include previous task outputs.
|
||||
|
||||
This test verifies that when a task has context=[], the _get_context method
|
||||
correctly uses task_outputs instead of an empty context list.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
Raises:
|
||||
AssertionError: If the context handling doesn't work as expected
|
||||
"""
|
||||
|
||||
|
||||
researcher = Agent(
|
||||
|
||||
Reference in New Issue
Block a user