Overview

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

Installation

Install the required packages:

pip install humanlayer controlflow 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: add and multiply
  3. Use @hl.require_approval() to require human approval before the multiply function can be called
  4. Create a ControlFlow task that uses these functions as tools
  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