mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
Adding tool caching a loop execution prevention. (#25)
* Adding tool caching a loop execution prevention. This adds some guardrails, to both prevent the same tool to be used consecutively and also caching tool's results across the entire crew so it cuts down execution time and eventual LLM calls. This plays a huge role for smaller opensource models that usually fall into those behaviors patterns. It also includes some smaller improvements around the tool prompt and agent tools, all with the same intention of guiding models into better conform with agent instructions.
This commit is contained in:
@@ -16,7 +16,7 @@ class AgentTools(BaseModel):
|
||||
return [
|
||||
Tool.from_function(
|
||||
func=self.delegate_work,
|
||||
name="Delegate Work to Co-Worker",
|
||||
name="Delegate work to co-worker",
|
||||
description=dedent(
|
||||
f"""Useful to delegate a specific task to one of the
|
||||
following co-workers: [{', '.join([agent.role for agent in self.agents])}].
|
||||
@@ -28,7 +28,7 @@ class AgentTools(BaseModel):
|
||||
),
|
||||
Tool.from_function(
|
||||
func=self.ask_question,
|
||||
name="Ask Question to Co-Worker",
|
||||
name="Ask question to co-worker",
|
||||
description=dedent(
|
||||
f"""Useful to ask a question, opinion or take from on
|
||||
of the following co-workers: [{', '.join([agent.role for agent in self.agents])}].
|
||||
@@ -53,10 +53,10 @@ class AgentTools(BaseModel):
|
||||
try:
|
||||
agent, task, information = command.split("|")
|
||||
except ValueError:
|
||||
return "Error executing tool. Missing exact 3 pipe (|) separated values. For example, `coworker|task|information`."
|
||||
return "\nError executing tool. Missing exact 3 pipe (|) separated values. For example, `coworker|task|information`."
|
||||
|
||||
if not agent or not task or not information:
|
||||
return "Error executing tool. Missing exact 3 pipe (|) separated values. For example, `coworker|question|information`."
|
||||
return "\nError executing tool. Missing exact 3 pipe (|) separated values. For example, `coworker|question|information`."
|
||||
|
||||
agent = [
|
||||
available_agent
|
||||
@@ -65,9 +65,7 @@ class AgentTools(BaseModel):
|
||||
]
|
||||
|
||||
if len(agent) == 0:
|
||||
return (
|
||||
"Error executing tool. Co-worker not found, double check the co-worker."
|
||||
)
|
||||
return f"\nError executing tool. Co-worker mentioned on the Action Input not found, it must to be one of the following options: {', '.join([agent.role for agent in self.agents])}."
|
||||
|
||||
agent = agent[0]
|
||||
result = agent.execute_task(task, information)
|
||||
|
||||
Reference in New Issue
Block a user