sologate-langchain
Human-in-the-loop approval gates for LangChain agents.
When your agent is about to do something risky — delete files, send bulk email, make API calls — Sologate pauses it and routes the action to a human for approval. One approve/reject click. Full audit trail. Agent resumes automatically.
pip install sologate-langchain
3-line integration
from sologate_langchain import SologateCallbackHandler
handler = SologateCallbackHandler(
sologate_url="https://www.sologate.app",
api_key="at_your_key_here",
)
agent_executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
That's it. Every tool call is scored automatically. Low-risk actions pass through silently. High-risk actions pause your agent and open an approval request in the Sologate Decision Center.
How it works
Agent calls tool
↓
SologateCallbackHandler.on_tool_start()
↓
Risk score 0–100 calculated locally (no API call for low-risk)
↓
score < threshold (60)? → runs silently ✓
score ≥ threshold? → POST /api/agent/request-approval
↓
Agent PAUSES (WebSocket wait)
↓
Human approves/rejects in dashboard
↓
Approved → agent continues ✓
Rejected → GateRejectedError raised ✗
Full example
import os
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_react_agent
from langchain_community.tools import ShellTool, WriteFileTool
from langchain import hub
from sologate_langchain import SologateCallbackHandler
llm = ChatOpenAI(model="gpt-4o")
tools = [ShellTool(), WriteFileTool()]
prompt = hub.pull("hwchase17/react")
agent = create_react_agent(llm, tools, prompt)
handler = SologateCallbackHandler(
sologate_url=os.environ["SOLOGATE_URL"],
api_key=os.environ["SOLOGATE_KEY"],
threshold=60, # gate anything scored ≥ 60/100
)
agent_executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
result = agent_executor.invoke({"input": "Clean up the project folder"})
When the agent tries rm -rf ./backups/ it scores 97/100 — HIGH and your terminal shows:
[sologate] 🔴 Gating: terminal (score 97/100 — HIGH)
[sologate] Reason: Shell command contains rm -rf (irreversible bulk deletion)
[sologate] Flags: • rm -rf detected
[sologate] Waiting for human decision at https://www.sologate.app/decisions...
Approve in the dashboard → agent continues. Reject → GateRejectedError raised.
Environment variables
export SOLOGATE_URL=https://www.sologate.app
export SOLOGATE_KEY=at_your_key_here
Or pass directly to SologateCallbackHandler(sologate_url=..., api_key=...).
Risk scoring
Scores are calculated locally — no network round-trip for safe actions.
| Score | Tier | Examples |
|---|---|---|
| 90+ | HIGH | rm -rf, DROP TABLE, curl | sh |
| 76–89 | HIGH | sudo, --force, credential file writes |
| 60–75 | HIGH | Bulk email, HTTP DELETE, force push |
| 30–59 | MEDIUM | Shell exec, file writes, outbound messages |
| 0–29 | LOW | Read operations, searches — auto-approved |
Customize the threshold:
handler = SologateCallbackHandler(..., threshold=80) # only gate HIGH risk
Low-level gate function
For custom agent frameworks (not LangChain):
from sologate_langchain import gate, GateRejectedError
try:
gate(
"delete_customer_records",
sologate_url="https://www.sologate.app",
api_key="at_...",
context="Agent is about to delete 312 inactive customer records",
payload={"count": 312, "table": "customers"},
)
# human approved — proceed
db.execute("DELETE FROM customers WHERE status='inactive'")
except GateRejectedError:
print("Rejected — no records deleted")
Links
Metadata
Release files for sologate-langchain 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| sologate_langchain-0.2.0.tar.gz | 11.4 kB | Without provenance | Details for sologate_langchain-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sologate_langchain-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for sologate_langchain-0.2.0-py3-none-any.whl |
Total release size: 20.8 kB
Release files / sologate_langchain-0.2.0.tar.gz
| Download URL | sologate_langchain-0.2.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34cbd32e515b9741fb9e4a7b0c11c182786cb19b115d70215002dbbbb6c83dff
|
|
BLAKE2b-256 checksum How to use checksums |
ea3f652d5cf5f26a522c298abb3b33fd213491530fb52565ed266c41325afa02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / sologate_langchain-0.2.0-py3-none-any.whl
| Download URL | sologate_langchain-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4d171c1f323b10a1ce6a770f8b6f9f45cf6763f2b4bd6e94af9544c142d0817
|
|
BLAKE2b-256 checksum How to use checksums |
0c39ad4bee01aceb3f0e95f92acbea628d4baa4f0b0bb67e21d29b507bdba932
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for sologate-langchain 0.2.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.