vsl-agt 0.1.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.
vsl_agt-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Semantics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
vsl_agt-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,273 @@
1
+ Metadata-Version: 2.4
2
+ Name: vsl-agt
3
+ Version: 0.1.0
4
+ Summary: VSL gates and the VERBA ledger inside Microsoft's Agent Governance Toolkit: an Agent Hooks interceptor and an AGT ToolCallInterceptor, with recorded actions and computed enforcement.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/supersemantics/VSL-agent-governance-toolkit
7
+ Project-URL: Repository, https://github.com/supersemantics/VSL-agent-governance-toolkit
8
+ Project-URL: Changelog, https://github.com/supersemantics/VSL-agent-governance-toolkit/blob/HEAD/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/supersemantics/VSL-agent-governance-toolkit/issues
10
+ Keywords: governance,ai-safety,guardrails,agent-governance-toolkit,agent-hooks,vsl,verba
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: super-semantics-vsl<0.5,>=0.4
18
+ Requires-Dist: agent-hooks-sdk==0.1.0b3
19
+ Provides-Extra: agt
20
+ Requires-Dist: agent-governance-toolkit-core<6,>=5; python_version >= "3.11" and extra == "agt"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=7; extra == "dev"
23
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # vsl-agt
27
+
28
+ [VSL](https://github.com/supersemantics/VSL-Core) gates and the VERBA ledger inside Microsoft's
29
+ [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit) (AGT).
30
+
31
+ AGT decides, before a tool call runs, whether its policy allows it. vsl-agt adds VSL's gates to that
32
+ same decision, and keeps a hash-chained record that shows, call by call, whether the gates decided
33
+ before the tool ran.
34
+
35
+ **Is:**
36
+ - `VSLInterceptor`: an [Agent Hooks](https://github.com/responsibleai/agent-hooks) interceptor
37
+ (`agent-hooks/0.1`, the interception contract AGT's policy engine is built on). Register it on a
38
+ host's `InterceptionEmitter` at `pre_tool_call` and `post_tool_call`.
39
+ - `VSLToolCallInterceptor`: AGT's own `ToolCallInterceptor` protocol (`agent_os.integrations`), for
40
+ `CompositeInterceptor` chains and the adapters that call interceptors (CrewAI).
41
+ - `AGTAdapter`: vsl-core's `VSLAdapter`, passing `run_conformance_suite` with no failures.
42
+
43
+ **Is not:**
44
+ - A Microsoft project, or Microsoft's AGT repository. This is Super Semantics' VSL adapter for AGT;
45
+ AGT itself is at [microsoft/agent-governance-toolkit](https://github.com/microsoft/agent-governance-toolkit).
46
+ - A replacement for AGT's policy engine, identity, trust scoring or sandboxing. It runs next to them.
47
+ - Complete mediation. Agent Hooks says so itself: a code path the framework never routes through an
48
+ interception point is not seen, so the ledger speaks only for the calls that were.
49
+
50
+ ## How this adapter differs from the other VSL adapters
51
+
52
+ Every other VSL adapter connects VSL to an orchestration framework: a LangGraph node, LangChain or
53
+ Agent Framework middleware, a ROS 2 publisher. vsl-agt connects VSL to another governance layer.
54
+ AGT already sits between the agent and its tools; vsl-agt puts VSL's gates in the same place, so
55
+ both decide on the same call.
56
+
57
+ | | The other VSL adapters | vsl-agt |
58
+ |---|---|---|
59
+ | Plugs into | the framework's own hook | AGT's interception points, next to AGT's own policy |
60
+ | Who decides | VSL's gate alone | AGT's verdict and VSL's together: any deny stops the call |
61
+ | Ledger writes | the gate blocks; your code records the decision and the action (vsl-ros2's `vsl_guard` node records its own) | gate decisions, the fallback for each denial, the Terminal State and the tool's run are recorded for you |
62
+ | Terminal State | the gate raises; your code records it and holds the agent | the interceptor holds the agent, the hold survives a restart, and only a recorded human release ends it |
63
+ | Audit trail | the VSL ledger | the VSL ledger, each entry linked to AGT's record of the same call |
64
+ | A tool run with no check before it | not detected by the adapter | a tracked tool's unchecked run reads `AFTER_ACTION` |
65
+
66
+ ## VSL adapters
67
+
68
+ Each adapter passes vsl-core's conformance suite and builds gates with no assurance claim. vsl-core
69
+ itself: [Python](https://github.com/supersemantics/VSL-Core) (`super-semantics-vsl`),
70
+ [TypeScript](https://github.com/supersemantics/VSL-Corejs) (`@supersemantics/vsl-core`),
71
+ [.NET](https://github.com/supersemantics/VSL-Core.NET) (`SuperSemantics.Vsl`).
72
+
73
+ | Framework | Package | Where the gate runs | What a denial does |
74
+ |---|---|---|---|
75
+ | Microsoft Agent Governance Toolkit | `vsl-agt` (this repo) | AGT's `pre_tool_call` interception point, or its `ToolCallInterceptor` chain | Agent Hooks raises `InterceptionBlocked`; AGT's chain returns `allowed=False` |
76
+ | [LangGraph](https://github.com/supersemantics/VSL-Langgraph) | `vsl-langgraph` | `gated_node`: before the node body | the node is skipped; `route_on_denial` routes the graph |
77
+ | [LangGraph.js](https://github.com/supersemantics/VSL-Langgraphjs) | `@supersemantics/vsl-langgraph` | `gatedNode`: before the node body | the node is skipped; `routeOnDenial` routes the graph |
78
+ | [LangChain](https://github.com/supersemantics/VSL-LangChain) | `vsl-langchain` | `VSLToolMiddleware`, `create_agent`'s `wrap_tool_call` | the tool never runs; the model gets an error `ToolMessage` |
79
+ | [Microsoft Agent Framework (Python)](https://github.com/supersemantics/VSL-Microsoft-agent-framework) | `vsl-maf` | function middleware, before the tool | the run aborts with `VSLGateDenied` |
80
+ | [Microsoft Agent Framework (.NET)](https://github.com/supersemantics/VSL-Microsoft-agent-framework.NET) | `SuperSemantics.Vsl.AgentFramework` | `UseVslGate` / `UseVslGates`, before the tool | the run aborts with `VslGateDeniedException` |
81
+ | [ROS 2](https://github.com/supersemantics/VSL-ROS2) | `vsl-ros2` | before a command is published, a service handled or an action goal accepted | the message isn't sent, or the goal is rejected; `vsl_guard` proxies Nav2 |
82
+
83
+ ## What VSL adds to AGT
84
+
85
+ Each row is a limit AGT documents about itself, and what vsl-agt does about it.
86
+
87
+ | AGT, in its own docs | vsl-agt |
88
+ |---|---|
89
+ | The audit trail "records what the agent attempted", not whether the action ran ([LIMITATIONS](https://github.com/microsoft/agent-governance-toolkit/blob/main/docs/LIMITATIONS.md) §2) | `post_tool_call` records that the tool ran (`write_action`); `ledger.enforcement(decision_id)` computes, from record order, whether every gate decided first |
90
+ | The decision fields are outside the audit entry hash in v1.0 ([AUDIT-COMPLIANCE-1.0](https://github.com/microsoft/agent-governance-toolkit/blob/main/docs/specs/AUDIT-COMPLIANCE-1.0.md) §4.3.1) | every VSL gate decision is a hash-chained ledger entry, decision included |
91
+ | No correlation across a sequence of allowed actions (LIMITATIONS §1) | a gate can be any Invariant, including a vsl-core `Cluster` Invariant over state the agents share; hand-offs between agents are recorded with `write_handover` in the same ledger |
92
+ | A recorded kill is not proof of termination (LIMITATIONS §13) | an Invariant can name a `TerminalState`: every gated call is denied until a named human releases it, recorded as a `HUMAN_AUTHORISED_TRANSITION` |
93
+ | Policy verdicts are allow, deny or transform | a `PreNode` gates on a measured ratio (Gamma) against a threshold, recorded with its value |
94
+
95
+ ## Install
96
+
97
+ ```bash
98
+ pip install vsl-agt # with Agent Hooks
99
+ pip install "vsl-agt[agt]" # also AGT core, for VSLToolCallInterceptor
100
+ ```
101
+
102
+ vsl-agt runs on Python 3.10 or later. AGT core 5.0, and so `VSLToolCallInterceptor`, needs 3.11 or
103
+ later.
104
+
105
+ `agent-hooks-sdk` is a beta (0.1.0b3) and is pinned exactly. vsl-core comes from PyPI as
106
+ `super-semantics-vsl` (0.4.x).
107
+
108
+ ## Agent Hooks: `VSLInterceptor`
109
+
110
+ ```python
111
+ from agent_hooks import AgentContextBuilder, InterceptionBlocked, InterceptionEmitter
112
+ from vsl_core.constructs import Invariant, PreNode, TerminalState
113
+ from vsl_core.ledger import JsonlLedgerStore, VerbaLedger
114
+ from vsl_core.metrics import GammaEstimate
115
+ from vsl_agt import VSLInterceptor, decision_id_of
116
+
117
+ async def within_cap(args):
118
+ return 0 < args["amount"] <= 1000
119
+
120
+ async def budget_headroom(args):
121
+ return GammaEstimate(gamma_hat=budget_left() / args["amount"] if args["amount"] > 0 else 0.0)
122
+
123
+ ledger = VerbaLedger(JsonlLedgerStore("decisions.jsonl", fsync=True))
124
+ vsl = VSLInterceptor(
125
+ {"issue_refund": [
126
+ Invariant(name="refund-cap", description="Refunds of $1000 or less.", rule=within_cap,
127
+ on_violation=TerminalState(name="refund-escalated", description="Refunds stop for review.")),
128
+ PreNode(name="refund-budget", description="Budget left / amount above 1.1.",
129
+ monitor=budget_headroom, gamma_threshold=1.1),
130
+ ]},
131
+ ledger=ledger,
132
+ identity_key="refund-agent",
133
+ )
134
+
135
+ emitter = InterceptionEmitter()
136
+ emitter.register(vsl, name="vsl", at=vsl.points)
137
+ ```
138
+
139
+ A host (an AGT framework adapter, or your own loop) emits `pre_tool_call` before the tool and
140
+ `post_tool_call` after it. A denial raises `InterceptionBlocked` and the tool never runs:
141
+
142
+ ```python
143
+ ctx = AgentContextBuilder(agent_id="refund-agent", framework="my-agent", session_id=session_id)
144
+ pre = ctx.pre_tool_call(call_id=call_id, name="issue_refund", args={"amount": 120.0})
145
+ await emitter.emit(pre) # raises InterceptionBlocked on a deny
146
+ value = issue_refund(amount=120.0)
147
+ await emitter.emit(ctx.post_tool_call(call_id=call_id, name="issue_refund", args={"amount": 120.0}, value=value))
148
+
149
+ ledger.enforcement(decision_id_of(pre)) # Enforcement.BEFORE_ACTION
150
+ ```
151
+
152
+ What it records, under the decision id `<session id>/<tool call id>`:
153
+
154
+ - each gate's decision (`write_gate_decision`; a PreNode's with its Gamma and threshold);
155
+ - for a denial, the fallback and its verification, so `ledger.audit()` passes;
156
+ - for an Invariant naming a `TerminalState`, a `TERMINAL` entry. Every gated call is then denied
157
+ (`vsl:terminal_state:<name>`) until `vsl.release(authority=..., authorised_by=..., evidence=...)`
158
+ records a `HUMAN_AUTHORISED_TRANSITION`. The state is read back from the ledger when a
159
+ `VSLInterceptor` is created, so with a `JsonlLedgerStore` it survives a restart: the agent comes
160
+ back still held, and only a recorded release frees it. Another agent's Terminal State (a different
161
+ `identity_key`) does not hold this one;
162
+ - after the tool, the action (`write_action`, with `is_error`).
163
+
164
+ **Matching the two audit trails.** Every gate decision and action entry carries an `agent_hooks`
165
+ field: the session id, sequence and point of the host's `InterceptionRecord` for the same emission,
166
+ and the context identity that record carries as `input_identity`. A deny also returns the ledger
167
+ entries' hashes in `evidence`, which the host keeps on the record. (The host keeps no evidence for a
168
+ plain allow, so use the `agent_hooks` field to match allowed calls.)
169
+
170
+ Denial reasons start with `vsl:`: `insufficient_gamma:<gate>`, `invariant_violation:<gate>`,
171
+ `terminal_state:<state>`, `gate_failed:<gate>`. A gate that raises, or a rule that returns anything
172
+ but a bool, is a deny (fail closed), and the ledger records the error.
173
+
174
+ Register an interceptor at every point your host emits: in `enforce` mode, Agent Hooks denies an
175
+ emission with no interceptor bound (`host_error:no_interceptor`). `vsl.points` is the two tool-call
176
+ points; the rest belong to AGT's own interceptors.
177
+
178
+ ## AGT's ToolCallInterceptor: `VSLToolCallInterceptor`
179
+
180
+ ```python
181
+ from agent_os.integrations.base import CompositeInterceptor, GovernancePolicy, PolicyInterceptor, ToolCallRequest
182
+ from vsl_agt import VSLToolCallInterceptor
183
+
184
+ vsl_native = VSLToolCallInterceptor(vsl) # the VSLInterceptor above
185
+ issue_refund = vsl_native.track(issue_refund) # records each run after it returns or raises
186
+ chain = CompositeInterceptor([PolicyInterceptor(GovernancePolicy(allowed_tools=["issue_refund"])), vsl_native])
187
+
188
+ request = ToolCallRequest(tool_name="issue_refund", arguments={"amount": 120.0}, call_id=call_id, agent_id="refund-agent")
189
+ if chain.intercept(request).allowed:
190
+ issue_refund(amount=120.0)
191
+
192
+ ledger.enforcement(call_id) # Enforcement.BEFORE_ACTION
193
+ ```
194
+
195
+ AGT's protocol is synchronous and runs before the tool only:
196
+
197
+ - the VSL gates run on a private event loop thread; a gate that doesn't decide within `timeout_sec`
198
+ (default 5 s) is a deny, `vsl:gate_timeout`;
199
+ - there is no after-tool hook, so `track(fn)` wraps each gated tool (sync or async). An allowed
200
+ intercept leaves its decision id pending; the tracked tool's next run records under it, with
201
+ `is_error` if it raised. A run with no allowed intercept before it (the gates were never asked, or
202
+ they denied and the caller ran it anyway) is recorded under a new `unmediated/...` decision id,
203
+ which `enforcement()` reads as `AFTER_ACTION`. Give the tracked function to the framework in
204
+ place of the original: for AGT's CrewAI adapter, track the tool's function before the adapter
205
+ wraps it;
206
+ - the pending id belongs to the thread or asyncio task: intercept and run the tool in the same one,
207
+ as `CompositeInterceptor` callers and the CrewAI adapter do;
208
+ - without `track`, call `record_action(request)` after the tool runs; without either, `enforcement()`
209
+ reads `NOT_OBSERVED` for an allowed call. Use one or the other for a tool, not both;
210
+ - the result's `audit_entry` carries `vsl_decision_id` and the ledger `vsl_evidence`.
211
+
212
+ `agent_os` is imported only when a call is intercepted. In AGT 5.0 importing it warns
213
+ (`agent-os-kernel is deprecated`), even from `agent-governance-toolkit-core`.
214
+
215
+ ## Other orchestration frameworks
216
+
217
+ There are three routes, depending on what the framework offers.
218
+
219
+ **1. A VSL adapter exists for it.** Use it (table above). If the agent also runs under AGT, put
220
+ both side by side. In Microsoft Agent Framework, for example, AGT's `GovernancePolicyMiddleware`
221
+ and vsl-maf's `VSLFunctionMiddleware` go in the same middleware list.
222
+
223
+ **2. Through AGT.** Which vsl-agt class you use depends on how AGT reaches the framework:
224
+
225
+ | How AGT reaches the framework | Use |
226
+ |---|---|
227
+ | A host that emits Agent Hooks (`agent-hooks-sdk`, or your own loop) | `VSLInterceptor`, registered at `vsl.points` |
228
+ | An AGT adapter that calls `ToolCallInterceptor`s, or a `CompositeInterceptor` in your own loop | `VSLToolCallInterceptor`, with each gated tool wrapped by `track()` |
229
+ | An AGT adapter with no third-party seam | route 1, or put the framework's tool calls through a `CompositeInterceptor` yourself |
230
+
231
+ In `agent-governance-toolkit-core` 5.0.0, the CrewAI adapter is the one that calls
232
+ `ToolCallInterceptor`s. The other Python adapters run AGT's policy through their own pre- and
233
+ post-execute checks, which take no third-party interceptor. That is AGT's code today, not a VSL
234
+ limit; as more of AGT's adapters move onto Agent Hooks, `VSLInterceptor` reaches them unchanged.
235
+
236
+ **3. No adapter at all.** Compile a gate with `AGTAdapter()` (or vsl-core's
237
+ `PlainPythonReferenceAdapter`) and call it immediately before the action. It raises on a denial.
238
+ Record the decision and the action yourself:
239
+
240
+ ```python
241
+ gate = AGTAdapter().compile_invariant(refund_cap)
242
+ await gate(args) # raises InvariantViolation on a denial
243
+ ledger.write_gate_decision(identity_key="refund-agent", primitive_name="refund-cap", allowed=True, decision_id=d)
244
+ issue_refund(**args)
245
+ ledger.write_action(identity_key="refund-agent", action_name="issue_refund", decision_id=d)
246
+ ```
247
+
248
+ ## What a gate reports
249
+
250
+ Gates take no assurance claim: a `PreNode` or `Invariant` is built from its name, description and
251
+ monitor or rule. Whether a gate held before its action is computed from the ledger (see
252
+ [vsl-core's "What a gate reports"](https://github.com/supersemantics/VSL-Core#what-a-gate-reports)).
253
+
254
+ ## Status
255
+
256
+ Alpha. Tested against the real packages, not mocks:
257
+
258
+ - `agent-hooks-sdk` 0.1.0b3: allowed and denied calls through `InterceptionEmitter`, the Terminal
259
+ State, its release, and both surviving a restart on a `JsonlLedgerStore`, a failing gate, ledger entries matched to the host's records, AGT-style
260
+ interceptors before VSL in the chain, and a host that runs a denied call anyway (the ledger reads
261
+ `AFTER_ACTION`).
262
+ - `agent-governance-toolkit-core` 5.0.0: `VSLToolCallInterceptor` in a `CompositeInterceptor` with
263
+ AGT's `PolicyInterceptor`, requests without a call id (CrewAI's shape), the timeout, and tracked
264
+ tools: sync and async, errors, one run per intercept, and runs with no intercept or after a deny
265
+ (`AFTER_ACTION`).
266
+ - `run_conformance_suite(AGTAdapter())` is empty.
267
+
268
+ Known gaps: a tracked tool run in a different thread or task from its intercept is recorded as
269
+ unmediated; Agent Hooks is a 0.1 beta and AGT is in preview, so both APIs may change.
270
+
271
+ ## License
272
+
273
+ MIT. Copyright Super Semantics.
@@ -0,0 +1,248 @@
1
+ # vsl-agt
2
+
3
+ [VSL](https://github.com/supersemantics/VSL-Core) gates and the VERBA ledger inside Microsoft's
4
+ [Agent Governance Toolkit](https://github.com/microsoft/agent-governance-toolkit) (AGT).
5
+
6
+ AGT decides, before a tool call runs, whether its policy allows it. vsl-agt adds VSL's gates to that
7
+ same decision, and keeps a hash-chained record that shows, call by call, whether the gates decided
8
+ before the tool ran.
9
+
10
+ **Is:**
11
+ - `VSLInterceptor`: an [Agent Hooks](https://github.com/responsibleai/agent-hooks) interceptor
12
+ (`agent-hooks/0.1`, the interception contract AGT's policy engine is built on). Register it on a
13
+ host's `InterceptionEmitter` at `pre_tool_call` and `post_tool_call`.
14
+ - `VSLToolCallInterceptor`: AGT's own `ToolCallInterceptor` protocol (`agent_os.integrations`), for
15
+ `CompositeInterceptor` chains and the adapters that call interceptors (CrewAI).
16
+ - `AGTAdapter`: vsl-core's `VSLAdapter`, passing `run_conformance_suite` with no failures.
17
+
18
+ **Is not:**
19
+ - A Microsoft project, or Microsoft's AGT repository. This is Super Semantics' VSL adapter for AGT;
20
+ AGT itself is at [microsoft/agent-governance-toolkit](https://github.com/microsoft/agent-governance-toolkit).
21
+ - A replacement for AGT's policy engine, identity, trust scoring or sandboxing. It runs next to them.
22
+ - Complete mediation. Agent Hooks says so itself: a code path the framework never routes through an
23
+ interception point is not seen, so the ledger speaks only for the calls that were.
24
+
25
+ ## How this adapter differs from the other VSL adapters
26
+
27
+ Every other VSL adapter connects VSL to an orchestration framework: a LangGraph node, LangChain or
28
+ Agent Framework middleware, a ROS 2 publisher. vsl-agt connects VSL to another governance layer.
29
+ AGT already sits between the agent and its tools; vsl-agt puts VSL's gates in the same place, so
30
+ both decide on the same call.
31
+
32
+ | | The other VSL adapters | vsl-agt |
33
+ |---|---|---|
34
+ | Plugs into | the framework's own hook | AGT's interception points, next to AGT's own policy |
35
+ | Who decides | VSL's gate alone | AGT's verdict and VSL's together: any deny stops the call |
36
+ | Ledger writes | the gate blocks; your code records the decision and the action (vsl-ros2's `vsl_guard` node records its own) | gate decisions, the fallback for each denial, the Terminal State and the tool's run are recorded for you |
37
+ | Terminal State | the gate raises; your code records it and holds the agent | the interceptor holds the agent, the hold survives a restart, and only a recorded human release ends it |
38
+ | Audit trail | the VSL ledger | the VSL ledger, each entry linked to AGT's record of the same call |
39
+ | A tool run with no check before it | not detected by the adapter | a tracked tool's unchecked run reads `AFTER_ACTION` |
40
+
41
+ ## VSL adapters
42
+
43
+ Each adapter passes vsl-core's conformance suite and builds gates with no assurance claim. vsl-core
44
+ itself: [Python](https://github.com/supersemantics/VSL-Core) (`super-semantics-vsl`),
45
+ [TypeScript](https://github.com/supersemantics/VSL-Corejs) (`@supersemantics/vsl-core`),
46
+ [.NET](https://github.com/supersemantics/VSL-Core.NET) (`SuperSemantics.Vsl`).
47
+
48
+ | Framework | Package | Where the gate runs | What a denial does |
49
+ |---|---|---|---|
50
+ | Microsoft Agent Governance Toolkit | `vsl-agt` (this repo) | AGT's `pre_tool_call` interception point, or its `ToolCallInterceptor` chain | Agent Hooks raises `InterceptionBlocked`; AGT's chain returns `allowed=False` |
51
+ | [LangGraph](https://github.com/supersemantics/VSL-Langgraph) | `vsl-langgraph` | `gated_node`: before the node body | the node is skipped; `route_on_denial` routes the graph |
52
+ | [LangGraph.js](https://github.com/supersemantics/VSL-Langgraphjs) | `@supersemantics/vsl-langgraph` | `gatedNode`: before the node body | the node is skipped; `routeOnDenial` routes the graph |
53
+ | [LangChain](https://github.com/supersemantics/VSL-LangChain) | `vsl-langchain` | `VSLToolMiddleware`, `create_agent`'s `wrap_tool_call` | the tool never runs; the model gets an error `ToolMessage` |
54
+ | [Microsoft Agent Framework (Python)](https://github.com/supersemantics/VSL-Microsoft-agent-framework) | `vsl-maf` | function middleware, before the tool | the run aborts with `VSLGateDenied` |
55
+ | [Microsoft Agent Framework (.NET)](https://github.com/supersemantics/VSL-Microsoft-agent-framework.NET) | `SuperSemantics.Vsl.AgentFramework` | `UseVslGate` / `UseVslGates`, before the tool | the run aborts with `VslGateDeniedException` |
56
+ | [ROS 2](https://github.com/supersemantics/VSL-ROS2) | `vsl-ros2` | before a command is published, a service handled or an action goal accepted | the message isn't sent, or the goal is rejected; `vsl_guard` proxies Nav2 |
57
+
58
+ ## What VSL adds to AGT
59
+
60
+ Each row is a limit AGT documents about itself, and what vsl-agt does about it.
61
+
62
+ | AGT, in its own docs | vsl-agt |
63
+ |---|---|
64
+ | The audit trail "records what the agent attempted", not whether the action ran ([LIMITATIONS](https://github.com/microsoft/agent-governance-toolkit/blob/main/docs/LIMITATIONS.md) §2) | `post_tool_call` records that the tool ran (`write_action`); `ledger.enforcement(decision_id)` computes, from record order, whether every gate decided first |
65
+ | The decision fields are outside the audit entry hash in v1.0 ([AUDIT-COMPLIANCE-1.0](https://github.com/microsoft/agent-governance-toolkit/blob/main/docs/specs/AUDIT-COMPLIANCE-1.0.md) §4.3.1) | every VSL gate decision is a hash-chained ledger entry, decision included |
66
+ | No correlation across a sequence of allowed actions (LIMITATIONS §1) | a gate can be any Invariant, including a vsl-core `Cluster` Invariant over state the agents share; hand-offs between agents are recorded with `write_handover` in the same ledger |
67
+ | A recorded kill is not proof of termination (LIMITATIONS §13) | an Invariant can name a `TerminalState`: every gated call is denied until a named human releases it, recorded as a `HUMAN_AUTHORISED_TRANSITION` |
68
+ | Policy verdicts are allow, deny or transform | a `PreNode` gates on a measured ratio (Gamma) against a threshold, recorded with its value |
69
+
70
+ ## Install
71
+
72
+ ```bash
73
+ pip install vsl-agt # with Agent Hooks
74
+ pip install "vsl-agt[agt]" # also AGT core, for VSLToolCallInterceptor
75
+ ```
76
+
77
+ vsl-agt runs on Python 3.10 or later. AGT core 5.0, and so `VSLToolCallInterceptor`, needs 3.11 or
78
+ later.
79
+
80
+ `agent-hooks-sdk` is a beta (0.1.0b3) and is pinned exactly. vsl-core comes from PyPI as
81
+ `super-semantics-vsl` (0.4.x).
82
+
83
+ ## Agent Hooks: `VSLInterceptor`
84
+
85
+ ```python
86
+ from agent_hooks import AgentContextBuilder, InterceptionBlocked, InterceptionEmitter
87
+ from vsl_core.constructs import Invariant, PreNode, TerminalState
88
+ from vsl_core.ledger import JsonlLedgerStore, VerbaLedger
89
+ from vsl_core.metrics import GammaEstimate
90
+ from vsl_agt import VSLInterceptor, decision_id_of
91
+
92
+ async def within_cap(args):
93
+ return 0 < args["amount"] <= 1000
94
+
95
+ async def budget_headroom(args):
96
+ return GammaEstimate(gamma_hat=budget_left() / args["amount"] if args["amount"] > 0 else 0.0)
97
+
98
+ ledger = VerbaLedger(JsonlLedgerStore("decisions.jsonl", fsync=True))
99
+ vsl = VSLInterceptor(
100
+ {"issue_refund": [
101
+ Invariant(name="refund-cap", description="Refunds of $1000 or less.", rule=within_cap,
102
+ on_violation=TerminalState(name="refund-escalated", description="Refunds stop for review.")),
103
+ PreNode(name="refund-budget", description="Budget left / amount above 1.1.",
104
+ monitor=budget_headroom, gamma_threshold=1.1),
105
+ ]},
106
+ ledger=ledger,
107
+ identity_key="refund-agent",
108
+ )
109
+
110
+ emitter = InterceptionEmitter()
111
+ emitter.register(vsl, name="vsl", at=vsl.points)
112
+ ```
113
+
114
+ A host (an AGT framework adapter, or your own loop) emits `pre_tool_call` before the tool and
115
+ `post_tool_call` after it. A denial raises `InterceptionBlocked` and the tool never runs:
116
+
117
+ ```python
118
+ ctx = AgentContextBuilder(agent_id="refund-agent", framework="my-agent", session_id=session_id)
119
+ pre = ctx.pre_tool_call(call_id=call_id, name="issue_refund", args={"amount": 120.0})
120
+ await emitter.emit(pre) # raises InterceptionBlocked on a deny
121
+ value = issue_refund(amount=120.0)
122
+ await emitter.emit(ctx.post_tool_call(call_id=call_id, name="issue_refund", args={"amount": 120.0}, value=value))
123
+
124
+ ledger.enforcement(decision_id_of(pre)) # Enforcement.BEFORE_ACTION
125
+ ```
126
+
127
+ What it records, under the decision id `<session id>/<tool call id>`:
128
+
129
+ - each gate's decision (`write_gate_decision`; a PreNode's with its Gamma and threshold);
130
+ - for a denial, the fallback and its verification, so `ledger.audit()` passes;
131
+ - for an Invariant naming a `TerminalState`, a `TERMINAL` entry. Every gated call is then denied
132
+ (`vsl:terminal_state:<name>`) until `vsl.release(authority=..., authorised_by=..., evidence=...)`
133
+ records a `HUMAN_AUTHORISED_TRANSITION`. The state is read back from the ledger when a
134
+ `VSLInterceptor` is created, so with a `JsonlLedgerStore` it survives a restart: the agent comes
135
+ back still held, and only a recorded release frees it. Another agent's Terminal State (a different
136
+ `identity_key`) does not hold this one;
137
+ - after the tool, the action (`write_action`, with `is_error`).
138
+
139
+ **Matching the two audit trails.** Every gate decision and action entry carries an `agent_hooks`
140
+ field: the session id, sequence and point of the host's `InterceptionRecord` for the same emission,
141
+ and the context identity that record carries as `input_identity`. A deny also returns the ledger
142
+ entries' hashes in `evidence`, which the host keeps on the record. (The host keeps no evidence for a
143
+ plain allow, so use the `agent_hooks` field to match allowed calls.)
144
+
145
+ Denial reasons start with `vsl:`: `insufficient_gamma:<gate>`, `invariant_violation:<gate>`,
146
+ `terminal_state:<state>`, `gate_failed:<gate>`. A gate that raises, or a rule that returns anything
147
+ but a bool, is a deny (fail closed), and the ledger records the error.
148
+
149
+ Register an interceptor at every point your host emits: in `enforce` mode, Agent Hooks denies an
150
+ emission with no interceptor bound (`host_error:no_interceptor`). `vsl.points` is the two tool-call
151
+ points; the rest belong to AGT's own interceptors.
152
+
153
+ ## AGT's ToolCallInterceptor: `VSLToolCallInterceptor`
154
+
155
+ ```python
156
+ from agent_os.integrations.base import CompositeInterceptor, GovernancePolicy, PolicyInterceptor, ToolCallRequest
157
+ from vsl_agt import VSLToolCallInterceptor
158
+
159
+ vsl_native = VSLToolCallInterceptor(vsl) # the VSLInterceptor above
160
+ issue_refund = vsl_native.track(issue_refund) # records each run after it returns or raises
161
+ chain = CompositeInterceptor([PolicyInterceptor(GovernancePolicy(allowed_tools=["issue_refund"])), vsl_native])
162
+
163
+ request = ToolCallRequest(tool_name="issue_refund", arguments={"amount": 120.0}, call_id=call_id, agent_id="refund-agent")
164
+ if chain.intercept(request).allowed:
165
+ issue_refund(amount=120.0)
166
+
167
+ ledger.enforcement(call_id) # Enforcement.BEFORE_ACTION
168
+ ```
169
+
170
+ AGT's protocol is synchronous and runs before the tool only:
171
+
172
+ - the VSL gates run on a private event loop thread; a gate that doesn't decide within `timeout_sec`
173
+ (default 5 s) is a deny, `vsl:gate_timeout`;
174
+ - there is no after-tool hook, so `track(fn)` wraps each gated tool (sync or async). An allowed
175
+ intercept leaves its decision id pending; the tracked tool's next run records under it, with
176
+ `is_error` if it raised. A run with no allowed intercept before it (the gates were never asked, or
177
+ they denied and the caller ran it anyway) is recorded under a new `unmediated/...` decision id,
178
+ which `enforcement()` reads as `AFTER_ACTION`. Give the tracked function to the framework in
179
+ place of the original: for AGT's CrewAI adapter, track the tool's function before the adapter
180
+ wraps it;
181
+ - the pending id belongs to the thread or asyncio task: intercept and run the tool in the same one,
182
+ as `CompositeInterceptor` callers and the CrewAI adapter do;
183
+ - without `track`, call `record_action(request)` after the tool runs; without either, `enforcement()`
184
+ reads `NOT_OBSERVED` for an allowed call. Use one or the other for a tool, not both;
185
+ - the result's `audit_entry` carries `vsl_decision_id` and the ledger `vsl_evidence`.
186
+
187
+ `agent_os` is imported only when a call is intercepted. In AGT 5.0 importing it warns
188
+ (`agent-os-kernel is deprecated`), even from `agent-governance-toolkit-core`.
189
+
190
+ ## Other orchestration frameworks
191
+
192
+ There are three routes, depending on what the framework offers.
193
+
194
+ **1. A VSL adapter exists for it.** Use it (table above). If the agent also runs under AGT, put
195
+ both side by side. In Microsoft Agent Framework, for example, AGT's `GovernancePolicyMiddleware`
196
+ and vsl-maf's `VSLFunctionMiddleware` go in the same middleware list.
197
+
198
+ **2. Through AGT.** Which vsl-agt class you use depends on how AGT reaches the framework:
199
+
200
+ | How AGT reaches the framework | Use |
201
+ |---|---|
202
+ | A host that emits Agent Hooks (`agent-hooks-sdk`, or your own loop) | `VSLInterceptor`, registered at `vsl.points` |
203
+ | An AGT adapter that calls `ToolCallInterceptor`s, or a `CompositeInterceptor` in your own loop | `VSLToolCallInterceptor`, with each gated tool wrapped by `track()` |
204
+ | An AGT adapter with no third-party seam | route 1, or put the framework's tool calls through a `CompositeInterceptor` yourself |
205
+
206
+ In `agent-governance-toolkit-core` 5.0.0, the CrewAI adapter is the one that calls
207
+ `ToolCallInterceptor`s. The other Python adapters run AGT's policy through their own pre- and
208
+ post-execute checks, which take no third-party interceptor. That is AGT's code today, not a VSL
209
+ limit; as more of AGT's adapters move onto Agent Hooks, `VSLInterceptor` reaches them unchanged.
210
+
211
+ **3. No adapter at all.** Compile a gate with `AGTAdapter()` (or vsl-core's
212
+ `PlainPythonReferenceAdapter`) and call it immediately before the action. It raises on a denial.
213
+ Record the decision and the action yourself:
214
+
215
+ ```python
216
+ gate = AGTAdapter().compile_invariant(refund_cap)
217
+ await gate(args) # raises InvariantViolation on a denial
218
+ ledger.write_gate_decision(identity_key="refund-agent", primitive_name="refund-cap", allowed=True, decision_id=d)
219
+ issue_refund(**args)
220
+ ledger.write_action(identity_key="refund-agent", action_name="issue_refund", decision_id=d)
221
+ ```
222
+
223
+ ## What a gate reports
224
+
225
+ Gates take no assurance claim: a `PreNode` or `Invariant` is built from its name, description and
226
+ monitor or rule. Whether a gate held before its action is computed from the ledger (see
227
+ [vsl-core's "What a gate reports"](https://github.com/supersemantics/VSL-Core#what-a-gate-reports)).
228
+
229
+ ## Status
230
+
231
+ Alpha. Tested against the real packages, not mocks:
232
+
233
+ - `agent-hooks-sdk` 0.1.0b3: allowed and denied calls through `InterceptionEmitter`, the Terminal
234
+ State, its release, and both surviving a restart on a `JsonlLedgerStore`, a failing gate, ledger entries matched to the host's records, AGT-style
235
+ interceptors before VSL in the chain, and a host that runs a denied call anyway (the ledger reads
236
+ `AFTER_ACTION`).
237
+ - `agent-governance-toolkit-core` 5.0.0: `VSLToolCallInterceptor` in a `CompositeInterceptor` with
238
+ AGT's `PolicyInterceptor`, requests without a call id (CrewAI's shape), the timeout, and tracked
239
+ tools: sync and async, errors, one run per intercept, and runs with no intercept or after a deny
240
+ (`AFTER_ACTION`).
241
+ - `run_conformance_suite(AGTAdapter())` is empty.
242
+
243
+ Known gaps: a tracked tool run in a different thread or task from its intercept is recorded as
244
+ unmediated; Agent Hooks is a 0.1 beta and AGT is in preview, so both APIs may change.
245
+
246
+ ## License
247
+
248
+ MIT. Copyright Super Semantics.
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vsl-agt"
7
+ version = "0.1.0"
8
+ description = "VSL gates and the VERBA ledger inside Microsoft's Agent Governance Toolkit: an Agent Hooks interceptor and an AGT ToolCallInterceptor, with recorded actions and computed enforcement."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ dependencies = [
14
+ # vsl-core, published on PyPI as super-semantics-vsl (imported as vsl_core).
15
+ "super-semantics-vsl>=0.4,<0.5",
16
+ # The Agent Hooks contract AGT's framework adapters emit. 0.1 is a beta:
17
+ # pinned to the exact release this package is tested against.
18
+ "agent-hooks-sdk==0.1.0b3",
19
+ ]
20
+ keywords = ["governance", "ai-safety", "guardrails", "agent-governance-toolkit", "agent-hooks", "vsl", "verba"]
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "Operating System :: OS Independent",
24
+ "Development Status :: 3 - Alpha",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/supersemantics/VSL-agent-governance-toolkit"
29
+ Repository = "https://github.com/supersemantics/VSL-agent-governance-toolkit"
30
+ Changelog = "https://github.com/supersemantics/VSL-agent-governance-toolkit/blob/HEAD/CHANGELOG.md"
31
+ Issues = "https://github.com/supersemantics/VSL-agent-governance-toolkit/issues"
32
+
33
+ [project.optional-dependencies]
34
+ # AGT itself, for VSLToolCallInterceptor (agent_os.integrations). Tested with 5.0.0,
35
+ # which needs Python 3.11 or later.
36
+ agt = ['agent-governance-toolkit-core>=5,<6; python_version >= "3.11"']
37
+ dev = ["pytest>=7", "pytest-asyncio>=0.23"]
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+ asyncio_mode = "auto"
45
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ """vsl-agt: VSL gates and the VERBA ledger inside Microsoft's Agent Governance Toolkit.
2
+
3
+ Register a VSLInterceptor on an Agent Hooks InterceptionEmitter (the
4
+ contract AGT's framework adapters emit) and VSL PreNodes and Invariants run
5
+ before each named tool call, every decision and every call is recorded in a
6
+ VerbaLedger, and VerbaLedger.enforcement(decision_id) shows from record
7
+ order whether the gates decided first.
8
+ """
9
+
10
+ import vsl_core as _vsl_core
11
+
12
+ from .adapter import AGTAdapter
13
+ from .agt_native import TIMEOUT_REASON, UNMEDIATED_PREFIX, VSLToolCallInterceptor
14
+ from .interceptor import (
15
+ EVIDENCE_ARTEFACT,
16
+ INTERCEPTION_POINTS,
17
+ REASON_PREFIX,
18
+ VSLInterceptor,
19
+ decision_id_of,
20
+ evaluate,
21
+ hook_link,
22
+ )
23
+
24
+ __version__ = "0.1.0"
25
+
26
+ # write_action / enforcement arrived in vsl-core 0.4.0.
27
+ _MIN_VSL_CORE = (0, 4, 0)
28
+ _found = tuple(int(part) for part in _vsl_core.__version__.split(".")[:3])
29
+ if _found < _MIN_VSL_CORE:
30
+ raise ImportError(
31
+ f"vsl-agt {__version__} needs vsl-core >= 0.4.0, found {_vsl_core.__version__}. "
32
+ "Upgrade: pip install --upgrade super-semantics-vsl"
33
+ )
34
+
35
+ __all__ = [
36
+ "AGTAdapter",
37
+ "VSLInterceptor",
38
+ "VSLToolCallInterceptor",
39
+ "TIMEOUT_REASON",
40
+ "UNMEDIATED_PREFIX",
41
+ "INTERCEPTION_POINTS",
42
+ "REASON_PREFIX",
43
+ "EVIDENCE_ARTEFACT",
44
+ "decision_id_of",
45
+ "evaluate",
46
+ "hook_link",
47
+ ]