brutor-runtime-hooks 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. brutor_runtime_hooks-0.2.0/.gitignore +2 -0
  2. brutor_runtime_hooks-0.2.0/CHANGELOG.md +32 -0
  3. brutor_runtime_hooks-0.2.0/LICENSE +52 -0
  4. brutor_runtime_hooks-0.2.0/NOTICE +23 -0
  5. brutor_runtime_hooks-0.2.0/PKG-INFO +172 -0
  6. brutor_runtime_hooks-0.2.0/README.md +132 -0
  7. brutor_runtime_hooks-0.2.0/pyproject.toml +116 -0
  8. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/__init__.py +46 -0
  9. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/_delegation.py +92 -0
  10. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/_env.py +39 -0
  11. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/_http.py +174 -0
  12. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/_jcs.py +123 -0
  13. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/_verdict.py +148 -0
  14. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/adapters/__init__.py +16 -0
  15. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/adapters/agent_framework.py +118 -0
  16. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/adapters/claude_agent_sdk.py +352 -0
  17. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/adapters/langgraph.py +623 -0
  18. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/adapters/openai_agents.py +450 -0
  19. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/bundle.py +294 -0
  20. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/errors.py +92 -0
  21. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/interceptor.py +495 -0
  22. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/minimise.py +105 -0
  23. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/py.typed +0 -0
  24. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/resolver.py +175 -0
  25. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/session.py +566 -0
  26. brutor_runtime_hooks-0.2.0/src/brutor/runtime_hooks/transform.py +184 -0
