This project has been archived by its maintainers, and is no longer receiving any updates.
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
Metadata
Release files for noxy-langchain 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| noxy_langchain-1.0.0.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| noxy_langchain-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / noxy_langchain-1.0.0.tar.gz
| Download URL | noxy_langchain-1.0.0.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db9bec92a520f661f4f31f0ee21799c424ea02fe11cf384f85c7dc94099649f9
|
|
BLAKE2b-256 checksum How to use checksums |
ec39d1f28f1a7e04bee06681303ac1841e2a346d94941bb79db3b00a4bf305f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / noxy_langchain-1.0.0-py3-none-any.whl
| Download URL | noxy_langchain-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31852781f073790862ec480660e50b38b52a31f49f03d5c038965fd502eed5de
|
|
BLAKE2b-256 checksum How to use checksums |
1a4604e968bdb799a57619e2141a18253001f36b6a4297f3e8db0b3dd1822629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|