watchlight-adk 0.4.4__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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Watchlight AI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ # The sdist ships the package, README.md, LICENSE and pyproject.toml, and
2
+ # nothing else: the tests and CI files stay in the repository.
3
+ # CI fails a build that ships anything more.
4
+ prune tests
5
+ prune ci
6
+ global-exclude *.py[cod]
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.4
2
+ Name: watchlight-adk
3
+ Version: 0.4.4
4
+ Summary: Governed Google ADK agents with Watchlight: authorize every tool call, model turn, built-in tool and sub-agent spawn before it runs, fail-closed. Independent plugin, not affiliated with Google.
5
+ Author-email: Watchlight AI <team@watchlight.ai>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://watchlight.ai
8
+ Project-URL: Documentation, https://docs.watchlight.ai/de
9
+ Project-URL: Repository, https://github.com/watchlight-ai-beacon/watchlight-de
10
+ Project-URL: Issues, https://github.com/watchlight-ai-beacon/watchlight-de/issues
11
+ Keywords: watchlight,google-adk,ai-agents,ai-governance,agent-runtime
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: httpx>=0.27
22
+ Requires-Dist: google-adk<3,>=2.5.0
23
+ Requires-Dist: watchlight-agent-sdk<0.13,>=0.12.2
24
+ Provides-Extra: nats
25
+ Requires-Dist: nats-py>=2.0; extra == "nats"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # watchlight-adk
32
+
33
+ Governed Google ADK agents with Watchlight: every tool call, model turn, built-in tool and sub-agent spawn is authorized before it runs, fail-closed.
34
+
35
+ > **Independent third-party plugin.** Built by Watchlight AI. Not affiliated with, endorsed by, or sponsored by Google. *Agent Development Kit (ADK)* and related names are trademarks of Google, used here nominatively only to describe compatibility.
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ pip install watchlight-adk "watchlight-engine>=0.2.5,<0.3"
41
+ ```
42
+
43
+ `watchlight-engine` is the compiled Developer Edition engine that `InProcessClient` uses. The plugin needs Python 3.11 or later and google-adk 2.5.0 or later (below 3). CI tests it on Python 3.12 and 3.13 with google-adk 2.14.1 and `opentelemetry-api` 1.45.2, the versions in the lock, and once more with google-adk 2.5.0.
44
+
45
+ ## Quickstart
46
+
47
+ Your agent code doesn't change. You register the plugin on the runner and point it at a backend.
48
+
49
+ ```python
50
+ from google.adk.runners import InMemoryRunner
51
+ from watchlight_adk import WatchlightPlugin
52
+ from watchlight_core import InProcessClient
53
+
54
+ # Cedar policies: the research agent may take model turns and read, nothing else.
55
+ # The principal is the agent's id, Agent::"<agent uuid>"; `principal.name` is
56
+ # its registered name (under InProcessClient, the slug it was started with).
57
+ POLICIES = [
58
+ {"name": "model",
59
+ "code": 'permit(principal is Agent, action == Action::"chat", resource) when { principal.name == "agent-research-agent" };'},
60
+ {"name": "reader",
61
+ "code": 'permit(principal is Agent, action == Action::"read", resource) when { principal.name == "agent-research-agent" };'},
62
+ ]
63
+
64
+ # Developer Edition: decisions are made in-process.
65
+ plugin = WatchlightPlugin(
66
+ agent_slug="agent-research-agent", # the root agent's registered slug
67
+ root_agent_name="research_agent", # the root ADK agent.name it belongs to
68
+ subagent_slugs={"researcher": "agent-researcher"}, # ADK agent.name → registered slug
69
+ )
70
+ plugin.apdp = InProcessClient(POLICIES) # the one line that differs from production
71
+
72
+ runner = InMemoryRunner(agent=my_agent, app_name="research", plugins=[plugin]) # Watchlight first
73
+ ```
74
+
75
+ `WatchlightPlugin(...)` loads the default Watchlight credential when it is constructed, before `plugin.apdp` is replaced. With no credential configured it loads none. A credential that is present but incomplete, such as `WATCHLIGHT_PLUGIN_TOKEN` without `WATCHLIGHT_TENANT_ID`, or a credential file at the default path that cannot be read, stops construction with `CredentialNotFound`, in the Developer Edition too. Unset it, or fix it.
76
+
77
+ Here `my_agent` is your ADK agent whose `name` is `research_agent`. Run it as usual (`runner.run_async(...)`). With these policies a `read_report` tool call runs. A `delete_report` call is refused: the tool body does not run, and the model receives a Watchlight refusal as the tool's result. Every model turn is authorized too, as action `chat` on `Model::"gemini-chat"`; without the `model` policy the agent's first model turn is refused.
78
+
79
+ The quickstart also writes the run's lineage to `.watchlight/audit.jsonl` in the current directory: an `execution_started` event, an `api_request_observed` event for each model request, a `tool_call_observed` event for each tool call with the decision it got (`Allow` for the read, `Deny` for the delete), and an `execution_completed` event with the counts of actions taken and denied.
80
+
81
+ The plugin resolves the agent slug to an identity, opens a governance session, and authorizes each tool call through ADK's native plugin callbacks (`before_tool_callback`, `before_model_callback`, `before_agent_callback`, …). A `Deny` becomes an ADK-shaped refusal the agent sees; allowed calls proceed and emit lineage. Tool names map to Cedar action verbs by convention (`get_*`/`read_*` → `read`, `list_*` → `list`, `search_*` → `search`, `create_*` → `create`, `delete_*` → `delete`, `execute_*` → `execute`, and `execute` when no convention matches), overridable per-tool via the `action_map` argument.
82
+
83
+ > **Warning:** keep `action_map` verbs on the generic verb list (`execute`, `read`, `list`, `search`, `create`, `update`, `delete`, `analyze`, `summarize`, `generate`, `embed`, `approve`, `review` and the other generic verbs the server accepts), or use the tool's own name. A sub-agent's grant and a run's tool grant name tools, not verbs, so the server reads a custom verb (`"web_search": "lookup"`) on `Tool::"web_search"` as a second, different tool. Under a grant, that call is refused, and for a sub-agent the run handle is invalidated, so the child cannot make any further calls.
84
+
85
+ ## What is and is not enforced
86
+
87
+ `watchlight-adk` puts a Watchlight authorization decision in front of the actions a Google ADK agent takes through ADK's callbacks. Register one plugin on your ADK `Runner` and each tool call, model turn, provider-side tool (Gemini built-in tools, a local code executor) and sub-agent spawn is checked against your policies — `Allow` or `Deny` — *before* it runs, with execution lineage captured along the way. Code a tool runs after it is allowed is not inspected; network egress from inside it is governed only when you route it through the Watchlight proxy.
88
+
89
+ The plugin is open-source glue: the ADK-specific lifecycle wiring on top of Watchlight's compiled policy engine (Developer Edition, in-process) or a governed Watchlight backend (Enterprise). Same plugin, same agent code — only the backend changes.
90
+
91
+ ### Which Watchlight agent is this ADK agent?
92
+
93
+ A governed identity is configuration, never something read off a framework object. ADK's `agent.name` is a display name your code picked — it is what `transfer_to_agent` addresses — while the Watchlight slug is the registry key the plugin resolves to the agent's id, the principal your policies match (`Agent::"<agent uuid>"`). Tell the plugin the mapping:
94
+
95
+ - `agent_slug="<registered-slug>"` — the root agent of the run. **Required.**
96
+ - `root_agent_name="<adk agent.name>"` — the ADK agent `agent_slug` belongs to. **Required**, so the slug is bound to an identity and not to whichever agent happens to open an invocation.
97
+ - `subagent_slugs={"<adk agent.name>": "<registered-slug>", ...}` — every other agent in the tree. Two agents may not share one slug, and no child may be mapped to the root's slug.
98
+
99
+ Slugs come from the registry, which mints them by slugifying the agent's name and prefixing `agent-`: an agent registered as `research-agent` carries the slug `agent-research-agent`. Use the registered spelling.
100
+
101
+ The plugin is always strict: an ADK agent it has no slug for is refused before it takes a single action, and the refusal says the agent is *not configured* — a deployment error — rather than *not registered*, so you know to fix the wiring and not the registry. A plugin constructed with no identity raises `ValueError` at construction.
102
+
103
+ There is no name-derivation fallback and no switch to enable one. The governed identity is the one you configure, never one worked out from `agent.name`.
104
+
105
+ ### Declaring what a sub-agent may do
106
+
107
+ When ADK transfers to a sub-agent the plugin asks the server for a governed spawn. It fills in one dimension of the requested scope for you — `allowed_tools`, derived from the tools the child agent declares. Every other dimension comes from your per-spawn default scope, read from `WATCHLIGHT_DEFAULT_SUBAGENT_SCOPE` as JSON:
108
+
109
+ ```bash
110
+ export WATCHLIGHT_DEFAULT_SUBAGENT_SCOPE='{"time_budget_seconds": 300, "max_depth": 1}'
111
+ ```
112
+
113
+ Declare it. With no value, the default scope is empty: no resources, no intents, and `max_depth: 0`. It also names no time budget, so the sub-agent inherits its parent's remaining time, bounded by the parent's deadline and the tenant ceiling, and never more. A `time_budget_seconds` you set is granted exactly as asked, or refused; it is never shortened. The server refuses `0`, because a child with no time could make no call. It also refuses a budget above what the parent can give: more than the parent was granted, more than the parent has left, or more than the tenant ceiling. The refusal says how many seconds were available, and the sub-agent does not run. A parent's remaining time shrinks as it works, so leave the budget unset if the sub-agent should simply get what is left.
114
+
115
+ Every spawn also declares the sub-agent's own intent, derived from its parent's. The plugin uses the child agent's ADK `description` as the objective and the `child_intent_category` constructor option as the intent category (default: the parent's own derived category, else `custom:delegated_task`). The server refuses a category outside the parent's intent categories or its run goal's allowed categories, so set `child_intent_category` to a category your goals allow. The sub-agent is then granted exactly that category.
116
+
117
+ A sub-agent whose spawn is refused does not run: it gets no model turn and makes no tool call. The plugin returns a refusal message in its place. That message says why (scope, delegation depth, governance unavailable) and how to fix it. The refusal holds for the rest of the ADK session. A sub-agent only ever runs through a governed spawn from its parent. If it opens an invocation of its own, for example because ADK routed the next user turn to it, it is refused.
118
+
119
+ An `AgentTool` gives the agent it wraps the parent's plugins. Leave `AgentTool(include_plugins=...)` at its default, `True`. A call of an `AgentTool` with `include_plugins=False` is refused, because its agent would run in a child Runner without Watchlight.
120
+
121
+ ### Failing closed
122
+
123
+ The plugin never turns uncertainty into permission.
124
+
125
+ - **No fail-open option.** An unreachable or failing backend is a `Deny` for every tool call and every model turn. The `fail_closed` constructor argument was removed in 0.4.1; passing it raises `TypeError`.
126
+ - **No session, no run.** When the root run's governance session cannot be opened (backend unreachable, session refused, or an empty answer), the root agent is not started: it gets no model turn and makes no tool call, and the run returns a refusal message saying governance is unavailable. `plugin.last_governance_mode` reads `"unavailable"`. A missing constraint manifest refuses the run the same way (and closes its session) unless the operator explicitly set `WATCHLIGHT_PLAN_GOVERNANCE_MODE=degrade`; only then does the run continue in `"degraded"` mode, with every action still authorized.
127
+ - **A configured proxy is required.** When `connect_proxy_url=` (or `WATCHLIGHT_PROXY_URL`) is set, every run must route its egress through the Watchlight proxy. If the backend issues no proxy token for the run, or the local CONNECT route cannot be installed, the run is refused the same way and its session is closed. It never continues with direct egress. **One governed run per process.** While a run owns the egress proxy, starting another run in the same process raises `SidecarRunActive` (a `GovernanceUnavailable`) and leaves the running one as it is. The owning run releases it when it ends, or when its session expires (`ttl_seconds`, 3600 by default) if it is never completed. Once the owner has ended, its proxy answers every new CONNECT with 403, so traffic fails rather than going direct. Run concurrent governed runs in separate processes.
128
+ - **Provider-hosted tools are authorized.** Built-in tools such as Google Search or code execution run inside the model call on Google's side and never reach `before_tool_callback`. Each model turn reads the request through the shared hosted-tool gate of `watchlight-agent-sdk`, and authorizes every hosted tool it enables before the model is called. Gemini built-ins are authorized as `Tool::"<name>"` (`google_search`, `code_execution`, `url_context`, ...), with the action verb from `action_map` or the naming convention, and with `context.builtin_tool == true` and `context.hosted_tool.kind`. The gate also reads tools passed in `config.http_options.extra_body` and a `config.cached_content`, which can carry tools (`Tool::"cached_content"`). A denial refuses the whole model turn, so your policies must permit the built-in tools an agent is given. A request the gate cannot read is refused too.
129
+ - **Remote MCP servers must be registered.** A Gemini `mcp_servers` entry lets the model call a remote MCP server directly. Pass `registered_mcp_servers={"<server url>": "<name>"}` to the plugin; the turn is then authorized for `Resource::"mcp://<name>/"`. A server that is not registered refuses the turn before any decision is asked for.
130
+ - **The request google-genai sends is decided too.** The plugin also installs the provider SDK gate of `watchlight-agent-sdk`. A governed run counts as live from its first step until it ends, and each model turn is marked with its agent, so every request the `google-genai` SDK sends for the turn is decided again on the body it sends, including options set on the model's client (`HttpOptions(extra_body=...)` on the `genai.Client`). The NextGen interactions API (`Gemini(use_interactions_api=True)`) and Gemini Live are refused, and a request that binds a tool from outside a model turn (a tool body, a thread) is refused with `UnmarkedToolBindingRefused`. Each refusal raises before anything is sent and is recorded in lineage as a `tool_call_observed` event with `metadata.provider_api_refused == true`, naming only the provider and the API. While a governed run is live, run unrelated agents that need tools in a separate process.
131
+ - **A hosted tool is decided twice.** A hosted tool on a model turn is decided by the plugin's own check of the request and again by the provider SDK gate on the request the SDK sends. This is expected: each decision is its own authorization call and its own audit record, so such a turn shows two records.
132
+ - **Hosted tools that ran are recorded.** When the model response shows that an allowed hosted tool ran (code execution parts, search or maps grounding), the plugin records a `tool_call_observed` event with `metadata.hosted_tool == true`. The event names the tool only; it carries no query, URL or result.
133
+ - **Plan governance.** `WATCHLIGHT_PLAN_GOVERNANCE_MODE` only decides what happens when the plan pipeline fails: a plan that cannot be submitted for validation refuses the model turn (`strict`, the default) or continues with action-time enforcement (`degrade`, explicit opt-in). A model turn without a `/*PLANNING*/` block is not refused, because no policy field says a plan is required; each tool call is still authorized when it is made. A denied plan refuses the turn.
134
+ - **Live sessions are refused.** ADK's live mode (`Runner.run_live`) opens the model connection without running the model callbacks, and the connection setup carries the agent's tools, so neither the model-turn decision nor the built-in tool checks could run. Until the live path can be governed, the plugin refuses every live invocation before ADK opens the connection: the session ends with a refusal message, and no Watchlight run is opened. Use `run_async`. `run_async` with `RunConfig(support_cfc=True)` is refused the same way: ADK opens a live connection for it from inside the model call, after `before_model_callback`, so it is a live session too. The refusal runs in `before_run_callback`, again in `before_agent_callback`, and again in `before_model_callback`, so a live agent started without a Runner (`agent.run_live(ctx)`) is refused too.
135
+ - **A tool that would run an agent Watchlight cannot reach is refused.** A Runner that a tool body builds gets only the plugins it is given, and ADK has no hook through which Watchlight could reach it, so its agent's tools would run with no decision. Before a tool runs, the plugin reads the tool's code without running it. It always reads the tool function itself, and it follows the functions and classes that code names: through module globals, closures, imports and module attributes (`helpers.run_sub()`), defaults, `functools.partial` arguments and the methods of classes it finds. It follows your application's own code (anything outside the standard library and installed packages, and anything in the tool's own top-level package) and any installed module that imports ADK. The call is refused before the body runs when that code:
136
+ - names `Runner`, `InMemoryRunner`, `App`, `Workflow` or any agent class (`LlmAgent` and every other `BaseAgent` subclass), directly or as a module attribute (`google.adk.runners.InMemoryRunner(...)`);
137
+ - names `PluginManager` or `InvocationContext`, or reaches the run's invocation context (`_invocation_context`, `get_invocation_context()`, `plugin_manager`), from which an agent could be run without the run's plugins;
138
+ - uses `__import__`, `import_module`, `exec` or `eval`, through which it could reach any class by a computed name;
139
+ - cannot be read within 4,096 objects.
140
+
141
+ A call of an `AgentTool` with `include_plugins=False` is refused too, and a subclass of `AgentTool` is read like any other tool. A tool that only refers to an agent instance it holds is not refused. Give sub-agents to the root as `sub_agents` or wrap them in `AgentTool` so they run as governed children.
142
+ - **What the read cannot see is stopped while it runs.** The read does not follow every indirection: a name worked out at run time, a class held in an instance attribute or passed in as an argument, or a factory in an installed package that does not import ADK. For those, the plugin has a runtime backstop. While a governed run is live anywhere in the process, an agent start, a model turn that offers tools, or a tool call that goes through a plugin manager without the Watchlight plugin is refused, as is a run started by a Runner without it. So a Runner built inside a tool body, or an agent run under a copied invocation context with the plugins stripped, never takes a turn and never runs a tool. This also holds when it runs on another thread or under a fresh `contextvars.Context`. The tool's own body still runs; only the inner agent is refused.
143
+ - **Only a constructed Watchlight plugin counts.** A plugin manager is governed only when it holds a `WatchlightPlugin` that was actually constructed. Another plugin that copies its name or attributes does not count, and its runner is refused like one with no plugin.
144
+ - **What the backstop does not see.**
145
+ - It works inside this process only. A tool body that starts a separate process to run an agent is not seen by it. Only egress governance through the Watchlight proxy applies there.
146
+ - Sub-agents run as governed children of the current run when they are given to the root as `sub_agents` or wrapped in `AgentTool`.
147
+ - **One process, one governance boundary.** "Live" is process-wide. While a governed run is live, an unrelated agent in the same process that has no Watchlight plugin is refused too. Run ungoverned agents in a separate process. When no governed run is live, nothing changes.
148
+ - **The backstop is installed once, at class level.** The plugin wraps `PluginManager`'s `run_before_run_callback`, `run_before_agent_callback`, `run_before_model_callback` and `run_before_tool_callback`, and `Runner.run_async`, when the first plugin is constructed. If any of these wraps is later replaced, every run, model turn and tool call of a governed run is refused. Removing the wraps on purpose turns governance off and is not defended against.
149
+ - **A run must start through `Runner.run_async`.** The wrap marks each step of the run it makes, and the plugin checks that mark for this run, not whether some governed run is live in the process. A run that did not start through it (the method called around the wrap, for example) is refused at `before_run_callback`, even while other governed runs are live. Where ADK ignores that run-level refusal (google-adk 2.5.0, with an `LlmAgent` root run through `run_async`), the refusal is enforced at `before_agent_callback`: the root agent is refused before its first model turn. This includes a task agent ADK resumes on its own from a session that holds an unresolved task delegation. Nothing runs, and no run or spawn reaches lineage.
150
+ - **Remote agents.** A held `RemoteA2aAgent` that a tool calls runs on its own server; the call is governed only by A2A governance, not by this check.
151
+ - **Refused tool calls are recorded as refused.** Each tool call the plugin refuses is recorded in lineage once, as a value-free `tool_call_observed` with the decision it got (`Deny` or `Quarantine`), at the moment it is refused. This covers a policy Deny, the refusal of a tool that would run an agent outside Watchlight, and a refused sub-agent's calls. Only a call the plugin let through is recorded as an `Allow`. A call the plugin never decided, for example one a plugin registered before Watchlight answered first, is recorded without a decision, never as an `Allow`. One limit: an agent-level `before_tool_callback` on your own agent runs after the plugin, so it can still skip a call the plugin allowed. That call is then recorded as an `Allow`, which is true of the authorization decision, although its body did not run.
152
+ - **Install Watchlight first.** Register the Watchlight plugin first in `plugins=[...]`. ADK stops at the first plugin whose callback returns something, so a plugin registered before Watchlight can answer a callback Watchlight never sees. Watchlight's checks that run in a later callback (the live refusal in `before_agent_callback`, the model-turn and tool checks) still apply, but only the first position guarantees that every check runs.
153
+ - **A hosted tool the response shows but the turn did not authorize** is logged and recorded in lineage as a `hosted_tool_observed` event with decision `NotAuthorized` (value-free).
154
+ - **Local code executors are authorized every turn.** A code executor other than `BuiltInCodeExecutor` (for example `UnsafeLocalCodeExecutor` or a container executor) runs the code the model writes, outside any tool callback. Each model turn of such an agent is authorized for `Tool::"code_executor"` first; a denial refuses the turn. ADK's data-file preprocessing (an executor with `optimize_data_file=True`) runs code before the first model callback, so it is authorized once when the agent starts, as `Tool::"optimize_data_file"`; a denial refuses the agent before ADK reaches it.
155
+ - **Late changes to the request are re-checked.** The plugin adds a final agent-level `before_model_callback` that authorizes any built-in tool or raw Python callable (`Tool::"callable:<name>"`) added to the request by your own agent callbacks or a later plugin, just before the model is called. An agent object that carries this re-check still refuses its model turns when a runner without the Watchlight plugin runs it, and the refusal says the plugin is not registered; build a fresh agent object for ungoverned use.
156
+ - **Tool arguments stay in the process.** The authorize request carries only value-free argument metadata in `context.tool_arg_metadata` (argument names, count and value types), never the values. The lineage plan event summarises arguments the same way. Policies that read the former `context.tool_args` string no longer receive it.
157
+
158
+ ### Attributing runs to an AI application
159
+
160
+ Every governed run can be attributed to the AI application the agent belongs to. Pass `application_id="<application UUID>"` to `WatchlightPlugin(...)` (ADK opens the run from its callbacks, so there is no per-run argument) or set `WATCHLIGHT_APPLICATION_ID` in the environment — the constructor argument wins. The id is sent on session create and bound to the run credential and to every sub-agent the run spawns; the server 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 agent names, and it is an Enterprise feature: the in-process Developer Edition engine refuses it.
161
+
162
+ ## Moving to Watchlight Beacon (Enterprise)
163
+
164
+ The Developer Edition decides with the engine inside your process. Watchlight Beacon is the Enterprise server. Your agent and the plugin registration stay the same. You leave out the `InProcessClient` line and pass the server's URL when you construct the plugin:
165
+
166
+ ```python
167
+ plugin = WatchlightPlugin(
168
+ apdp_url="https://watchlight.your-company.example",
169
+ agent_slug="agent-research-agent",
170
+ root_agent_name="research_agent",
171
+ )
172
+ ```
173
+
174
+ The plugin credential comes from your secret store or the environment, never from source code: `WATCHLIGHT_PLUGIN_TOKEN` with `WATCHLIGHT_TENANT_ID`, a credential file (`WATCHLIGHT_CREDENTIAL_FILE`) or an AWS secret (`WATCHLIGHT_CREDENTIAL_AWS_SECRET_ID`). A credential that is present but incomplete stops construction with `CredentialNotFound` and names what is missing. Lineage events then go to the server. What changes when you move (configuration, identity, agent ids, lineage and the features the Developer Edition refuses) is described once, in the SDK README: [Moving to Watchlight Beacon (Enterprise)](https://github.com/watchlight-ai-beacon/watchlight-de/blob/main/integrations/plugins/python/watchlight-core/README.md#moving-to-watchlight-beacon-enterprise).
175
+
176
+ ## Python version
177
+
178
+ `watchlight-adk` requires Python 3.11 or later; pip refuses to install it on Python 3.10. On Python 3.10, the newest google-adk is 2.11.0, which holds `opentelemetry-api` at 1.42.1 or earlier. That version has two denial-of-service flaws: unbounded parsing of an inbound `tracestate` header (CVE-2026-114603), and quadratic-time parsing of a `traceparent` value in `TraceContextTextMapPropagator.extract()` (CVE-2026-126360). google-adk 2.14.0 and later accept the fixed `opentelemetry-api` 1.45.2, and they need Python 3.11. Python 3.10 reached end of life in October 2026.
179
+
180
+ The plugin never parses inbound trace context. google-adk's own FastAPI server does in Gemini Enterprise mode: it passes the inbound `Google-Agent-Engine-Traceparent` header to `extract()`, so with a google-adk earlier than 2.14.0 it reaches the `traceparent` flaw. It passes no `tracestate`, so it does not reach the other one. If you run that server, use google-adk 2.14.0 or later.
181
+
182
+ ## Learn more
183
+
184
+ - **Documentation:** https://docs.watchlight.ai/de
185
+ - **Developer Edition** and **Enterprise:** https://watchlight.ai
186
+
187
+ ## License
188
+
189
+ Apache-2.0.
190
+
191
+ ## Trademarks
192
+
193
+ This is an independent integration built by Watchlight AI. It is not affiliated with, endorsed by or sponsored by Google. Agent Development Kit (ADK), Gemini and other product names in this README belong to their respective owners. They are used only to describe compatibility.
@@ -0,0 +1,163 @@
1
+ # watchlight-adk
2
+
3
+ Governed Google ADK agents with Watchlight: every tool call, model turn, built-in tool and sub-agent spawn is authorized before it runs, fail-closed.
4
+
5
+ > **Independent third-party plugin.** Built by Watchlight AI. Not affiliated with, endorsed by, or sponsored by Google. *Agent Development Kit (ADK)* and related names are trademarks of Google, used here nominatively only to describe compatibility.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install watchlight-adk "watchlight-engine>=0.2.5,<0.3"
11
+ ```
12
+
13
+ `watchlight-engine` is the compiled Developer Edition engine that `InProcessClient` uses. The plugin needs Python 3.11 or later and google-adk 2.5.0 or later (below 3). CI tests it on Python 3.12 and 3.13 with google-adk 2.14.1 and `opentelemetry-api` 1.45.2, the versions in the lock, and once more with google-adk 2.5.0.
14
+
15
+ ## Quickstart
16
+
17
+ Your agent code doesn't change. You register the plugin on the runner and point it at a backend.
18
+
19
+ ```python
20
+ from google.adk.runners import InMemoryRunner
21
+ from watchlight_adk import WatchlightPlugin
22
+ from watchlight_core import InProcessClient
23
+
24
+ # Cedar policies: the research agent may take model turns and read, nothing else.
25
+ # The principal is the agent's id, Agent::"<agent uuid>"; `principal.name` is
26
+ # its registered name (under InProcessClient, the slug it was started with).
27
+ POLICIES = [
28
+ {"name": "model",
29
+ "code": 'permit(principal is Agent, action == Action::"chat", resource) when { principal.name == "agent-research-agent" };'},
30
+ {"name": "reader",
31
+ "code": 'permit(principal is Agent, action == Action::"read", resource) when { principal.name == "agent-research-agent" };'},
32
+ ]
33
+
34
+ # Developer Edition: decisions are made in-process.
35
+ plugin = WatchlightPlugin(
36
+ agent_slug="agent-research-agent", # the root agent's registered slug
37
+ root_agent_name="research_agent", # the root ADK agent.name it belongs to
38
+ subagent_slugs={"researcher": "agent-researcher"}, # ADK agent.name → registered slug
39
+ )
40
+ plugin.apdp = InProcessClient(POLICIES) # the one line that differs from production
41
+
42
+ runner = InMemoryRunner(agent=my_agent, app_name="research", plugins=[plugin]) # Watchlight first
43
+ ```
44
+
45
+ `WatchlightPlugin(...)` loads the default Watchlight credential when it is constructed, before `plugin.apdp` is replaced. With no credential configured it loads none. A credential that is present but incomplete, such as `WATCHLIGHT_PLUGIN_TOKEN` without `WATCHLIGHT_TENANT_ID`, or a credential file at the default path that cannot be read, stops construction with `CredentialNotFound`, in the Developer Edition too. Unset it, or fix it.
46
+
47
+ Here `my_agent` is your ADK agent whose `name` is `research_agent`. Run it as usual (`runner.run_async(...)`). With these policies a `read_report` tool call runs. A `delete_report` call is refused: the tool body does not run, and the model receives a Watchlight refusal as the tool's result. Every model turn is authorized too, as action `chat` on `Model::"gemini-chat"`; without the `model` policy the agent's first model turn is refused.
48
+
49
+ The quickstart also writes the run's lineage to `.watchlight/audit.jsonl` in the current directory: an `execution_started` event, an `api_request_observed` event for each model request, a `tool_call_observed` event for each tool call with the decision it got (`Allow` for the read, `Deny` for the delete), and an `execution_completed` event with the counts of actions taken and denied.
50
+
51
+ The plugin resolves the agent slug to an identity, opens a governance session, and authorizes each tool call through ADK's native plugin callbacks (`before_tool_callback`, `before_model_callback`, `before_agent_callback`, …). A `Deny` becomes an ADK-shaped refusal the agent sees; allowed calls proceed and emit lineage. Tool names map to Cedar action verbs by convention (`get_*`/`read_*` → `read`, `list_*` → `list`, `search_*` → `search`, `create_*` → `create`, `delete_*` → `delete`, `execute_*` → `execute`, and `execute` when no convention matches), overridable per-tool via the `action_map` argument.
52
+
53
+ > **Warning:** keep `action_map` verbs on the generic verb list (`execute`, `read`, `list`, `search`, `create`, `update`, `delete`, `analyze`, `summarize`, `generate`, `embed`, `approve`, `review` and the other generic verbs the server accepts), or use the tool's own name. A sub-agent's grant and a run's tool grant name tools, not verbs, so the server reads a custom verb (`"web_search": "lookup"`) on `Tool::"web_search"` as a second, different tool. Under a grant, that call is refused, and for a sub-agent the run handle is invalidated, so the child cannot make any further calls.
54
+
55
+ ## What is and is not enforced
56
+
57
+ `watchlight-adk` puts a Watchlight authorization decision in front of the actions a Google ADK agent takes through ADK's callbacks. Register one plugin on your ADK `Runner` and each tool call, model turn, provider-side tool (Gemini built-in tools, a local code executor) and sub-agent spawn is checked against your policies — `Allow` or `Deny` — *before* it runs, with execution lineage captured along the way. Code a tool runs after it is allowed is not inspected; network egress from inside it is governed only when you route it through the Watchlight proxy.
58
+
59
+ The plugin is open-source glue: the ADK-specific lifecycle wiring on top of Watchlight's compiled policy engine (Developer Edition, in-process) or a governed Watchlight backend (Enterprise). Same plugin, same agent code — only the backend changes.
60
+
61
+ ### Which Watchlight agent is this ADK agent?
62
+
63
+ A governed identity is configuration, never something read off a framework object. ADK's `agent.name` is a display name your code picked — it is what `transfer_to_agent` addresses — while the Watchlight slug is the registry key the plugin resolves to the agent's id, the principal your policies match (`Agent::"<agent uuid>"`). Tell the plugin the mapping:
64
+
65
+ - `agent_slug="<registered-slug>"` — the root agent of the run. **Required.**
66
+ - `root_agent_name="<adk agent.name>"` — the ADK agent `agent_slug` belongs to. **Required**, so the slug is bound to an identity and not to whichever agent happens to open an invocation.
67
+ - `subagent_slugs={"<adk agent.name>": "<registered-slug>", ...}` — every other agent in the tree. Two agents may not share one slug, and no child may be mapped to the root's slug.
68
+
69
+ Slugs come from the registry, which mints them by slugifying the agent's name and prefixing `agent-`: an agent registered as `research-agent` carries the slug `agent-research-agent`. Use the registered spelling.
70
+
71
+ The plugin is always strict: an ADK agent it has no slug for is refused before it takes a single action, and the refusal says the agent is *not configured* — a deployment error — rather than *not registered*, so you know to fix the wiring and not the registry. A plugin constructed with no identity raises `ValueError` at construction.
72
+
73
+ There is no name-derivation fallback and no switch to enable one. The governed identity is the one you configure, never one worked out from `agent.name`.
74
+
75
+ ### Declaring what a sub-agent may do
76
+
77
+ When ADK transfers to a sub-agent the plugin asks the server for a governed spawn. It fills in one dimension of the requested scope for you — `allowed_tools`, derived from the tools the child agent declares. Every other dimension comes from your per-spawn default scope, read from `WATCHLIGHT_DEFAULT_SUBAGENT_SCOPE` as JSON:
78
+
79
+ ```bash
80
+ export WATCHLIGHT_DEFAULT_SUBAGENT_SCOPE='{"time_budget_seconds": 300, "max_depth": 1}'
81
+ ```
82
+
83
+ Declare it. With no value, the default scope is empty: no resources, no intents, and `max_depth: 0`. It also names no time budget, so the sub-agent inherits its parent's remaining time, bounded by the parent's deadline and the tenant ceiling, and never more. A `time_budget_seconds` you set is granted exactly as asked, or refused; it is never shortened. The server refuses `0`, because a child with no time could make no call. It also refuses a budget above what the parent can give: more than the parent was granted, more than the parent has left, or more than the tenant ceiling. The refusal says how many seconds were available, and the sub-agent does not run. A parent's remaining time shrinks as it works, so leave the budget unset if the sub-agent should simply get what is left.
84
+
85
+ Every spawn also declares the sub-agent's own intent, derived from its parent's. The plugin uses the child agent's ADK `description` as the objective and the `child_intent_category` constructor option as the intent category (default: the parent's own derived category, else `custom:delegated_task`). The server refuses a category outside the parent's intent categories or its run goal's allowed categories, so set `child_intent_category` to a category your goals allow. The sub-agent is then granted exactly that category.
86
+
87
+ A sub-agent whose spawn is refused does not run: it gets no model turn and makes no tool call. The plugin returns a refusal message in its place. That message says why (scope, delegation depth, governance unavailable) and how to fix it. The refusal holds for the rest of the ADK session. A sub-agent only ever runs through a governed spawn from its parent. If it opens an invocation of its own, for example because ADK routed the next user turn to it, it is refused.
88
+
89
+ An `AgentTool` gives the agent it wraps the parent's plugins. Leave `AgentTool(include_plugins=...)` at its default, `True`. A call of an `AgentTool` with `include_plugins=False` is refused, because its agent would run in a child Runner without Watchlight.
90
+
91
+ ### Failing closed
92
+
93
+ The plugin never turns uncertainty into permission.
94
+
95
+ - **No fail-open option.** An unreachable or failing backend is a `Deny` for every tool call and every model turn. The `fail_closed` constructor argument was removed in 0.4.1; passing it raises `TypeError`.
96
+ - **No session, no run.** When the root run's governance session cannot be opened (backend unreachable, session refused, or an empty answer), the root agent is not started: it gets no model turn and makes no tool call, and the run returns a refusal message saying governance is unavailable. `plugin.last_governance_mode` reads `"unavailable"`. A missing constraint manifest refuses the run the same way (and closes its session) unless the operator explicitly set `WATCHLIGHT_PLAN_GOVERNANCE_MODE=degrade`; only then does the run continue in `"degraded"` mode, with every action still authorized.
97
+ - **A configured proxy is required.** When `connect_proxy_url=` (or `WATCHLIGHT_PROXY_URL`) is set, every run must route its egress through the Watchlight proxy. If the backend issues no proxy token for the run, or the local CONNECT route cannot be installed, the run is refused the same way and its session is closed. It never continues with direct egress. **One governed run per process.** While a run owns the egress proxy, starting another run in the same process raises `SidecarRunActive` (a `GovernanceUnavailable`) and leaves the running one as it is. The owning run releases it when it ends, or when its session expires (`ttl_seconds`, 3600 by default) if it is never completed. Once the owner has ended, its proxy answers every new CONNECT with 403, so traffic fails rather than going direct. Run concurrent governed runs in separate processes.
98
+ - **Provider-hosted tools are authorized.** Built-in tools such as Google Search or code execution run inside the model call on Google's side and never reach `before_tool_callback`. Each model turn reads the request through the shared hosted-tool gate of `watchlight-agent-sdk`, and authorizes every hosted tool it enables before the model is called. Gemini built-ins are authorized as `Tool::"<name>"` (`google_search`, `code_execution`, `url_context`, ...), with the action verb from `action_map` or the naming convention, and with `context.builtin_tool == true` and `context.hosted_tool.kind`. The gate also reads tools passed in `config.http_options.extra_body` and a `config.cached_content`, which can carry tools (`Tool::"cached_content"`). A denial refuses the whole model turn, so your policies must permit the built-in tools an agent is given. A request the gate cannot read is refused too.
99
+ - **Remote MCP servers must be registered.** A Gemini `mcp_servers` entry lets the model call a remote MCP server directly. Pass `registered_mcp_servers={"<server url>": "<name>"}` to the plugin; the turn is then authorized for `Resource::"mcp://<name>/"`. A server that is not registered refuses the turn before any decision is asked for.
100
+ - **The request google-genai sends is decided too.** The plugin also installs the provider SDK gate of `watchlight-agent-sdk`. A governed run counts as live from its first step until it ends, and each model turn is marked with its agent, so every request the `google-genai` SDK sends for the turn is decided again on the body it sends, including options set on the model's client (`HttpOptions(extra_body=...)` on the `genai.Client`). The NextGen interactions API (`Gemini(use_interactions_api=True)`) and Gemini Live are refused, and a request that binds a tool from outside a model turn (a tool body, a thread) is refused with `UnmarkedToolBindingRefused`. Each refusal raises before anything is sent and is recorded in lineage as a `tool_call_observed` event with `metadata.provider_api_refused == true`, naming only the provider and the API. While a governed run is live, run unrelated agents that need tools in a separate process.
101
+ - **A hosted tool is decided twice.** A hosted tool on a model turn is decided by the plugin's own check of the request and again by the provider SDK gate on the request the SDK sends. This is expected: each decision is its own authorization call and its own audit record, so such a turn shows two records.
102
+ - **Hosted tools that ran are recorded.** When the model response shows that an allowed hosted tool ran (code execution parts, search or maps grounding), the plugin records a `tool_call_observed` event with `metadata.hosted_tool == true`. The event names the tool only; it carries no query, URL or result.
103
+ - **Plan governance.** `WATCHLIGHT_PLAN_GOVERNANCE_MODE` only decides what happens when the plan pipeline fails: a plan that cannot be submitted for validation refuses the model turn (`strict`, the default) or continues with action-time enforcement (`degrade`, explicit opt-in). A model turn without a `/*PLANNING*/` block is not refused, because no policy field says a plan is required; each tool call is still authorized when it is made. A denied plan refuses the turn.
104
+ - **Live sessions are refused.** ADK's live mode (`Runner.run_live`) opens the model connection without running the model callbacks, and the connection setup carries the agent's tools, so neither the model-turn decision nor the built-in tool checks could run. Until the live path can be governed, the plugin refuses every live invocation before ADK opens the connection: the session ends with a refusal message, and no Watchlight run is opened. Use `run_async`. `run_async` with `RunConfig(support_cfc=True)` is refused the same way: ADK opens a live connection for it from inside the model call, after `before_model_callback`, so it is a live session too. The refusal runs in `before_run_callback`, again in `before_agent_callback`, and again in `before_model_callback`, so a live agent started without a Runner (`agent.run_live(ctx)`) is refused too.
105
+ - **A tool that would run an agent Watchlight cannot reach is refused.** A Runner that a tool body builds gets only the plugins it is given, and ADK has no hook through which Watchlight could reach it, so its agent's tools would run with no decision. Before a tool runs, the plugin reads the tool's code without running it. It always reads the tool function itself, and it follows the functions and classes that code names: through module globals, closures, imports and module attributes (`helpers.run_sub()`), defaults, `functools.partial` arguments and the methods of classes it finds. It follows your application's own code (anything outside the standard library and installed packages, and anything in the tool's own top-level package) and any installed module that imports ADK. The call is refused before the body runs when that code:
106
+ - names `Runner`, `InMemoryRunner`, `App`, `Workflow` or any agent class (`LlmAgent` and every other `BaseAgent` subclass), directly or as a module attribute (`google.adk.runners.InMemoryRunner(...)`);
107
+ - names `PluginManager` or `InvocationContext`, or reaches the run's invocation context (`_invocation_context`, `get_invocation_context()`, `plugin_manager`), from which an agent could be run without the run's plugins;
108
+ - uses `__import__`, `import_module`, `exec` or `eval`, through which it could reach any class by a computed name;
109
+ - cannot be read within 4,096 objects.
110
+
111
+ A call of an `AgentTool` with `include_plugins=False` is refused too, and a subclass of `AgentTool` is read like any other tool. A tool that only refers to an agent instance it holds is not refused. Give sub-agents to the root as `sub_agents` or wrap them in `AgentTool` so they run as governed children.
112
+ - **What the read cannot see is stopped while it runs.** The read does not follow every indirection: a name worked out at run time, a class held in an instance attribute or passed in as an argument, or a factory in an installed package that does not import ADK. For those, the plugin has a runtime backstop. While a governed run is live anywhere in the process, an agent start, a model turn that offers tools, or a tool call that goes through a plugin manager without the Watchlight plugin is refused, as is a run started by a Runner without it. So a Runner built inside a tool body, or an agent run under a copied invocation context with the plugins stripped, never takes a turn and never runs a tool. This also holds when it runs on another thread or under a fresh `contextvars.Context`. The tool's own body still runs; only the inner agent is refused.
113
+ - **Only a constructed Watchlight plugin counts.** A plugin manager is governed only when it holds a `WatchlightPlugin` that was actually constructed. Another plugin that copies its name or attributes does not count, and its runner is refused like one with no plugin.
114
+ - **What the backstop does not see.**
115
+ - It works inside this process only. A tool body that starts a separate process to run an agent is not seen by it. Only egress governance through the Watchlight proxy applies there.
116
+ - Sub-agents run as governed children of the current run when they are given to the root as `sub_agents` or wrapped in `AgentTool`.
117
+ - **One process, one governance boundary.** "Live" is process-wide. While a governed run is live, an unrelated agent in the same process that has no Watchlight plugin is refused too. Run ungoverned agents in a separate process. When no governed run is live, nothing changes.
118
+ - **The backstop is installed once, at class level.** The plugin wraps `PluginManager`'s `run_before_run_callback`, `run_before_agent_callback`, `run_before_model_callback` and `run_before_tool_callback`, and `Runner.run_async`, when the first plugin is constructed. If any of these wraps is later replaced, every run, model turn and tool call of a governed run is refused. Removing the wraps on purpose turns governance off and is not defended against.
119
+ - **A run must start through `Runner.run_async`.** The wrap marks each step of the run it makes, and the plugin checks that mark for this run, not whether some governed run is live in the process. A run that did not start through it (the method called around the wrap, for example) is refused at `before_run_callback`, even while other governed runs are live. Where ADK ignores that run-level refusal (google-adk 2.5.0, with an `LlmAgent` root run through `run_async`), the refusal is enforced at `before_agent_callback`: the root agent is refused before its first model turn. This includes a task agent ADK resumes on its own from a session that holds an unresolved task delegation. Nothing runs, and no run or spawn reaches lineage.
120
+ - **Remote agents.** A held `RemoteA2aAgent` that a tool calls runs on its own server; the call is governed only by A2A governance, not by this check.
121
+ - **Refused tool calls are recorded as refused.** Each tool call the plugin refuses is recorded in lineage once, as a value-free `tool_call_observed` with the decision it got (`Deny` or `Quarantine`), at the moment it is refused. This covers a policy Deny, the refusal of a tool that would run an agent outside Watchlight, and a refused sub-agent's calls. Only a call the plugin let through is recorded as an `Allow`. A call the plugin never decided, for example one a plugin registered before Watchlight answered first, is recorded without a decision, never as an `Allow`. One limit: an agent-level `before_tool_callback` on your own agent runs after the plugin, so it can still skip a call the plugin allowed. That call is then recorded as an `Allow`, which is true of the authorization decision, although its body did not run.
122
+ - **Install Watchlight first.** Register the Watchlight plugin first in `plugins=[...]`. ADK stops at the first plugin whose callback returns something, so a plugin registered before Watchlight can answer a callback Watchlight never sees. Watchlight's checks that run in a later callback (the live refusal in `before_agent_callback`, the model-turn and tool checks) still apply, but only the first position guarantees that every check runs.
123
+ - **A hosted tool the response shows but the turn did not authorize** is logged and recorded in lineage as a `hosted_tool_observed` event with decision `NotAuthorized` (value-free).
124
+ - **Local code executors are authorized every turn.** A code executor other than `BuiltInCodeExecutor` (for example `UnsafeLocalCodeExecutor` or a container executor) runs the code the model writes, outside any tool callback. Each model turn of such an agent is authorized for `Tool::"code_executor"` first; a denial refuses the turn. ADK's data-file preprocessing (an executor with `optimize_data_file=True`) runs code before the first model callback, so it is authorized once when the agent starts, as `Tool::"optimize_data_file"`; a denial refuses the agent before ADK reaches it.
125
+ - **Late changes to the request are re-checked.** The plugin adds a final agent-level `before_model_callback` that authorizes any built-in tool or raw Python callable (`Tool::"callable:<name>"`) added to the request by your own agent callbacks or a later plugin, just before the model is called. An agent object that carries this re-check still refuses its model turns when a runner without the Watchlight plugin runs it, and the refusal says the plugin is not registered; build a fresh agent object for ungoverned use.
126
+ - **Tool arguments stay in the process.** The authorize request carries only value-free argument metadata in `context.tool_arg_metadata` (argument names, count and value types), never the values. The lineage plan event summarises arguments the same way. Policies that read the former `context.tool_args` string no longer receive it.
127
+
128
+ ### Attributing runs to an AI application
129
+
130
+ Every governed run can be attributed to the AI application the agent belongs to. Pass `application_id="<application UUID>"` to `WatchlightPlugin(...)` (ADK opens the run from its callbacks, so there is no per-run argument) or set `WATCHLIGHT_APPLICATION_ID` in the environment — the constructor argument wins. The id is sent on session create and bound to the run credential and to every sub-agent the run spawns; the server 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 agent names, and it is an Enterprise feature: the in-process Developer Edition engine refuses it.
131
+
132
+ ## Moving to Watchlight Beacon (Enterprise)
133
+
134
+ The Developer Edition decides with the engine inside your process. Watchlight Beacon is the Enterprise server. Your agent and the plugin registration stay the same. You leave out the `InProcessClient` line and pass the server's URL when you construct the plugin:
135
+
136
+ ```python
137
+ plugin = WatchlightPlugin(
138
+ apdp_url="https://watchlight.your-company.example",
139
+ agent_slug="agent-research-agent",
140
+ root_agent_name="research_agent",
141
+ )
142
+ ```
143
+
144
+ The plugin credential comes from your secret store or the environment, never from source code: `WATCHLIGHT_PLUGIN_TOKEN` with `WATCHLIGHT_TENANT_ID`, a credential file (`WATCHLIGHT_CREDENTIAL_FILE`) or an AWS secret (`WATCHLIGHT_CREDENTIAL_AWS_SECRET_ID`). A credential that is present but incomplete stops construction with `CredentialNotFound` and names what is missing. Lineage events then go to the server. What changes when you move (configuration, identity, agent ids, lineage and the features the Developer Edition refuses) is described once, in the SDK README: [Moving to Watchlight Beacon (Enterprise)](https://github.com/watchlight-ai-beacon/watchlight-de/blob/main/integrations/plugins/python/watchlight-core/README.md#moving-to-watchlight-beacon-enterprise).
145
+
146
+ ## Python version
147
+
148
+ `watchlight-adk` requires Python 3.11 or later; pip refuses to install it on Python 3.10. On Python 3.10, the newest google-adk is 2.11.0, which holds `opentelemetry-api` at 1.42.1 or earlier. That version has two denial-of-service flaws: unbounded parsing of an inbound `tracestate` header (CVE-2026-114603), and quadratic-time parsing of a `traceparent` value in `TraceContextTextMapPropagator.extract()` (CVE-2026-126360). google-adk 2.14.0 and later accept the fixed `opentelemetry-api` 1.45.2, and they need Python 3.11. Python 3.10 reached end of life in October 2026.
149
+
150
+ The plugin never parses inbound trace context. google-adk's own FastAPI server does in Gemini Enterprise mode: it passes the inbound `Google-Agent-Engine-Traceparent` header to `extract()`, so with a google-adk earlier than 2.14.0 it reaches the `traceparent` flaw. It passes no `tracestate`, so it does not reach the other one. If you run that server, use google-adk 2.14.0 or later.
151
+
152
+ ## Learn more
153
+
154
+ - **Documentation:** https://docs.watchlight.ai/de
155
+ - **Developer Edition** and **Enterprise:** https://watchlight.ai
156
+
157
+ ## License
158
+
159
+ Apache-2.0.
160
+
161
+ ## Trademarks
162
+
163
+ This is an independent integration built by Watchlight AI. It is not affiliated with, endorsed by or sponsored by Google. Agent Development Kit (ADK), Gemini and other product names in this README belong to their respective owners. They are used only to describe compatibility.