feat: enhance manager coworker context

- Add coworker goals and backstories to delegation tool descriptions
- Update i18n templates to support multiline coworker descriptions
- Add tests for similar role scenarios

Fixes #2095

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-11 10:34:19 +00:00
parent 47818f4f41
commit 172157e8d5
4 changed files with 108 additions and 24 deletions

View File

@@ -124,3 +124,36 @@ def test_ask_question_to_wrong_agent():
result
== "\nError executing tool. coworker mentioned not found, it must be one of the following options:\n- researcher\n"
)
def test_delegate_work_with_similar_roles():
"""Test that delegation tools show rich context for similar roles."""
researcher1 = Agent(
role="Quick Researcher",
goal="Find information quickly, prioritizing speed",
backstory="Specialist in rapid information gathering"
)
researcher2 = Agent(
role="Deep Researcher",
goal="Find detailed and thorough information",
backstory="Expert in comprehensive research"
)
tools = AgentTools(agents=[researcher1, researcher2]).tools()
delegate_tool = tools[0]
ask_tool = tools[1]
# Verify tool descriptions include goals and backstories
assert "Quick Researcher (Goal: Find information quickly" in delegate_tool.description
assert "Deep Researcher (Goal: Find detailed" in delegate_tool.description
assert "Specialist in rapid information gathering" in delegate_tool.description
assert "Expert in comprehensive research" in delegate_tool.description
# Verify ask tool also has the enhanced descriptions
assert "Quick Researcher (Goal: Find information quickly" in ask_tool.description
assert "Deep Researcher (Goal: Find detailed" in ask_tool.description
assert "Specialist in rapid information gathering" in ask_tool.description
assert "Expert in comprehensive research" in ask_tool.description
# Verify multiline formatting
assert "\n- " in delegate_tool.description
assert "\n- " in ask_tool.description