docs: improve documentation and test assertions as per PR review

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-05-06 22:51:29 +00:00
parent 6fb4438e52
commit 17efd214fb
2 changed files with 16 additions and 2 deletions

View File

@@ -14,7 +14,12 @@ class DelegateWorkToolSchema(BaseModel):
class DelegateWorkTool(BaseAgentTool): class DelegateWorkTool(BaseAgentTool):
"""Tool for delegating work to coworkers""" """Tool for delegating work to other agents in the crew.
Attributes:
result_as_answer (bool): When True, returns the delegated agent's result
as the final answer instead of metadata about delegation.
"""
name: str = "Delegate work to coworker" name: str = "Delegate work to coworker"
args_schema: type[BaseModel] = DelegateWorkToolSchema args_schema: type[BaseModel] = DelegateWorkToolSchema

View File

@@ -1,6 +1,7 @@
"""Test to ensure hierarchical process mode returns complete final answers.""" """Test to ensure hierarchical process mode returns complete final answers."""
import pytest import pytest
from crewai.agent import Agent from crewai.agent import Agent
from crewai.crew import Crew from crewai.crew import Crew
from crewai.process import Process from crewai.process import Process
@@ -9,7 +10,14 @@ from crewai.task import Task
@pytest.mark.vcr(filter_headers=["authorization"]) @pytest.mark.vcr(filter_headers=["authorization"])
def test_hierarchical_process_delegation_result(): def test_hierarchical_process_delegation_result():
"""Test that the hierarchical process returns the delegated agent's result, not just the manager's delegation thought.""" """Tests hierarchical process delegation result handling.
Ensures that:
1. The output is derived from the delegated agent's actual work.
2. The response does not contain delegation-related metadata.
3. The content meets minimum length requirements.
4. Expected topic-related keywords are present in the output.
"""
researcher = Agent( researcher = Agent(
role="Researcher", role="Researcher",
goal="Make the best research and analysis on content about AI and AI agents", goal="Make the best research and analysis on content about AI and AI agents",
@@ -40,6 +48,7 @@ def test_hierarchical_process_delegation_result():
assert "idea" in result.raw.lower() or "article" in result.raw.lower() assert "idea" in result.raw.lower() or "article" in result.raw.lower()
assert len(result.raw) > 100 # Ensure we have substantial content assert len(result.raw) > 100 # Ensure we have substantial content
assert result.raw.count('\n') >= 6 # At least 3 ideas with paragraphs
assert "delegate" not in result.raw.lower() assert "delegate" not in result.raw.lower()
assert "delegating" not in result.raw.lower() assert "delegating" not in result.raw.lower()