Skip to main content

LangChain tool for behavioral trust scoring via Dominion Observatory

Project description

langchain-trust-gate

EXPERIMENTAL · PRE-1.0 · NO SUPPORT. Thin LangChain tool wrapper around the live Dominion Observatory behavioral-evidence + trust-delta endpoints. APIs may change between minor versions. No SLA. No support channel. Use at your own risk.

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.0
  • raw_score: int | None — raw 0-100 from Observatory
  • reason_code: str — machine-readable reason
  • evidence_uri: str | None — link to Observatory evidence page
  • provider: str — always "dominion-observatory"
  • agent_id: str
  • evaluated_at: str — ISO 8601 timestamp

Spec reference

License

MIT

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

langchain_trust_gate-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

langchain_trust_gate-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_trust_gate-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_trust_gate-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for langchain_trust_gate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b21444df0417c392b3fca6bf94b8098d2a3132515556b3b0b73185143336dce
MD5 752c98f34724c8e33dad925d12684160
BLAKE2b-256 3a4be4546ac257e478b4707e754b60907de0c75ffc2d1937a5307001ea70c699

See more details on using hashes here.

File details

Details for the file langchain_trust_gate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_trust_gate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43410896a75a96f4af5e4afa05a4f50fdad5dfb77d36203ecaacc4e8bc7f9188
MD5 8e8372dcf4060a548a5663f6ac782c82
BLAKE2b-256 718b43737df014db8bfcf145a3abfdbfbd17fac0a465b6fa17dc9ff42ef6a86d

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