Framework Integration

LangChain Integration

Secure LangChain agents with Amorce in 2 lines of code

⚡ 2-Line Security for LangChain

Add Ed25519 signatures, human-in-the-loop approvals, and agent-to-agent compatibility to any LangChain agent with minimal code changes.

Quick Start

Installation

pip install langchain-amorce

Basic Usage

Turn any LangChain agent into a secure Amorce agent:

from langchain_amorce import AmorceAgent
from langchain.chat_models import ChatOpenAI
from langchain.tools import DuckDuckGoSearchRun

# Create secure agent
agent = AmorceAgent(
    llm=ChatOpenAI(model="gpt-4"),
    tools=[DuckDuckGoSearchRun()],
    secure=True  # ← Adds Amorce security
)

# Use normally - all actions are now cryptographically signed
result = agent.run("What's the latest AI news?")
print(f"Agent ID: {agent.agent_id}")  # Verified identity

✅ That's it! Your LangChain agent now has: Ed25519 cryptographic signatures • Trust Directory verification • Automatic identity management • A2A-compatible messages

Features

🔐 Cryptographic Signatures

Every agent action is signed with Ed25519, providing non-repudiable proof of authorization. All communications are verified before execution.

👤 Human-in-the-Loop (HITL)

Require human approval for sensitive operations:

from langchain.tools import ShellTool

agent = AmorceAgent(
    llm=ChatOpenAI(),
    tools=[
        DuckDuckGoSearchRun(),  # No approval needed
        ShellTool()              # Dangerous!
    ],
    hitl_required=['shell'],  # Require approval for shell
    secure=True
)

# Search works normally
agent.run("Search for Python tutorials")

# Shell command triggers approval popup
agent.run("Delete tmp files")  # ← Human approval required!

🔗 A2A Protocol Compatible

Messages are formatted for Agent-to-Agent Protocol compatibility:

agent = AmorceAgent(
    llm=ChatOpenAI(),
    tools=[search],
    a2a_compatible=True  # ← Enable A2A format
)

# All messages use A2A envelope with Amorce signatures

Live Example: Marketplace Demo

See LangChain + Amorce in action with Sarah, a buyer agent that negotiates with a CrewAI seller agent:

from langchain_amorce import AmorceAgent
from langchain.chat_models import ChatOpenAI

sarah = AmorceAgent(
    name="Sarah",
    role="Smart Shopper",
    llm=ChatOpenAI(model="gpt-4"),
    tools=[
        brave_search_tool,      # Price research
        budget_calculator,       # Affordability check
        fraud_detector,         # Verify seller
    ],
    hitl_required=['make_payment', 'share_address'],
    max_budget=500,
    secure=True
)

# Sarah autonomously:
# 1. Searches for MacBook prices
# 2. Finds sellers in Trust Directory
# 3. Verifies reputations
# 4. Negotiates price
# 5. Requests human approval for payment

🎬 Full Demo: Check out the complete Agent Marketplace Demo showing Sarah negotiating with Henri (CrewAI).

Advanced Configuration

Custom Identity

Load an existing identity instead of generating a new one:

from amorce import IdentityManager

# Load existing identity
identity = IdentityManager.load_from_file("my_agent.pem")

agent = AmorceAgent(
    llm=ChatOpenAI(),
    tools=[...],
    identity=identity  # Use specific identity
)

Custom Amorce Client

Connect to a custom orchestrator or directory:

from amorce import AmorceClient

client = AmorceClient(
    identity,
    directory_url='https://my-directory.com',
    orchestrator_url='https://my-orchestrator.com'
)

agent = AmorceAgent(
    llm=ChatOpenAI(),
    tools=[...],
    amorce_client=client  # Custom client
)

✅ Production Ready

The langchain-amorce integration is battle-tested and used in production environments. It seamlessly integrates with existing LangChain codebases.

Resources