@@ -0,0 +1,2 @@
1
+ .coverage
2
+ dist/
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - Transform verdicts: every `HookSession` step returns a `HookOutcome` (`verdict`, `proceeds`,
6
+ `target`, `transformed`) in place of the verdict, and applies a `transform` to the point's target
7
+ with the Agent Hooks path grammar (`brutor.runtime_hooks.transform`); a transform that does not
8
+ apply is the deny `host_error:transform_invalid` (`host_error:transform_target_forbidden` outside
9
+ `$target` and at `agent_startup`), one that leaves the context invalid `host_error:context_invalid`.
10
+ Each adapter's `TRANSFORMS` says where it applies a transform and where it fails closed.
11
+ - `record_sink` no longer receives a delegate's delegation.
12
+ - Adapters: the OpenAI Agents SDK (`openai-agents` extra; `BrutorRunner`) and LangGraph
13
+ (`langgraph` extra; `brutor_tool_node`, `governed_invoke`, `GovernedThread`, `BrutorState`).
14
+ Agents with tools an adapter cannot intercept are refused when they are wrapped
15
+ (`UncoveredTools`) unless the tools are named in `allow_uncovered`.
16
+ - A delegate joins its caller's run: `HookSession(..., delegation=...)`,
17
+ `delegation_from_headers(headers)`, `HookSession.outbound_headers()`, `HookSession.joined`.
18
+ - `HookSession.snapshot()` and `HookSession.restore()`: a session continued in another process.
19
+ - `BrutorApprovalResolver.check()`: one look at a hold, for hosts that resume later.
20
+ - The local bundle cache (`BrutorInterceptor(bundle=True)`, `bundle` extra): the agent's export
21
+ evaluated in process at `pre_tool_call`; only a definite local deny is final, and the context
22
+ still reaches the gateway in the background (`extensions.brutor.local`).
23
+ `ACS_MANIFEST_VERSION` names the pinned manifest contract.
24
+
25
+ ## 0.1.0
26
+
27
+ - `BrutorInterceptor`: an Agent Hooks 0.1 interceptor backed by the gateway's Decision API, with
28
+ run handles per session, data minimisation from the gateway's profile, and fail-closed errors.
29
+ - `BrutorApprovalResolver`: holds resolved through the gateway's approval queue.
30
+ - `HookSession`: Agent Hooks contexts and sequencing for code with no Agent Hooks host.
31
+ - Adapters: Microsoft Agent Framework (`agent-framework` extra) and the Claude Agent SDK for Python
32
+ (`claude-agent-sdk` extra).
@@ -0,0 +1,52 @@
1
+ Brutor Enterprise SDK Licence, version 1.0 (1 December 2026)
2
+ Copyright 2026 Brutor AI Ltd. All rights reserved.
3
+ SPDX-License-Identifier: LicenseRef-Brutor-Enterprise-SDK
4
+
5
+ This licence covers the Brutor Agent Control Enterprise SDKs: brutor-runtime-hooks (PyPI),
6
+ @brutor-ai/runtime-hooks (npm), and Brutor.RuntimeHooks, Brutor.RuntimeHooks.AgentFramework and
7
+ Brutor.RuntimeHooks.Bundle (NuGet), in every version published with this file (the "SDK").
8
+ The licensor is Brutor AI Ltd, a company registered in England and Wales ("Brutor AI").
9
+ "You" means the person or organisation that installs or uses the SDK.
10
+
11
+ The SDK is a client of the Brutor Agent Control Enterprise Edition gateway. An "Enterprise
12
+ licence" is a licence key issued by Brutor AI for the Enterprise Edition (BRUTOR_LICENSE_KEY),
13
+ either a trial licence or an Enterprise licence, that has not expired.
14
+
15
+ 1. What you may do without a subscription. You may install the SDK, read its source code, and
16
+ run it to develop and evaluate your own software against any Brutor Agent Control gateway,
17
+ including an Enterprise Edition trial.
18
+ You may change the SDK for your own internal use, for example to debug it.
19
+ 2. Production use. Using the SDK with real users, data or workloads requires that every gateway
20
+ it talks to runs under a valid Enterprise licence. A trial licence counts while it is valid.
21
+ 3. Redistribution. You may distribute the SDK only unmodified and only as a dependency of your
22
+ own application: declared in its package manifest, or inside its container image or installer,
23
+ with this file and the NOTICE file kept.
24
+ You may not sell, sublicense or publish the SDK as a package of its own, or distribute a
25
+ modified copy.
26
+ 4. Restrictions. You may not remove or change a licence or copyright notice in the SDK, or use
27
+ the SDK to get around a licence check, feature flag or limit of the Enterprise Edition.
28
+ 5. Ownership. Brutor AI and its licensors keep every right this licence does not expressly
29
+ grant. "Brutor" and the Brutor logos are trademarks of Brutor AI Ltd; this licence grants no
30
+ right to use them.
31
+ 6. Third-party components. Parts of the SDK come from other authors and are listed in NOTICE.
32
+ Each stays under its own licence, which governs that part instead of this one. Packages the
33
+ SDK depends on, or names as optional, are installed by you from their own registries under
34
+ their own terms; Brutor AI does not distribute them.
35
+ 7. No warranty. THE SDK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
36
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37
+ PURPOSE AND NONINFRINGEMENT.
38
+ 8. Limitation of liability. To the fullest extent the law allows, Brutor AI is not liable for
39
+ any indirect, incidental, special or consequential loss, or for loss of profits, data, use or
40
+ goodwill, arising from the SDK or its use, whether in contract, tort or otherwise. Brutor AI's
41
+ total liability under this licence is limited to one hundred pounds sterling (GBP 100).
42
+ Nothing in this licence limits liability for death or personal injury caused by negligence,
43
+ for fraud or fraudulent misrepresentation, or for anything else the law does not allow to be
44
+ limited.
45
+ 9. Termination. This licence ends automatically if you break it. You must then stop using and
46
+ distributing the SDK. Sections 5 to 11 survive.
47
+ 10. Your agreement with Brutor AI. If you have a signed agreement with Brutor AI for the
48
+ Enterprise Edition, that agreement prevails over this licence where they conflict.
49
+ 11. Governing law. This licence is governed by the laws of England and Wales, and the courts of
50
+ England and Wales have exclusive jurisdiction.
51
+
52
+ Questions about this licence: legal@brutor.ai. An Enterprise licence or a trial: hello@brutor.ai.
@@ -0,0 +1,23 @@
1
+ Brutor Agent Control Enterprise SDK: brutor-runtime-hooks
2
+ Copyright 2026 Brutor AI Ltd. All rights reserved.
3
+ Licensed under the Brutor Enterprise SDK Licence (see LICENSE).
4
+
5
+ Software this package works with but does not distribute
6
+
7
+ You install these yourself from PyPI, as dependencies or optional extras.
8
+ Each one is under its own licence:
9
+
10
+ brutor-agent-auth Brutor AI Ltd, Apache License 2.0
11
+ httpx BSD 3-Clause License
12
+ agent-hooks-sdk 0.1.0b3 Microsoft Corporation, MIT License
13
+ (extra agent-framework)
14
+ agent-framework-core 1.26.0 Microsoft Corporation, MIT License
15
+ (extra agent-framework)
16
+ agent-control-spec 0.4.0b2 Microsoft Corporation, MIT License (extra bundle)
17
+ claude-agent-sdk >=0.2.185,<0.3
18
+ MIT License per its package metadata; its
19
+ platform wheels also contain the Claude Code
20
+ program, which is under Anthropic's terms
21
+ (extra claude-agent-sdk)
22
+ openai-agents >=0.25,<0.26 MIT License (extra openai-agents)
23
+ langgraph >=1.2,<1.3 MIT License (extra langgraph)
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.5
2
+ Name: brutor-runtime-hooks
3
+ Version: 0.2.0
4
+ Summary: Agent Hooks interceptor for Brutor Agent Control: governs the tool calls, prompts and answers an agent handles in its own process
5
+ Project-URL: Documentation, https://docs.brutor.ai/runtime-hooks/
6
+ Author: Brutor AI Ltd.
7
+ License-Expression: LicenseRef-Brutor-Enterprise-SDK
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Keywords: agent control specification,agent framework,agent hooks,agents,approvals,claude agent sdk,governance,langgraph,openai agents,policy
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Framework :: AsyncIO
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Classifier: Topic :: Security
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: brutor-agent-auth<0.3,>=0.2
27
+ Requires-Dist: httpx<1,>=0.27
28
+ Provides-Extra: agent-framework
29
+ Requires-Dist: agent-framework-core==1.26.0; extra == 'agent-framework'
30
+ Requires-Dist: agent-hooks-sdk==0.1.0b3; extra == 'agent-framework'
31
+ Provides-Extra: bundle
32
+ Requires-Dist: agent-control-spec==0.4.0b2; extra == 'bundle'
33
+ Provides-Extra: claude-agent-sdk
34
+ Requires-Dist: claude-agent-sdk<0.3,>=0.2.185; extra == 'claude-agent-sdk'
35
+ Provides-Extra: langgraph
36
+ Requires-Dist: langgraph<1.3,>=1.2; extra == 'langgraph'
37
+ Provides-Extra: openai-agents
38
+ Requires-Dist: openai-agents<0.26,>=0.25; extra == 'openai-agents'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Brutor Agent Control — Runtime Hooks for Python (Enterprise)
42
+
43
+ Governed runtime hooks for agents that run outside the gateway.
44
+
45
+ **Edition:** Enterprise
46
+
47
+ ## What it is
48
+
49
+ Runtime hooks for Brutor Agent Control. Your agent calls tools, reads prompts
50
+ and writes answers in its own process, out of the gateway's sight. With this package each of those
51
+ steps is decided by the gateway, under the same grants, argument policies, data scope, run policies,
52
+ guardrails and approvals as its own traffic. The decision travels as an
53
+ [Agent Hooks 0.1](https://github.com/responsibleai/agent-hooks) interceptor call.
54
+
55
+ The package is a client of the Enterprise Edition gateway and is licensed under the Brutor
56
+ Enterprise SDK Licence (see License below). You can install it and evaluate it against any gateway,
57
+ including an Enterprise trial. Production use needs an Enterprise licence on the gateway.
58
+
59
+ Documentation: https://docs.brutor.ai/runtime-hooks/
60
+
61
+ ## Requirements
62
+
63
+ Python 3.11 or later (CI runs 3.11 to 3.15). Dependencies: `brutor-agent-auth` (>=0.2,<0.3) and `httpx`.
64
+
65
+ ## Install
66
+
67
+ ```bash
68
+ pip install brutor-runtime-hooks # the interceptor and HookSession
69
+ pip install 'brutor-runtime-hooks[agent-framework]' # Microsoft Agent Framework
70
+ pip install 'brutor-runtime-hooks[claude-agent-sdk]' # Claude Agent SDK (Python)
71
+ pip install 'brutor-runtime-hooks[openai-agents]' # OpenAI Agents SDK
72
+ pip install 'brutor-runtime-hooks[langgraph]' # LangGraph
73
+ pip install 'brutor-runtime-hooks[bundle]' # the local bundle cache
74
+ ```
75
+
76
+ The agent authenticates with `brutor-agent-auth` (a dependency): a short-lived workload token from
77
+ the platform it runs on, so no secret is stored in the agent.
78
+
79
+ ## Quick start
80
+
81
+ ```python
82
+ from brutor.runtime_hooks import BrutorApprovalResolver, BrutorInterceptor, HookSession
83
+
84
+ interceptor = BrutorInterceptor() # BRUTOR_GATEWAY_URL; credential from brutor.auth.WorkloadAuth()
85
+ resolver = BrutorApprovalResolver(interceptor)
86
+
87
+ async with HookSession(
88
+ interceptor, agent_id="loan-screening", framework="langgraph", tools=["write_file"], resolver=resolver
89
+ ) as hooks:
90
+ pre = await hooks.pre_tool_call("call_1", "write_file", {"path": "/letters/APP-1042.md"})
91
+ if pre.proceeds: # pre.target: the arguments as allowed, or as the gateway transformed them
92
+ result = write_file(**pre.target)
93
+ await hooks.post_tool_call("call_1", "write_file", pre.target, result)
94
+ ```
95
+
96
+ Each step returns a `HookOutcome` (`verdict`, `proceeds`, `target`, `transformed`): act only when
97
+ `proceeds`, and always with `target`, which is the redacted or rewritten value after a `transform`.
98
+
99
+ Turn runtime hooks on for the AI System first (Admin Console, the AI System's Runtime hooks tab):
100
+ `observe` shows what `enforce` would decide and blocks nothing; `enforce` applies the decisions.
101
+
102
+ - **Microsoft Agent Framework**: `middleware=[brutor_middleware(interceptor)]` from
103
+ `brutor.runtime_hooks.adapters.agent_framework`. The framework is the Agent Hooks host for all
104
+ eight interception points.
105
+ - **Claude Agent SDK**: `async with BrutorClaudeSession(interceptor, options, agent_id=...) as client:`
106
+ from `brutor.runtime_hooks.adapters.claude_agent_sdk`. It covers prompts, tool calls and answers;
107
+ model calls are governed by pointing the SDK at the gateway.
108
+ - **OpenAI Agents SDK**: `await BrutorRunner(interceptor).run(agent, prompt)` from
109
+ `brutor.runtime_hooks.adapters.openai_agents`, in place of `Runner.run`. Brutor's guardrails are
110
+ added to copies of your agents; tools the SDK's guardrails cannot see (hosted tools, built-in
111
+ execution tools, agents used as tools) are refused unless you name them in `allow_uncovered`.
112
+ - **LangGraph**: `brutor_tool_node(tools, interceptor)` in place of `ToolNode(tools)`, and
113
+ `await governed_invoke(graph, inputs, config, interceptor, agent_id=...)` to run the graph. A hold
114
+ interrupts the graph; resuming it re-evaluates the same decision with the approval. Add
115
+ `BrutorState` to a checkpointed graph's state so the session survives checkpoints.
116
+
117
+ ## The local bundle cache
118
+
119
+ `BrutorInterceptor(bundle=True)` evaluates Brutor's stateless tool rules in the agent's process
120
+ (the agent's export, fetched after `agent_startup`). A definite local deny is answered at once and
121
+ still recorded by the gateway; everything else, a local allow included, is decided by the gateway.
122
+ It is off by default.
123
+
124
+ ## An agent reached as a delegate
125
+
126
+ An agent that another agent calls through the gateway receives the delegation in
127
+ `x-brutor-delegation-*` headers. Start its session with them, and send the run handle (never the
128
+ delegation headers) on its own gateway calls:
129
+
130
+ ```python
131
+ from brutor.runtime_hooks import HookSession, delegation_from_headers
132
+
133
+ async with HookSession(
134
+ interceptor, agent_id="fraud-screener", framework="custom", delegation=delegation_from_headers(request.headers)
135
+ ) as hooks:
136
+ headers = hooks.outbound_headers({"Content-Type": "application/json"}) # X-Brutor-Run-Id
137
+ ```
138
+
139
+ The adapters take the same `delegation=` argument.
140
+
141
+ ## Failing closed
142
+
143
+ When the gateway gives no usable decision (an error, a timeout, an answer that is not a valid
144
+ verdict), `BrutorInterceptor` raises `DecisionUnavailable` and the host denies the step.
145
+ `HookSession` and the adapters do this for you. The SDK never logs a credential, a run handle, an
146
+ approval token or the content of a step. Content that the gateway's checks do not read is replaced
147
+ by its hash before it is sent.
148
+
149
+ ## Development
150
+
151
+ From `sdk/enterprise/python/brutor-runtime-hooks` in the Brutor Agent Control repository (tools
152
+ pinned in `requirements-dev.txt`). The `sdk-enterprise.yml` workflow runs these gates:
153
+
154
+ ```bash
155
+ python -m pip install -r requirements-dev.txt -e ../../../python/brutor-agent-auth -e '.[agent-framework,claude-agent-sdk,openai-agents,langgraph,bundle]'
156
+ ruff check . && ruff format --check .
157
+ mypy --strict src
158
+ python scripts/env_registry.py --check
159
+ python -m pytest # fails below 95% coverage
160
+ ```
161
+
162
+ ## Documentation
163
+
164
+ https://docs.brutor.ai/runtime-hooks/
165
+
166
+ ## Security
167
+
168
+ See SECURITY.md at the repository root.
169
+
170
+ ## License
171
+
172
+ Proprietary: the Brutor Enterprise SDK Licence (see `LICENSE`). It is not an open-source license.
@@ -0,0 +1,132 @@
1
+ # Brutor Agent Control — Runtime Hooks for Python (Enterprise)
2
+
3
+ Governed runtime hooks for agents that run outside the gateway.
4
+
5
+ **Edition:** Enterprise
6
+
7
+ ## What it is
8
+
9
+ Runtime hooks for Brutor Agent Control. Your agent calls tools, reads prompts
10
+ and writes answers in its own process, out of the gateway's sight. With this package each of those
11
+ steps is decided by the gateway, under the same grants, argument policies, data scope, run policies,
12
+ guardrails and approvals as its own traffic. The decision travels as an
13
+ [Agent Hooks 0.1](https://github.com/responsibleai/agent-hooks) interceptor call.
14
+
15
+ The package is a client of the Enterprise Edition gateway and is licensed under the Brutor
16
+ Enterprise SDK Licence (see License below). You can install it and evaluate it against any gateway,
17
+ including an Enterprise trial. Production use needs an Enterprise licence on the gateway.
18
+
19
+ Documentation: https://docs.brutor.ai/runtime-hooks/
20
+
21
+ ## Requirements
22
+
23
+ Python 3.11 or later (CI runs 3.11 to 3.15). Dependencies: `brutor-agent-auth` (>=0.2,<0.3) and `httpx`.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install brutor-runtime-hooks # the interceptor and HookSession
29
+ pip install 'brutor-runtime-hooks[agent-framework]' # Microsoft Agent Framework
30
+ pip install 'brutor-runtime-hooks[claude-agent-sdk]' # Claude Agent SDK (Python)
31
+ pip install 'brutor-runtime-hooks[openai-agents]' # OpenAI Agents SDK
32
+ pip install 'brutor-runtime-hooks[langgraph]' # LangGraph
33
+ pip install 'brutor-runtime-hooks[bundle]' # the local bundle cache
34
+ ```
35
+
36
+ The agent authenticates with `brutor-agent-auth` (a dependency): a short-lived workload token from
37
+ the platform it runs on, so no secret is stored in the agent.
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ from brutor.runtime_hooks import BrutorApprovalResolver, BrutorInterceptor, HookSession
43
+
44
+ interceptor = BrutorInterceptor() # BRUTOR_GATEWAY_URL; credential from brutor.auth.WorkloadAuth()
45
+ resolver = BrutorApprovalResolver(interceptor)
46
+
47
+ async with HookSession(
48
+ interceptor, agent_id="loan-screening", framework="langgraph", tools=["write_file"], resolver=resolver
49
+ ) as hooks:
50
+ pre = await hooks.pre_tool_call("call_1", "write_file", {"path": "/letters/APP-1042.md"})
51
+ if pre.proceeds: # pre.target: the arguments as allowed, or as the gateway transformed them
52
+ result = write_file(**pre.target)
53
+ await hooks.post_tool_call("call_1", "write_file", pre.target, result)
54
+ ```
55
+
56
+ Each step returns a `HookOutcome` (`verdict`, `proceeds`, `target`, `transformed`): act only when
57
+ `proceeds`, and always with `target`, which is the redacted or rewritten value after a `transform`.
58
+
59
+ Turn runtime hooks on for the AI System first (Admin Console, the AI System's Runtime hooks tab):
60
+ `observe` shows what `enforce` would decide and blocks nothing; `enforce` applies the decisions.
61
+
62
+ - **Microsoft Agent Framework**: `middleware=[brutor_middleware(interceptor)]` from
63
+ `brutor.runtime_hooks.adapters.agent_framework`. The framework is the Agent Hooks host for all
64
+ eight interception points.
65
+ - **Claude Agent SDK**: `async with BrutorClaudeSession(interceptor, options, agent_id=...) as client:`
66
+ from `brutor.runtime_hooks.adapters.claude_agent_sdk`. It covers prompts, tool calls and answers;
67
+ model calls are governed by pointing the SDK at the gateway.
68
+ - **OpenAI Agents SDK**: `await BrutorRunner(interceptor).run(agent, prompt)` from
69
+ `brutor.runtime_hooks.adapters.openai_agents`, in place of `Runner.run`. Brutor's guardrails are
70
+ added to copies of your agents; tools the SDK's guardrails cannot see (hosted tools, built-in
71
+ execution tools, agents used as tools) are refused unless you name them in `allow_uncovered`.
72
+ - **LangGraph**: `brutor_tool_node(tools, interceptor)` in place of `ToolNode(tools)`, and
73
+ `await governed_invoke(graph, inputs, config, interceptor, agent_id=...)` to run the graph. A hold
74
+ interrupts the graph; resuming it re-evaluates the same decision with the approval. Add
75
+ `BrutorState` to a checkpointed graph's state so the session survives checkpoints.
76
+
77
+ ## The local bundle cache
78
+
79
+ `BrutorInterceptor(bundle=True)` evaluates Brutor's stateless tool rules in the agent's process
80
+ (the agent's export, fetched after `agent_startup`). A definite local deny is answered at once and
81
+ still recorded by the gateway; everything else, a local allow included, is decided by the gateway.
82
+ It is off by default.
83
+
84
+ ## An agent reached as a delegate
85
+
86
+ An agent that another agent calls through the gateway receives the delegation in
87
+ `x-brutor-delegation-*` headers. Start its session with them, and send the run handle (never the
88
+ delegation headers) on its own gateway calls:
89
+
90
+ ```python
91
+ from brutor.runtime_hooks import HookSession, delegation_from_headers
92
+
93
+ async with HookSession(
94
+ interceptor, agent_id="fraud-screener", framework="custom", delegation=delegation_from_headers(request.headers)
95
+ ) as hooks:
96
+ headers = hooks.outbound_headers({"Content-Type": "application/json"}) # X-Brutor-Run-Id
97
+ ```
98
+
99
+ The adapters take the same `delegation=` argument.
100
+
101
+ ## Failing closed
102
+
103
+ When the gateway gives no usable decision (an error, a timeout, an answer that is not a valid
104
+ verdict), `BrutorInterceptor` raises `DecisionUnavailable` and the host denies the step.
105
+ `HookSession` and the adapters do this for you. The SDK never logs a credential, a run handle, an
106
+ approval token or the content of a step. Content that the gateway's checks do not read is replaced
107
+ by its hash before it is sent.
108
+
109
+ ## Development
110
+
111
+ From `sdk/enterprise/python/brutor-runtime-hooks` in the Brutor Agent Control repository (tools
112
+ pinned in `requirements-dev.txt`). The `sdk-enterprise.yml` workflow runs these gates:
113
+
114
+ ```bash
115
+ python -m pip install -r requirements-dev.txt -e ../../../python/brutor-agent-auth -e '.[agent-framework,claude-agent-sdk,openai-agents,langgraph,bundle]'
116
+ ruff check . && ruff format --check .
117
+ mypy --strict src
118
+ python scripts/env_registry.py --check
119
+ python -m pytest # fails below 95% coverage
120
+ ```
121
+
122
+ ## Documentation
123
+
124
+ https://docs.brutor.ai/runtime-hooks/
125
+
126
+ ## Security
127
+
128
+ See SECURITY.md at the repository root.
129
+
130
+ ## License
131
+
132
+ Proprietary: the Brutor Enterprise SDK Licence (see `LICENSE`). It is not an open-source license.
@@ -0,0 +1,116 @@
1
+ # Copyright 2026 Brutor AI Ltd. All rights reserved.
2
+ # SPDX-License-Identifier: LicenseRef-Brutor-Enterprise-SDK
3
+
4
+ [build-system]
5
+ # Pinned: the release build is byte-for-byte reproducible (build-requirements.in).
6
+ requires = ["hatchling==1.33.0"]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "brutor-runtime-hooks"
11
+ version = "0.2.0"
12
+ description = "Agent Hooks interceptor for Brutor Agent Control: governs the tool calls, prompts and answers an agent handles in its own process"
13
+ license = "LicenseRef-Brutor-Enterprise-SDK"
14
+ license-files = ["LICENSE", "NOTICE"]
15
+ readme = "README.md"
16
+ requires-python = ">=3.11"
17
+ authors = [{ name = "Brutor AI Ltd." }]
18
+ keywords = ["agent hooks", "agents", "governance", "policy", "approvals", "claude agent sdk", "agent framework", "openai agents", "langgraph", "agent control specification"]
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "License :: Other/Proprietary License",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ "Programming Language :: Python :: 3.15",
31
+ "Framework :: AsyncIO",
32
+ "Topic :: Security",
33
+ "Typing :: Typed",
34
+ ]
35
+ dependencies = ["brutor-agent-auth>=0.2,<0.3", "httpx>=0.27,<1"]
36
+
37
+ [project.optional-dependencies]
38
+ # Microsoft Agent Framework: its Agent Hooks host (experimental upstream, so pinned exactly).
39
+ agent-framework = ["agent-framework-core==1.26.0", "agent-hooks-sdk==0.1.0b3"]
40
+ # The Claude Agent SDK (Python).
41
+ claude-agent-sdk = ["claude-agent-sdk>=0.2.185,<0.3"]
42
+ # The OpenAI Agents SDK (Python).
43
+ openai-agents = ["openai-agents>=0.25,<0.26"]
44
+ # LangGraph (Python).
45
+ langgraph = ["langgraph>=1.2,<1.3"]
46
+ # The local bundle cache: the Agent Control Specification runtime (pre-release upstream, so pinned exactly).
47
+ bundle = ["agent-control-spec==0.4.0b2"]
48
+
49
+ [project.urls]
50
+ Documentation = "https://docs.brutor.ai/runtime-hooks/"
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ # `brutor` is a namespace package shared with brutor-agent-auth: there is no brutor/__init__.py.
54
+ packages = ["src/brutor"]
55
+
56
+ [tool.hatch.build.targets.sdist]
57
+ include = ["src/brutor", "README.md", "CHANGELOG.md", "LICENSE", "NOTICE", "pyproject.toml"]
58
+ # The tests, their fixtures and the vendored upstream files are not published.
59
+ exclude = ["/tests", "/scripts"]
60
+
61
+ [tool.ruff]
62
+ line-length = 120
63
+ target-version = "py311"
64
+ src = ["src", "tests"]
65
+ extend-exclude = ["tests/fixtures"]
66
+
67
+ [tool.ruff.lint]
68
+ select = ["E", "W", "F", "I", "B", "UP", "S", "SIM", "RUF", "PT", "C4", "PL", "T20", "ASYNC"]
69
+ ignore = [
70
+ "PLR0913", # the interceptor and the session take their documented keyword arguments
71
+ "PLR0917", # BrutorInterceptor's documented signature takes its settings positionally too
72
+ "PLR0911", # the verdict and envelope checks, and the host's fail-closed mapping, return per rule
73
+ "PLR0912", # ... and branch per rule: one place reads as the schema reads
74
+ "PLR2004", # status codes and seconds read better as numbers
75
+ ]
76
+
77
+ [tool.ruff.lint.isort]
78
+ known-first-party = ["brutor"]
79
+ known-local-folder = ["conftest", "contexts", "fake_api", "fake_claude", "fixture", "guards", "bridge", "report", "sdk_cases", "openai_host", "langgraph_host", "claude_host", "maf_host"]
80
+
81
+ [tool.ruff.lint.per-file-ignores]
82
+ "tests/**" = ["ASYNC240", "S101", "S603", "S105", "S106", "S107", "S310", "PLR0917", "PLC0415", "PLR0915", "RUF012", "PT012", "PLW2901"]
83
+ "scripts/**" = ["S101", "PT018", "S603", "T201", "S607"]
84
+
85
+ [tool.mypy]
86
+ strict = true
87
+ python_version = "3.11"
88
+ mypy_path = "src"
89
+ explicit_package_bases = true
90
+ namespace_packages = true
91
+
92
+ [[tool.mypy.overrides]]
93
+ # The optional extras are imported only inside their adapters, and type-checked when installed.
94
+ module = [
95
+ "agent_framework", "agent_framework.*", "agent_hooks", "agent_hooks.*", "claude_agent_sdk", "claude_agent_sdk.*",
96
+ "agents", "agents.*", "langgraph", "langgraph.*", "langchain_core", "langchain_core.*",
97
+ "agent_control_spec", "agent_control_spec.*",
98
+ ]
99
+ ignore_missing_imports = true
100
+
101
+ [tool.pytest.ini_options]
102
+ testpaths = ["tests"]
103
+ pythonpath = ["tests"]
104
+ asyncio_mode = "auto"
105
+ asyncio_default_fixture_loop_scope = "function"
106
+ # langsmith (installed with the langgraph extra) registers a pytest plugin that fails to load
107
+ # under Python 3.14's deprecation of asyncio.iscoroutinefunction: it is not used, so it is not
108
+ # loaded, and that one upstream warning is ignored where langsmith raises it.
109
+ addopts = "-ra --strict-markers -p no:langsmith_plugin --cov=brutor.runtime_hooks --cov-report=term-missing --cov-fail-under=95"
110
+ filterwarnings = [
111
+ "error",
112
+ "ignore:'asyncio.iscoroutinefunction' is deprecated:DeprecationWarning:langsmith._internal._beta_decorator",
113
+ ]
114
+
115
+ [tool.coverage.run]
116
+ branch = true
@@ -0,0 +1,46 @@
1
+ # Copyright 2026 Brutor AI Ltd. All rights reserved.
2
+ # SPDX-License-Identifier: LicenseRef-Brutor-Enterprise-SDK
3
+
4
+ """Runtime hooks for Brutor Agent Control: govern what an agent does inside its own process.
5
+
6
+ from brutor.runtime_hooks import BrutorInterceptor, BrutorApprovalResolver, HookSession
7
+
8
+ interceptor = BrutorInterceptor() # BRUTOR_GATEWAY_URL; a brutor.auth.WorkloadAuth credential
9
+ resolver = BrutorApprovalResolver(interceptor)
10
+ async with HookSession(interceptor, agent_id="loan-screening", framework="langgraph",
11
+ tools=["write_file"], resolver=resolver) as hooks:
12
+ outcome = await hooks.pre_tool_call(call_id, "write_file", args)
13
+ if outcome.proceeds:
14
+ result = write_file(**outcome.target) # the arguments as allowed, or as transformed
15
+
16
+ ``BrutorInterceptor`` is an Agent Hooks 0.1 interceptor: any Agent Hooks host (Microsoft Agent
17
+ Framework, the adapters in ``brutor.runtime_hooks.adapters``) can call it. Every decision is the
18
+ gateway's (``POST /v1/runtime-hooks/evaluate``), with the same policies as the gateway's own
19
+ traffic. When the gateway gives no usable answer the interceptor raises ``DecisionUnavailable`` and
20
+ the host denies: it fails closed.
21
+ """
22
+
23
+ from brutor.runtime_hooks._delegation import delegation_from_headers
24
+ from brutor.runtime_hooks.bundle import ACS_MANIFEST_VERSION
25
+ from brutor.runtime_hooks.errors import DecisionUnavailable, HookDenied, OutputDenied, UncoveredTools
26
+ from brutor.runtime_hooks.interceptor import SPEC_VERSION, BrutorInterceptor
27
+ from brutor.runtime_hooks.resolver import BrutorApprovalResolver
28
+ from brutor.runtime_hooks.session import HookOutcome, HookSession, context_identity
29
+
30
+ __version__ = "0.2.0"
31
+
32
+ __all__ = [
33
+ "ACS_MANIFEST_VERSION",
34
+ "SPEC_VERSION",
35
+ "BrutorApprovalResolver",
36
+ "BrutorInterceptor",
37
+ "DecisionUnavailable",
38
+ "HookDenied",
39
+ "HookOutcome",
40
+ "HookSession",
41
+ "OutputDenied",
42
+ "UncoveredTools",
43
+ "__version__",
44
+ "context_identity",
45
+ "delegation_from_headers",
46
+ ]