LangChain tool for behavioral trust scoring via Dominion Observatory
Project description
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
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 langchain_trust_gate-0.3.0.tar.gz.
File metadata
- Download URL: langchain_trust_gate-0.3.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a022030ab0cbfed78a4a761c241ce729e0063f8f77950ee1ce24d3151e6ecdf6
|
|
| MD5 |
e08a0d57f41c074268a7f67aebdb5596
|
|
| BLAKE2b-256 |
b42b3bd30c2e2dfe49184d54f0b910274d6ec4bc6dac518653cad850822a4bfa
|
File details
Details for the file langchain_trust_gate-0.3.0-py3-none-any.whl.
File metadata
- Download URL: langchain_trust_gate-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc7a81b4018b9bb7de373ac1cd5c249c0d4f2877ce363fa0828c48764b3165c0
|
|
| MD5 |
f24d2053e78ecef3099d133e6b93d968
|
|
| BLAKE2b-256 |
5ccfa3279079e41674e7a26cb37f0c6fdffa1b1d00613cf5252176c706f222e1
|