langchain-trust-gate
LangChain tool for behavioral trust scoring via Dominion Observatory.
Gate agent actions on real behavioral attestation data — interaction history, success rates, latency — before executing sensitive operations.
Install
pip install langchain-trust-gate
Quick start
from langchain_trust_gate import TrustGateTool, check_trust
# As a LangChain tool (drop into any agent)
tool = TrustGateTool()
result = tool.invoke({"agent_id": "sg-cpf-calculator"})
# {'decision': 'PASS', 'score': 0.82, 'raw_score': 82, ...}
# Direct async call
evaluation = await check_trust("sg-cpf-calculator")
if evaluation["decision"] == "PASS":
# proceed with operation
pass
With a LangChain agent
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
from langchain_trust_gate import TrustGateTool
llm = ChatOpenAI(model="gpt-4")
tools = [TrustGateTool()]
agent = initialize_agent(
tools, llm, agent=AgentType.OPENAI_FUNCTIONS, verbose=True
)
agent.run("Check the trust score of the sg-cpf-calculator agent")
Decision thresholds
| Score (0-100) | Decision | Meaning |
|---|---|---|
| >= 60 | PASS |
Silver tier or above — proceed |
| 40-59 | UNCERTAIN |
Review band — apply extra checks |
| < 40 | FAIL |
Below Bronze — block operation |
Thresholds are configurable:
tool = TrustGateTool(pass_threshold=70, fail_threshold=30)
API
TrustGateTool
LangChain BaseTool subclass. Configurable fields:
| Field | Type | Default | Description |
|---|---|---|---|
base_url |
str |
Observatory URL | API endpoint |
pass_threshold |
int |
60 |
Minimum score for PASS |
fail_threshold |
int |
40 |
Scores below this are FAIL |
timeout |
float |
5.0 |
HTTP timeout in seconds |
check_trust(agent_id, **kwargs) -> TrustEvaluation
Async function for direct use outside LangChain.
check_trust_sync(agent_id, **kwargs) -> TrustEvaluation
Synchronous wrapper.
TrustEvaluation
TypedDict with fields:
decision:"PASS"|"FAIL"|"UNCERTAIN"score:float | None— normalized 0.0-1.0raw_score:int | None— raw 0-100 from Observatoryreason_code:str— machine-readable reasonevidence_uri:str | None— link to Observatory evidence pageprovider:str— always"dominion-observatory"agent_id:strevaluated_at:str— ISO 8601 timestamp
Spec reference
License
MIT
Metadata
Release files for langchain-trust-gate 0.3.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 | |
|---|---|---|---|
| langchain_trust_gate-0.3.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_trust_gate-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / langchain_trust_gate-0.3.0.tar.gz
| Download URL | langchain_trust_gate-0.3.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a022030ab0cbfed78a4a761c241ce729e0063f8f77950ee1ce24d3151e6ecdf6
|
|
BLAKE2b-256 checksum How to use checksums |
b42b3bd30c2e2dfe49184d54f0b910274d6ec4bc6dac518653cad850822a4bfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / langchain_trust_gate-0.3.0-py3-none-any.whl
| Download URL | langchain_trust_gate-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc7a81b4018b9bb7de373ac1cd5c249c0d4f2877ce363fa0828c48764b3165c0
|
|
BLAKE2b-256 checksum How to use checksums |
5ccfa3279079e41674e7a26cb37f0c6fdffa1b1d00613cf5252176c706f222e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|