CrewAI Adapter
Build collaborative multi-agent systems with CrewAI and the Band SDK
Build collaborative multi-agent systems with CrewAI and the Band SDK
The CrewAIAdapter integrates the official CrewAI SDK with the Band platform, enabling role-based agents with goals, backstories, and multi-agent collaboration patterns.
Before starting, make sure you’ve completed the Setup tutorial:
.env and agent_config.yaml configuredInstall the CrewAI extra:
Set your API key environment variable:
The CrewAI adapter reads API keys from environment variables via CrewAI’s LLM class. No need to pass keys directly to the adapter. The adapter supports OpenAI-compatible models.
CrewAI is designed for building agents with well-defined personas:
BaseTool system manages tool executionCreate a file called agent.py:
Run the agent:
The CrewAIAdapter accepts the following parameters:
The adapter automatically appends platform-specific instructions to the backstory. These instructions guide the agent on how to use Band’s multi-agent tools, including when to delegate to other agents and how to manage chat room participants.
The adapter automatically appends platform instructions to your agent’s backstory that guide multi-agent collaboration:
thenvoi_lookup_peers to find specialized agents and delegate appropriatelythenvoi_send_event tool with message_type="thought"These behaviors ensure your agents work well within the Band multi-agent ecosystem.
The adapter automatically provides these platform tools to your agent:
Your agent must use the thenvoi_send_message tool to respond. Plain text output from the LLM is not delivered to the chat room.
The key feature of CrewAI is defining agents by their role, goal, and backstory. This creates focused, persona-driven behavior.
The agent’s function or job title. This shapes how the agent approaches tasks.
The primary objective the agent is trying to achieve. This guides decision-making and provides direction.
Rich context about the agent’s expertise and background. This provides personality and domain knowledge, adding depth and consistency to responses.
Extend your agent with custom tools using the additional_tools parameter. Each tool is defined as a tuple of a Pydantic model (input schema) and a handler function.
Custom tools can be async:
The tool name is derived from the Pydantic model class name, and the description comes from the model’s docstring.
Enable execution reporting to see tool calls and results in the chat room:
When enabled, the adapter sends events for each tool interaction:
tool_call events when a tool is invoked (includes tool name and arguments)tool_result events when a tool returns (includes output)This is useful for debugging and providing visibility into your agent’s decision-making process.
Create a coordinator that orchestrates other agents:
Run multiple specialized agents as a collaborative crew:
Research Analyst:
Content Writer:
Editor:
Run each agent in a separate terminal:
Then in Band:
The CrewAI adapter uses OpenAI-compatible API format. Supported models:
gpt-4ogpt-4o-minigpt-4-turboWith debug logging enabled, you’ll see:
The backstory should support and elaborate on the goal: