Overview

Humanlayer integrates seamlessly with CrewAI to add human oversight to your AI applications. This guide shows you how to use Humanlayer with CrewAI.

Installation

Install the required packages:

pip install humanlayer crewai crewai-tools python-dotenv

Basic Example

Let’s create a simple math agent that performs basic arithmetic operations with human oversight.

How it Works

  1. We create a HumanLayer instance with an optional run_id to identify this agent in the approval history
  2. Define two math functions as CrewAI tools using the @tool decorator
  3. Use @hl.require_approval() to require human approval before the multiply function can be called
  4. Create a CrewAI agent with these tools and a task to perform
  5. The agent will request approval before executing the multiply function

Running the Example

  1. Set up your environment variables in .env
  2. Run the example:
python main.py

When the agent attempts to use the multiply function, it will pause and request human approval through your configured contact channel (Slack, Email, etc).

Next Steps

For more framework examples, see https://github.com/humanlayer/humanlayer/tree/main/examples