Skip to main content

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.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.2.0.tar.gz (4.6 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.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_trust_gate-0.2.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

Hashes for langchain_trust_gate-0.2.0.tar.gz
Algorithm Hash digest
SHA256 301d99a899c85776bbafcafcd1e866961552d3d37eaf17393efab8ffc535fda5
MD5 58c197937b9c412de7ce164fbd4995c4
BLAKE2b-256 375e1690b15f200d6a0ff94b06a142bc22690befa25fc030f1169c2ea0cb86c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_trust_gate-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd11440e3a43a391618853a421d917b08de32fc4855d34ca74190a0ee30c963d
MD5 cd81268ec3769fb812776303aa1c4b15
BLAKE2b-256 d19d3bbcd88c014b0de5f9289552f763a08a153d7a27d06075be9720e3481598

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