Skip to main content

HumanLayer for LangGraph

PyPI version License: MIT

An integration package for using HumanLayer with LangGraph to build human-in-the-loop agents.

Installation

pip install humanlayer-langgraph-alpha

Features

  • Seamlessly integrate HumanLayer with LangGraph agents
  • Log tool calls and results to HumanLayer
  • Request human approval for critical actions
  • Collect human input within agent workflows
  • Build complete human-in-the-loop subgraphs

Quick Start

from humanlayer import HumanLayer
from humanlayer_langgraph import build_humanlayer_subgraph
from langchain_core.tools import tool
from langgraph.graph import StateGraph
from langgraph.graph import MessagesState

# Initialize HumanLayer
hl = HumanLayer(run_id="my-agent-run")

# Define your tools
@tool
def get_weather(location: str):
    """Get the current weather for a location."""
    return f"The weather in {location} is sunny."

# Build your graph
graph_builder = StateGraph(MessagesState)

# Create a HumanLayer-integrated tool node
tools_node = build_humanlayer_subgraph([get_weather], hl)

# Add the node to your graph
graph_builder.add_node("tools", tools_node)

Human Approval Workflows

For critical actions, you can require human approval:

from humanlayer_langgraph import create_human_approval_node

# Create a node that requires human approval
approval_node = create_human_approval_node(
    human_layer=hl,
    message_template="Please approve this action: {action}",
    timeout=300  # 5 minutes
)

# Add the node to your graph
graph_builder.add_node("human_approval", approval_node)

# Add conditional edges
graph_builder.add_conditional_edges(
    "chatbot",
    lambda state: "requires_approval" if needs_approval(state) else "direct_execution",
    {
        "requires_approval": "human_approval",
        "direct_execution": "tools"
    }
)

Human Input Collection

Collect input from humans during agent execution:

from humanlayer_langgraph import create_human_input_node

# Create a node that requests human input
input_node = create_human_input_node(
    human_layer=hl,
    prompt_template="Please provide input: {prompt}",
    timeout=300
)

# Add the node to your graph
graph_builder.add_node("human_input", input_node)

Examples

See the examples/ directory for complete examples of HumanLayer integration with LangGraph. You can run the examples with:

make run-examples

Development

Setting Up Development Environment

  1. Clone the repository:

    git clone https://github.com/humanlayer/humanlayer-langgraph-alpha.git
    cd humanlayer-langgraph-alpha
    
  2. Create a virtual environment and install development dependencies:

    make setup-dev
    
  3. Run the tests:

    make test
    

Development Commands

  • make format: Format code with black
  • make lint: Run linters (ruff, mypy)
  • make test: Run tests
  • make run-examples: Run example scripts
  • make clean: Clean build artifacts
  • make build: Build package

Publishing

Local Publishing

To release a new version:

  1. Bump the version (patch, minor, or major):

    make bump-patch  # or bump-minor, bump-major
    
  2. Build and publish:

    make publish  # or publish-test for TestPyPI
    

GitHub Actions

This package uses GitHub Actions to automate the release process:

  1. Go to the "Actions" tab in the GitHub repository
  2. Select the "Publish Package" workflow
  3. Click "Run workflow"
  4. Select the release type (patch, minor, or major)
  5. Click "Run workflow"

The action will:

  • Run tests
  • Bump the version
  • Build the package
  • Push the new tag
  • Publish to PyPI

Documentation

Full documentation is available at docs.humanlayer.com.

License

MIT

Metadata

Release files for humanlayer-langgraph-alpha 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for humanlayer-langgraph-alpha 0.1.0
File Size Uploaded Provenance Actions
humanlayer_langgraph_alpha-0.1.0.tar.gz 13.6 kB Without provenance Details for humanlayer_langgraph_alpha-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for humanlayer-langgraph-alpha 0.1.0
File Interpreter ABI Platform Actions
humanlayer_langgraph_alpha-0.1.0-py3-none-any.whl Python 3 none any Details for humanlayer_langgraph_alpha-0.1.0-py3-none-any.whl

Total release size: 24.0 kB

Release files / humanlayer_langgraph_alpha-0.1.0.tar.gz

Download URL humanlayer_langgraph_alpha-0.1.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ea685f5d4255728056e0b93517f77dc18b5b8a4fbf9cbc7a1cbea11070d3767
BLAKE2b-256 checksum
How to use checksums
809a08317c3ca7695c76f630844a4ea48470cc2babd941851216ad90571d924b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / humanlayer_langgraph_alpha-0.1.0-py3-none-any.whl

Download URL humanlayer_langgraph_alpha-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20108f75334826ca9daa675b31e8ab7d270dad92989a264100f97de5b7845e69
BLAKE2b-256 checksum
How to use checksums
1b75cac3350e4a9642f9805d0b32e6cdd83f03a89f0a22efb01752f6849bf01a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for humanlayer-langgraph-alpha 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page