LangChain connector for Noxy human-in-the-loop — routes to all registered devices via agent middleware and webhooks.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Noxy LangChain Connector
LangChain connector for Noxy human-in-the-loop guardrails. Uses HumanInTheLoopMiddleware to pause agent tool calls, routes encrypted approval prompts to all devices registered for the identity (web, iOS, Android, Telegram), and resumes execution when Noxy fires a webhook.
Flow
sequenceDiagram
participant A as LangChain Agent
participant N as Noxy Relay
participant D as User Devices
participant S as Your Server
A->>N: send_decision (tool approval)
N->>D: Route to registered devices (web, iOS, Android, Telegram)
A->>A: interrupt() — state saved to checkpointer
Note over A: Agent suspended
alt User responds
D->>N: Approve / Reject
N->>S: Webhook (outcome)
S->>A: Command(resume=HITLResponse)
A->>A: Continue with approved/rejected tool calls
else Timeout
N->>S: Webhook (timeout / expired)
S->>A: Command(resume=reject)
A->>A: Continue with default behaviour
end
- The agent proposes a guarded tool call.
NoxyHumanInTheLoopMiddlewareroutes an encrypted actionable to all devices for the identity.- LangChain calls
interrupt()— the agent suspends and persists state via a checkpointer. - User responds on any registered device or the decision TTL expires.
- Noxy fires a webhook to your server.
- Your server calls
NoxyAgentResumeHandler.resume_from_webhook()→Command(resume=...). - The agent continues with approved, edited, or rejected tool calls.
Requirements
- Python >= 3.10
- A LangChain agent created with
create_agentand a checkpointer - noxy-sdk credentials (
NOXY_APP_TOKEN, target identity)
Target identity can be a phone number, email, user id, or wallet address (0x…).
Installation
pip install noxy-langchain
For the FastAPI webhook example:
pip install "noxy-langchain[examples]"
Local development against the monorepo SDK:
pip install -e ../../sdks/python-sdk
pip install -e ".[dev,examples]"
Quick start
import uuid
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
from noxy import NoxyConfig, init_noxy_agent_client
from noxy_langchain import NoxyLangChainBridge
@tool
def transfer_funds(to: str, amount: str) -> str:
"""Transfer funds."""
return f"Sent {amount} to {to}"
client = init_noxy_agent_client(
NoxyConfig(
endpoint="https://relay.noxy.network",
auth_token="your-app-token",
decision_ttl_seconds=3600,
)
)
bridge = NoxyLangChainBridge(client, "user@example.com")
agent = create_agent(
init_chat_model("openai:gpt-4o-mini"),
tools=[transfer_funds],
middleware=[bridge.create_hitl_middleware({"transfer_funds": True})],
checkpointer=InMemorySaver(),
)
resume_handler = bridge.create_resume_handler(agent)
config = {"configurable": {"thread_id": str(uuid.uuid4())}}
# agent.invoke(...) suspends when transfer_funds is proposed
# Later, in your webhook handler:
final = resume_handler.resume_from_webhook({
"decisionId": "<decisionId>",
"identityId": "user@example.com",
"outcome": "approved", # or "rejected", "expired"
})
Webhook payload
| Field | Type | Description |
|---|---|---|
decisionId |
str |
Decision to resume (snake_case decision_id also accepted) |
identityId |
str |
Identity that took the decision (phone, email, user id, or wallet) |
outcome |
str |
approved, rejected, expired, or timeout |
receivedAt |
str |
Optional ISO timestamp |
Noxy outcomes map to LangChain HITL decisions:
approved→{"type": "approve"}rejected/expired/timeout→{"type": "reject", "message": "..."}
API
| Symbol | Description |
|---|---|
NoxyLangChainBridge |
Wires client, registry, middleware factory, and resume handler |
NoxyHumanInTheLoopMiddleware |
LangChain middleware that routes tool approvals to Noxy |
NoxyAgentResumeHandler |
Resume paused agents from webhook payloads |
PendingDecisionRegistry |
Maps decision_id → thread_id for resume |
build_hitl_actionable(...) |
Build actionable payload from HITL action requests |
hitl_response_from_outcome(...) |
Map Noxy outcome to LangChain HITL resume value |
parse_webhook_payload(...) |
Parse raw webhook JSON |
Examples
examples/basic.py— middleware + webhook resume demo with a mock Noxy clientexamples/webhook_server.py— FastAPI server with/runsand/webhooks/noxy
python examples/basic.py
Development
make dev
make test
make build
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noxy_langchain-1.0.0.tar.gz.
File metadata
- Download URL: noxy_langchain-1.0.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db9bec92a520f661f4f31f0ee21799c424ea02fe11cf384f85c7dc94099649f9
|
|
| MD5 |
5cf3239a1af0412373a73aa21f6c6c11
|
|
| BLAKE2b-256 |
ec39d1f28f1a7e04bee06681303ac1841e2a346d94941bb79db3b00a4bf305f6
|
File details
Details for the file noxy_langchain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: noxy_langchain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31852781f073790862ec480660e50b38b52a31f49f03d5c038965fd502eed5de
|
|
| MD5 |
5db002c48849b1bf9b5c4e091526a84f
|
|
| BLAKE2b-256 |
1a4604e968bdb799a57619e2141a18253001f36b6a4297f3e8db0b3dd1822629
|