CrewAI Integration
CrewAI Integration
Section titled “CrewAI Integration”agentic-crew provides first-class support for CrewAI, the popular multi-agent orchestration framework. Define crews once in YAML and run them on CrewAI with full feature support.
Installation
Section titled “Installation”# Install with CrewAI supportpip install agentic-crew[crewai]
# Or install everythingpip install agentic-crew[ai]Quick Start
Section titled “Quick Start”1. Define Your Crew
Section titled “1. Define Your Crew”name: my-projectversion: "1.0"
crews: code_reviewer: description: Review code for issues and improvements agents: crews/code_reviewer/agents.yaml tasks: crews/code_reviewer/tasks.yamlsecurity_expert: role: Security Analyst goal: Identify security vulnerabilities in code backstory: | You are a senior security engineer with 15 years of experience in secure coding practices and penetration testing. verbose: true allow_delegation: false
code_quality_expert: role: Code Quality Specialist goal: Ensure code follows best practices backstory: | You are a clean code advocate with deep expertise in design patterns, SOLID principles, and maintainability. verbose: true allow_delegation: truesecurity_review: description: | Analyze the provided code for security vulnerabilities: - SQL injection - XSS attacks - Authentication issues - Hardcoded secrets agent: security_expert expected_output: Security findings with severity ratings
quality_review: description: | Review code for quality issues: - Code duplication - Complex functions - Naming conventions - Error handling agent: code_quality_expert expected_output: Quality improvement suggestions2. Run Your Crew
Section titled “2. Run Your Crew”from agentic_crew import run_crew
result = run_crew( package="my-project", crew="code_reviewer", inputs={"code_path": "./src"})
print(result)Or from CLI:
agentic-crew run my-project code_reviewer --input "Review ./src"CrewAI-Specific Features
Section titled “CrewAI-Specific Features”Using CrewAI Tools
Section titled “Using CrewAI Tools”researcher: role: Research Analyst goal: Research topics thoroughly backstory: Expert researcher tools: - search_internet - read_website - analyze_dataAgent Delegation
Section titled “Agent Delegation”Enable agents to delegate tasks:
manager: role: Project Manager goal: Coordinate the team backstory: Experienced tech lead allow_delegation: true # Can delegate to other agents
developer: role: Developer goal: Write code backstory: Senior developer allow_delegation: false # Executes tasks directlySequential vs Hierarchical
Section titled “Sequential vs Hierarchical”from agentic_crew import run_crew
# Sequential process (default)result = run_crew( package="my-project", crew="my_crew", inputs={}, process="sequential" # Tasks run in order)
# Hierarchical processresult = run_crew( package="my-project", crew="my_crew", inputs={}, process="hierarchical" # Manager delegates)Memory and Context
Section titled “Memory and Context”analyst: role: Data Analyst goal: Analyze data patterns backstory: Expert in data analysis memory: true # Enable memory cache: true # Cache responsesTask Dependencies
Section titled “Task Dependencies”gather_requirements: description: Gather project requirements agent: analyst expected_output: Requirements document
design_solution: description: Design a solution based on requirements agent: architect expected_output: Architecture document context: - gather_requirements # Depends on previous task
implement_solution: description: Implement the designed solution agent: developer expected_output: Working code context: - design_solution # Gets context from designAdvanced Configuration
Section titled “Advanced Configuration”Custom LLM Configuration
Section titled “Custom LLM Configuration”from agentic_crew import get_crew_config, run_crew_autofrom crewai import LLM
# Get crew configconfig = get_crew_config("./my-project", "code_reviewer")
# Configure custom LLMllm = LLM( model="anthropic/claude-sonnet-4-20250514", temperature=0.7, max_tokens=4096)
# Run with custom LLMresult = run_crew_auto(config, llm=llm)Using CrewAI Directly
Section titled “Using CrewAI Directly”For maximum control, build the CrewAI objects directly:
from agentic_crew.core.decomposer import get_runner
# Get the CrewAI runnerrunner = get_runner("crewai")
# Load configurationconfig = runner.load_config("./my-project", "code_reviewer")
# Build CrewAI objectscrew = runner.build_crew(config)
# Customize before runningcrew.verbose = Truecrew.max_rpm = 10
# Runresult = crew.kickoff(inputs={"code_path": "./src"})Custom Agents in Code
Section titled “Custom Agents in Code”Mix YAML and code definitions:
from crewai import Agent, Task, Crewfrom agentic_crew import get_crew_config
# Load base configconfig = get_crew_config("./my-project", "code_reviewer")
# Create custom agentcustom_agent = Agent( role="Performance Specialist", goal="Optimize code performance", backstory="Expert in algorithms and optimization", verbose=True, llm="anthropic/claude-sonnet-4-20250514")
# Create custom taskcustom_task = Task( description="Analyze code for performance bottlenecks", agent=custom_agent, expected_output="Performance optimization report")
# Add to crewfrom agentic_crew.core.decomposer import get_runnerrunner = get_runner("crewai")crew = runner.build_crew(config)
crew.agents.append(custom_agent)crew.tasks.append(custom_task)
result = crew.kickoff()Best Practices
Section titled “Best Practices”1. Clear Role Definitions
Section titled “1. Clear Role Definitions”# Good: Specific, focused rolesecurity_expert: role: API Security Specialist goal: Find authentication and authorization vulnerabilities backstory: 10 years of API security experience
# Bad: Vague rolehelper: role: Helper goal: Help with things backstory: General assistant2. Detailed Task Descriptions
Section titled “2. Detailed Task Descriptions”# Good: Detailed with expected formatsecurity_scan: description: | Scan the codebase for security issues:
1. Check all API endpoints for authentication 2. Verify input validation on user-facing forms 3. Look for SQL injection in database queries 4. Check for XSS in template rendering
Format findings as: - [SEVERITY] File:Line - Description expected_output: | Markdown table with columns: | Severity | Location | Issue | Recommendation |
# Bad: Vague taskscan: description: Check for security issues expected_output: Report3. Appropriate Delegation
Section titled “3. Appropriate Delegation”# Manager can delegateproject_lead: allow_delegation: true
# Specialists should executesecurity_analyst: allow_delegation: false
developer: allow_delegation: falseTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Crew not finding agents:
# Ensure paths are correct in manifest# agents: crews/my_crew/agents.yaml ✓# agents: ./agents.yaml ✗Tasks running out of order:
# Use context to define dependenciestask_b: context: - task_a # task_a must complete firstLLM rate limits:
from crewai import Crew
crew = Crew( agents=[...], tasks=[...], max_rpm=10, # Limit requests per minute share_crew=False)Next Steps
Section titled “Next Steps”- LangGraph Integration - Alternative framework
- Python Examples - More Python examples
- @agentic/crew Package - Full package reference