Skip to main content

Governance gate for LangChain agents. Powered by Sentinel AI — pauses risky actions for human approval, logs every decision, generates compliance reports.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sologate_langchain-0.2.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sologate_langchain-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file sologate_langchain-0.2.0.tar.gz.

File metadata

  • Download URL: sologate_langchain-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for sologate_langchain-0.2.0.tar.gz
Algorithm Hash digest
SHA256 34cbd32e515b9741fb9e4a7b0c11c182786cb19b115d70215002dbbbb6c83dff
MD5 d80b82afec362912ca2571db32389883
BLAKE2b-256 ea3f652d5cf5f26a522c298abb3b33fd213491530fb52565ed266c41325afa02

See more details on using hashes here.

File details

Details for the file sologate_langchain-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sologate_langchain-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4d171c1f323b10a1ce6a770f8b6f9f45cf6763f2b4bd6e94af9544c142d0817
MD5 4959d9bb9ed318cafb5bd380c67107fb
BLAKE2b-256 0c39ad4bee01aceb3f0e95f92acbea628d4baa4f0b0bb67e21d29b507bdba932

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page