Skip to main content

watchlight-claude-agent

Governed Claude Agent SDK agents with Watchlight: every tool call and every sub-agent launch is authorized before it runs, and refused on any doubt.

pip install watchlight-claude-agent

Independent third-party plugin. This is an independent integration built by Watchlight AI. It is not affiliated with, endorsed by, or sponsored by Anthropic. Claude Agent SDK and related names are trademarks of Anthropic, used here nominatively only to describe compatibility.

What it enforces

The Python Claude Agent SDK has no plugin loader, so the plugin ships its enforcement as a hook map. plugin.governed_options(handle, options) (or plugin.governance_hooks(handle)) adds these hooks to your ClaudeAgentOptions:

  • Every tool call goes through a PreToolUse gate. The call is authorized on the handle of the agent that made it: a sub-agent's own handle for a sub-agent's call, the root handle otherwise. A deny, a needs-approval decision, an unreachable backend or any other error returns a deny decision, so the tool does not run. Only argument names and value types are sent for authorization, never argument values.
  • Sub-agent launches (the Task / Agent tool) perform the governed spawn in the same PreToolUse gate, before the tool runs. The child gets its own credential with a scope that the server narrows to a subset of the parent's. When the spawn is refused, the sub-agent type is not a registered agent, or anything else goes wrong, the tool call is denied: the sub-agent never starts and never gets a model turn.
  • A sub-agent that starts without a governed spawn, or a tool call from an agent the plugin cannot identify while a sub-agent is running, is denied.
  • A starting sub-agent binds to its governed spawn by tool-use id when the SDK provides one, otherwise by sub-agent type. The SDK's SubagentStart input carries no tool-use id, so a second launch of a type that is still starting is denied (the two could not be told apart), including when both launches are gated at the same moment: the first one reserves its slot before the gate does any work. A launch that never starts (a later hook or a permission prompt refused it) is closed on PostToolUse / PostToolUseFailure, at Stop, or after 120 seconds.
  • Each PreToolUse decision has a 45-second deadline, inside the 60-second timeout the plugin sets on its hook matchers; a decision that is not made in time is a deny.
  • Run start fails closed. start_run raises AgentNotRegistered for an unknown agent and GovernanceUnavailable when the backend does not open the session. It also refuses the run, and closes the session it opened, when the backend issues no constraint manifest, unless the operator explicitly set WATCHLIGHT_PLAN_GOVERNANCE_MODE=degrade.
  • Egress. When a wl-proxy URL is configured (connect_proxy_url= or WATCHLIGHT_PROXY_URL), start_run installs a local CONNECT proxy and sets HTTPS_PROXY / HTTP_PROXY for this process, so Python HTTP clients that honour those variables go through wl-proxy. If the backend issued no proxy token, or the proxy cannot be installed, start_run raises GovernanceUnavailable instead of running with direct egress. Clients that ignore HTTPS_PROXY are not covered.

What it does not do: model turns themselves are not authorized (only the tools they call), and plan validation (handle.submit_plan) runs only when you call it. Your own hooks are kept, but they run alongside Watchlight's: a deny from any hook stops the call, so they cannot turn a Watchlight deny into an allow.

The policy decisions run on Watchlight's compiled engine, either in-process for local development or against the governed control plane in production.

Quickstart

For local development, the zero-infrastructure Developer Edition runs the compiled engine in-process (requires the watchlight-engine package):

pip install watchlight-claude-agent "watchlight-engine>=0.2.4,<0.3"
from claude_agent_sdk import ClaudeAgentOptions, query
from watchlight_claude_agent import WatchlightClaudeAgentSDKPlugin
from watchlight_core import InProcessClient

# A Cedar policy: an agent may execute tools. Anything not permitted is
# denied.
# The principal is the agent's id, Agent::"<agent uuid>", never its slug, so
# `principal is Agent` is the rule that matches on every backend.
POLICIES = [
    {"name": "tools",
     "code": 'permit(principal is Agent, action == Action::"execute", resource);'},
]

plugin = WatchlightClaudeAgentSDKPlugin(governance=InProcessClient(POLICIES))

async def run_agent(question: str):
    async with await plugin.start_run("research-agent") as handle:
        # Every tool call and sub-agent launch now goes through Watchlight.
        options = plugin.governed_options(handle, ClaudeAgentOptions())
        async for message in query(prompt=question, options=options):
            print(message)

Each tool call is authorized as action execute on a resource named after the tool (for example Read, Bash, mcp__server__tool).

Sub-agents must be registered Watchlight agents (the subagent_type of the Task call is resolved to a registered agent). Their requested scope comes from default_subagent_scope= (or WATCHLIGHT_DEFAULT_SUBAGENT_SCOPE); when that is empty the sub-agent starts with no tools and its first tool call is denied.

Attributing runs to an AI application

Every governed run can be attributed to the AI application the agent belongs to. Pass application_id="<application UUID>" to WatchlightClaudeAgentSDKPlugin(...), or per run to start_run(...), or set WATCHLIGHT_APPLICATION_ID in the environment — an explicit argument wins over the env var. The id is sent on session create and bound to the run credential and to every sub-agent the run spawns; wl-apdp refuses the session if the agent is not a member of that application. An agent in exactly one application needs nothing here. The id is explicit configuration, never inferred from prompts or names, and it is an Enterprise feature: the in-process Developer Edition engine refuses it.

Two backends, same code

Backend Runs
Developer Edition InProcessClient The compiled engine, in-process — no server, no network
Enterprise ApdpClient The governed control plane — signed lineage, drift detection, fleet-wide governance

Moving from local to production is a one-line change:

import os

from watchlight_core import ApdpClient

# Read the API key from the environment or your secret manager; never
# write it into source code.
plugin = WatchlightClaudeAgentSDKPlugin(
    governance=ApdpClient(
        "https://apdp.your-company.example",
        api_key=os.environ["WATCHLIGHT_API_KEY"],
    )
)

License

Apache-2.0

Metadata

Release files for watchlight-claude-agent 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for watchlight-claude-agent 0.3.1
File Size Uploaded Provenance Actions
watchlight_claude_agent-0.3.1.tar.gz 58.1 kB With provenance Details for watchlight_claude_agent-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for watchlight-claude-agent 0.3.1
File Interpreter ABI Platform Actions
watchlight_claude_agent-0.3.1-py3-none-any.whl Python 3 none any Details for watchlight_claude_agent-0.3.1-py3-none-any.whl

Total release size: 94.6 kB

Release files / watchlight_claude_agent-0.3.1.tar.gz

Download URL watchlight_claude_agent-0.3.1.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6cc91daea236cdf0f867574e3332c2c64b19a27d1305e3d0fbb59f01d7c67af6
BLAKE2b-256 checksum
How to use checksums
8c14d9fc3c0a1bf711f62324f18ee1582ce4f80d87bedc84ec8b6c38a4e68dd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / watchlight_claude_agent-0.3.1-py3-none-any.whl

Download URL watchlight_claude_agent-0.3.1-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1da1f4a0c8c7923d4d0428feaa15432f138a2344ae6ad8dfce2e02bfba4afcf3
BLAKE2b-256 checksum
How to use checksums
b81f1c6951a85c9aae4fe25312284ca2dc06d85df3dddb9bb55323c4c533dac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for watchlight-claude-agent 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for watchlight_claude_agent-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page