Skip to main content

Python client for the OpenClaw Governor – runtime AI-agent governance service

Project description

openclaw-governor-client

Python client for the OpenClaw Governor – a runtime governance layer for AI agents.

The Governor evaluates every tool invocation against configurable policies and returns an allow / block / review decision before the tool executes.

Installation

pip install openclaw-governor-client

Quick start

from governor_client import evaluate_action, GovernorBlockedError

# Evaluate a tool call against the Governor
try:
    decision = evaluate_action(
        tool="shell_exec",
        args={"command": "ls -la /tmp"},
        context={"session_id": "abc-123"},
    )
    print(decision["decision"])      # "allow" | "review"
    print(decision["risk_score"])    # 0.0 – 1.0
    print(decision["explanation"])
except GovernorBlockedError as e:
    print(f"Blocked: {e}")

Configuration

Environment variable Default Description
GOVERNOR_URL http://localhost:8000 Base URL of the Governor service

You can also pass the URL programmatically:

import governor_client

governor_client.GOVERNOR_URL = "https://openclaw-governor.fly.dev"

API

evaluate_action(tool, args, context=None) → dict

Send a tool call to the Governor for evaluation.

Returns the full decision dict:

{
    "decision": "allow",        # "allow" | "block" | "review"
    "risk_score": 0.15,
    "explanation": "Low-risk read operation",
    "policy_ids": ["shell-guard"],
    "modified_args": None,
}

Raises GovernorBlockedError if the decision is "block".

governed_call(tool, args, context=None) → dict

Convenience wrapper around evaluate_action. Identical behaviour — callers should inspect decision for "review" and handle accordingly.

GovernorBlockedError

Exception raised when the Governor blocks a tool invocation. Subclass of RuntimeError.

Requirements

  • Python ≥ 3.9
  • httpx ≥ 0.24.0

License

MIT — see LICENSE.

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

openclaw_governor_client-0.2.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

openclaw_governor_client-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openclaw_governor_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c74963e2c32639840c3b7d6008e5de39c2604ba58b5dd9b759a6193e776ebe5f
MD5 2d14b70b94586773f49fdd5a473bbd73
BLAKE2b-256 5e1774105d9b51e516bbe5152ade10625aae357429f130adb02d39d1452741da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openclaw_governor_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dc16d9c9be7aa7893e42893f4d3cda0145ec8963c032925a62908b17ec4f9d3
MD5 e20a9f2ed4c5a8ee7f1ea2f1b7b1c1e9
BLAKE2b-256 556c98a01ac4aabf44cf7cecf5e199c4852d98a725d223a3ed899382b66493fa

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