Skip to content

Commit

Permalink
small adjustments before cutting version
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomdmoura committed Jan 4, 2025
1 parent 7272fd1 commit d3da731
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/crewai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class Task(BaseModel):
default=3, description="Maximum number of retries when guardrail fails"
)
retry_count: int = Field(default=0, description="Current number of retries")

start_time: Optional[datetime.datetime] = Field(
default=None, description="Start time of the task execution"
)
Expand Down Expand Up @@ -391,10 +390,9 @@ def _execute_core(
)

self.retry_count += 1
context = (
f"### Previous attempt failed validation: {guardrail_result.error}\n\n\n"
f"### Previous result:\n{task_output.raw}\n\n\n"
"Try again, making sure to address the validation error."
context = self.i18n.errors("validation_error").format(
guardrail_result_error=guardrail_result.error,
task_output=task_output.raw
)
return self._execute_core(agent, context, tools)

Expand Down
6 changes: 3 additions & 3 deletions src/crewai/tools/agent_tools/base_agent_tools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Optional, Union
from typing import Optional

from pydantic import Field

Expand Down Expand Up @@ -54,12 +54,12 @@ def _execute(
) -> str:
"""
Execute delegation to an agent with case-insensitive and whitespace-tolerant matching.
Args:
agent_name: Name/role of the agent to delegate to (case-insensitive)
task: The specific question or task to delegate
context: Optional additional context for the task execution
Returns:
str: The execution result from the delegated agent or an error message
if the agent cannot be found
Expand Down
3 changes: 2 additions & 1 deletion src/crewai/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"tool_arguments_error": "Error: the Action Input is not a valid key, value dictionary.",
"wrong_tool_name": "You tried to use the tool {tool}, but it doesn't exist. You must use one of the following tools, use one at time: {tools}.",
"tool_usage_exception": "I encountered an error while trying to use the tool. This was the error: {error}.\n Tool {tool} accepts these inputs: {tool_inputs}",
"agent_tool_execution_error": "Error executing task with agent '{agent_role}'. Error: {error}"
"agent_tool_execution_error": "Error executing task with agent '{agent_role}'. Error: {error}",
"validation_error": "### Previous attempt failed validation: {guardrail_result_error}\n\n\n### Previous result:\n{task_output}\n\n\nTry again, making sure to address the validation error."
},
"tools": {
"delegate_work": "Delegate a specific task to one of the following coworkers: {coworkers}\nThe input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don't reference things but instead explain them.",
Expand Down
7 changes: 3 additions & 4 deletions src/crewai/utilities/planning_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import logging
from typing import Any, List, Optional

Expand Down Expand Up @@ -78,10 +77,10 @@ def _create_planner_task(self, planning_agent: Agent, tasks_summary: str) -> Tas
def _get_agent_knowledge(self, task: Task) -> List[str]:
"""
Safely retrieve knowledge source content from the task's agent.
Args:
task: The task containing an agent with potential knowledge sources
Returns:
List[str]: A list of knowledge source strings
"""
Expand All @@ -108,6 +107,6 @@ def _create_tasks_summary(self) -> str:
f"[{', '.join(str(tool) for tool in task.agent.tools)}]" if task.agent and task.agent.tools else '"agent has no tools"',
f',\n "agent_knowledge": "[\\"{knowledge_list[0]}\\"]"' if knowledge_list and str(knowledge_list) != "None" else ""
)

tasks_summary.append(task_summary)
return " ".join(tasks_summary)

0 comments on commit d3da731

Please sign in to comment.