mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Fix #2886: Add undocumented Agent parameters allow_feedback, allow_conflict, and allow_iteration
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -123,6 +123,18 @@ class Agent(BaseAgent):
|
|||||||
default="safe",
|
default="safe",
|
||||||
description="Mode for code execution: 'safe' (using Docker) or 'unsafe' (direct execution).",
|
description="Mode for code execution: 'safe' (using Docker) or 'unsafe' (direct execution).",
|
||||||
)
|
)
|
||||||
|
allow_feedback: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="Enable agent to receive and process feedback during execution.",
|
||||||
|
)
|
||||||
|
allow_conflict: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="Enable agent to handle conflicts with other agents during execution.",
|
||||||
|
)
|
||||||
|
allow_iteration: bool = Field(
|
||||||
|
default=False,
|
||||||
|
description="Enable agent to iterate on its solutions based on feedback and validation.",
|
||||||
|
)
|
||||||
embedder_config: Optional[Dict[str, Any]] = Field(
|
embedder_config: Optional[Dict[str, Any]] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="Embedder configuration for the agent.",
|
description="Embedder configuration for the agent.",
|
||||||
@@ -400,6 +412,9 @@ class Agent(BaseAgent):
|
|||||||
step_callback=self.step_callback,
|
step_callback=self.step_callback,
|
||||||
function_calling_llm=self.function_calling_llm,
|
function_calling_llm=self.function_calling_llm,
|
||||||
respect_context_window=self.respect_context_window,
|
respect_context_window=self.respect_context_window,
|
||||||
|
allow_feedback=self.allow_feedback,
|
||||||
|
allow_conflict=self.allow_conflict,
|
||||||
|
allow_iteration=self.allow_iteration,
|
||||||
request_within_rpm_limit=(
|
request_within_rpm_limit=(
|
||||||
self._rpm_controller.check_or_wait if self._rpm_controller else None
|
self._rpm_controller.check_or_wait if self._rpm_controller else None
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
respect_context_window: bool = False,
|
respect_context_window: bool = False,
|
||||||
request_within_rpm_limit: Any = None,
|
request_within_rpm_limit: Any = None,
|
||||||
callbacks: List[Any] = [],
|
callbacks: List[Any] = [],
|
||||||
|
allow_feedback: bool = False,
|
||||||
|
allow_conflict: bool = False,
|
||||||
|
allow_iteration: bool = False,
|
||||||
):
|
):
|
||||||
self._i18n: I18N = I18N()
|
self._i18n: I18N = I18N()
|
||||||
self.llm = llm
|
self.llm = llm
|
||||||
@@ -73,6 +76,9 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
|||||||
self.function_calling_llm = function_calling_llm
|
self.function_calling_llm = function_calling_llm
|
||||||
self.respect_context_window = respect_context_window
|
self.respect_context_window = respect_context_window
|
||||||
self.request_within_rpm_limit = request_within_rpm_limit
|
self.request_within_rpm_limit = request_within_rpm_limit
|
||||||
|
self.allow_feedback = allow_feedback
|
||||||
|
self.allow_conflict = allow_conflict
|
||||||
|
self.allow_iteration = allow_iteration
|
||||||
self.ask_for_human_input = False
|
self.ask_for_human_input = False
|
||||||
self.messages: List[Dict[str, str]] = []
|
self.messages: List[Dict[str, str]] = []
|
||||||
self.iterations = 0
|
self.iterations = 0
|
||||||
|
|||||||
@@ -1625,3 +1625,30 @@ def test_agent_with_knowledge_sources():
|
|||||||
|
|
||||||
# Assert that the agent provides the correct information
|
# Assert that the agent provides the correct information
|
||||||
assert "red" in result.raw.lower()
|
assert "red" in result.raw.lower()
|
||||||
|
|
||||||
|
|
||||||
|
def test_agent_with_feedback_conflict_iteration_params():
|
||||||
|
"""Test that the agent correctly handles the allow_feedback, allow_conflict, and allow_iteration parameters."""
|
||||||
|
agent = Agent(
|
||||||
|
role="test role",
|
||||||
|
goal="test goal",
|
||||||
|
backstory="test backstory",
|
||||||
|
allow_feedback=True,
|
||||||
|
allow_conflict=True,
|
||||||
|
allow_iteration=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert agent.allow_feedback is True
|
||||||
|
assert agent.allow_conflict is True
|
||||||
|
assert agent.allow_iteration is True
|
||||||
|
|
||||||
|
# Create another agent with default values
|
||||||
|
default_agent = Agent(
|
||||||
|
role="test role",
|
||||||
|
goal="test goal",
|
||||||
|
backstory="test backstory",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert default_agent.allow_feedback is False
|
||||||
|
assert default_agent.allow_conflict is False
|
||||||
|
assert default_agent.allow_iteration is False
|
||||||
|
|||||||
Reference in New Issue
Block a user