agent-action-gateway 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_action_gateway-0.2.0/LICENSE +21 -0
- agent_action_gateway-0.2.0/PKG-INFO +374 -0
- agent_action_gateway-0.2.0/README.md +343 -0
- agent_action_gateway-0.2.0/pyproject.toml +167 -0
- agent_action_gateway-0.2.0/setup.cfg +4 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/__init__.py +44 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/__main__.py +7 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/audit/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/audit/failure_wall.py +215 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/audit/promotions.py +196 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/audit/receipts.py +143 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/audit/wall.py +298 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/cli.py +997 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/credential/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/credential/credentials.py +272 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/credential/egress.py +216 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/data/calibration/calibration-v1.json +47 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/data/golden/golden-v1.json +35 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/engine/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/engine/enforcement.py +419 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/calibration.py +138 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/evaluator.py +166 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/gate.py +108 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/golden.py +135 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/judge.py +163 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/models.py +120 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/online.py +192 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/providers/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/providers/gemini.py +269 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/trajectory.py +231 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/eval/verdict.py +53 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/gate_cli.py +295 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/guards/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/guards/capture.py +58 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/guards/redaction.py +124 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/guards/sql.py +158 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/guards/status.py +20 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/adapters/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/adapters/base.py +59 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/gateway.py +751 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/mcp.py +153 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/mcp_http.py +436 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/mcp_proxy.py +2020 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/integrations/mcp_server.py +101 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/observability/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/observability/dashboard.py +916 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/observability/view.py +170 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/observability/wiring.py +481 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/__init__.py +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/cross_check.py +47 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/fingerprint.py +111 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/fuses.py +291 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/locks.py +411 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/safety.py +37 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/policy/stop_rules.py +219 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/__init__.py +4 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/approval_proof.py +76 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/chaos.py +298 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/chaos_manual.py +82 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/evaluation_proof.py +99 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/fakes.py +22 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/proofs/proof.py +113 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/runtime/__init__.py +4 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/runtime/orchestrator.py +281 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/runtime/records.py +49 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/runtime/session.py +764 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/storage/__init__.py +3 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/storage/base.py +185 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/storage/evaluations.py +224 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/storage/postgres.py +190 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway/storage/traces.py +765 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/PKG-INFO +374 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/SOURCES.txt +129 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/dependency_links.txt +1 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/entry_points.txt +2 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/requires.txt +14 -0
- agent_action_gateway-0.2.0/src/agent_action_gateway.egg-info/top_level.txt +1 -0
- agent_action_gateway-0.2.0/tests/test_adoption_contract.py +295 -0
- agent_action_gateway-0.2.0/tests/test_approvals.py +184 -0
- agent_action_gateway-0.2.0/tests/test_backend_agreement.py +337 -0
- agent_action_gateway-0.2.0/tests/test_cli.py +256 -0
- agent_action_gateway-0.2.0/tests/test_credentials.py +176 -0
- agent_action_gateway-0.2.0/tests/test_dashboard.py +296 -0
- agent_action_gateway-0.2.0/tests/test_dashboard_actions.py +243 -0
- agent_action_gateway-0.2.0/tests/test_documentation.py +39 -0
- agent_action_gateway-0.2.0/tests/test_documentation_clarity.py +354 -0
- agent_action_gateway-0.2.0/tests/test_effect_claims.py +231 -0
- agent_action_gateway-0.2.0/tests/test_egress_gateway.py +159 -0
- agent_action_gateway-0.2.0/tests/test_evaluation.py +248 -0
- agent_action_gateway-0.2.0/tests/test_evaluator_pacing.py +50 -0
- agent_action_gateway-0.2.0/tests/test_failure_promotion.py +187 -0
- agent_action_gateway-0.2.0/tests/test_failure_promotion_drill.py +121 -0
- agent_action_gateway-0.2.0/tests/test_failure_wall.py +182 -0
- agent_action_gateway-0.2.0/tests/test_fingerprint.py +103 -0
- agent_action_gateway-0.2.0/tests/test_fuses.py +358 -0
- agent_action_gateway-0.2.0/tests/test_gate.py +212 -0
- agent_action_gateway-0.2.0/tests/test_gateway.py +429 -0
- agent_action_gateway-0.2.0/tests/test_gateway_boundary.py +465 -0
- agent_action_gateway-0.2.0/tests/test_gateway_modes.py +80 -0
- agent_action_gateway-0.2.0/tests/test_gemini_judge.py +221 -0
- agent_action_gateway-0.2.0/tests/test_golden_set_portability.py +171 -0
- agent_action_gateway-0.2.0/tests/test_guarded_receipts.py +168 -0
- agent_action_gateway-0.2.0/tests/test_intent_key.py +67 -0
- agent_action_gateway-0.2.0/tests/test_mcp.py +253 -0
- agent_action_gateway-0.2.0/tests/test_mcp_http.py +282 -0
- agent_action_gateway-0.2.0/tests/test_mcp_proxy.py +1409 -0
- agent_action_gateway-0.2.0/tests/test_mcp_server.py +78 -0
- agent_action_gateway-0.2.0/tests/test_online_eval.py +168 -0
- agent_action_gateway-0.2.0/tests/test_packaging.py +131 -0
- agent_action_gateway-0.2.0/tests/test_property_edges.py +70 -0
- agent_action_gateway-0.2.0/tests/test_proxy_deployment.py +113 -0
- agent_action_gateway-0.2.0/tests/test_proxy_gateway.py +161 -0
- agent_action_gateway-0.2.0/tests/test_proxy_gateway_process.py +195 -0
- agent_action_gateway-0.2.0/tests/test_readme_examples.py +66 -0
- agent_action_gateway-0.2.0/tests/test_receipts.py +68 -0
- agent_action_gateway-0.2.0/tests/test_retention.py +201 -0
- agent_action_gateway-0.2.0/tests/test_safety_invariants.py +388 -0
- agent_action_gateway-0.2.0/tests/test_self_correction.py +314 -0
- agent_action_gateway-0.2.0/tests/test_silent_failures.py +107 -0
- agent_action_gateway-0.2.0/tests/test_smoke.py +50 -0
- agent_action_gateway-0.2.0/tests/test_sql_guard.py +90 -0
- agent_action_gateway-0.2.0/tests/test_sqlite_base.py +191 -0
- agent_action_gateway-0.2.0/tests/test_stop_rules.py +601 -0
- agent_action_gateway-0.2.0/tests/test_trace.py +342 -0
- agent_action_gateway-0.2.0/tests/test_trace_capture.py +167 -0
- agent_action_gateway-0.2.0/tests/test_trajectory.py +206 -0
- agent_action_gateway-0.2.0/tests/test_unknown_outcomes.py +156 -0
- agent_action_gateway-0.2.0/tests/test_wiring_check.py +316 -0
- agent_action_gateway-0.2.0/tests/test_write_and_retry.py +107 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GreyyDaze
|
|
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.
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: agent-action-gateway
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Let AI agents change real systems safely: you control what they can do, and you can prove what they did
|
|
5
|
+
Author: GreyyDaze
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/GreyyDaze/agent-action-gateway
|
|
8
|
+
Project-URL: Repository, https://github.com/GreyyDaze/agent-action-gateway
|
|
9
|
+
Project-URL: Issues, https://github.com/GreyyDaze/agent-action-gateway/issues
|
|
10
|
+
Keywords: ai-agents,safety,mcp,guardrails,audit,approval
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: yaml
|
|
21
|
+
Requires-Dist: PyYAML>=6; extra == "yaml"
|
|
22
|
+
Provides-Extra: postgres
|
|
23
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest<9,>=8; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy>=1.11; extra == "dev"
|
|
29
|
+
Requires-Dist: PyYAML>=6; extra == "dev"
|
|
30
|
+
Requires-Dist: mutmut>=2.5; extra == "dev"
|
|
31
|
+
|
|
32
|
+
# Agent Action Gateway
|
|
33
|
+
|
|
34
|
+
[](https://github.com/GreyyDaze/agent-action-gateway/actions/workflows/ci.yml)
|
|
35
|
+
|
|
36
|
+
**Let AI agents change real systems safely. You control what they can do, and
|
|
37
|
+
you can prove what they did.**
|
|
38
|
+
|
|
39
|
+
## 1. Overview
|
|
40
|
+
|
|
41
|
+
AI agents call tools that change real systems: they delete tables, deploy code,
|
|
42
|
+
restart services. Called directly, there is **no control** (a wrong or
|
|
43
|
+
prompt-injected agent still acts) and **no proof** (no record of what it tried,
|
|
44
|
+
what ran, and what was refused).
|
|
45
|
+
|
|
46
|
+
This package puts a **checkpoint** between the agent and those tools. The agent
|
|
47
|
+
decides what to do. The checkpoint decides if it runs, and records it either way.
|
|
48
|
+
|
|
49
|
+
## 2. Key features
|
|
50
|
+
|
|
51
|
+
| | Problem | What the checkpoint does |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| **Control** | A risky action runs unseen | It waits until a person approves **that exact action**. The approval works once. |
|
|
54
|
+
| | The agent acts in the wrong environment | A `prod` tool is refused from a `dev` or `staging` session. |
|
|
55
|
+
| | A retry repeats the action | The same action does not run twice, even after a crash. |
|
|
56
|
+
| | The agent loops or runs too long | Limits on steps, time and cost stop the run. |
|
|
57
|
+
| | The agent holds the real API key | With the gateway, it never sees the key. |
|
|
58
|
+
| **Prove** | No record of what happened | Every checked action is recorded, with secrets hidden. A dashboard shows it, and is where a person approves, settles held actions and accepts changed tools. |
|
|
59
|
+
| | A new version may be less safe | A release gate tests it on your cases and fails if it got worse. |
|
|
60
|
+
|
|
61
|
+
Smaller features (stop and ask for a missing value, risk decided per call for
|
|
62
|
+
tools like `execute_sql`, tool pinning, the bypass scanner) are explained in the
|
|
63
|
+
[SDK guide](docs/sdk.md), the [gateway guide](docs/gateway-deployment.md) and the
|
|
64
|
+
[evaluation guide](docs/evaluation.md).
|
|
65
|
+
|
|
66
|
+
## 3. Technology stack
|
|
67
|
+
|
|
68
|
+
- **Python 3.11+, standard library only.** No required dependencies in a safety tool.
|
|
69
|
+
- **SQLite** by default, **PostgreSQL** optional: approvals and records survive a crash.
|
|
70
|
+
- **MCP** (stdio and Streamable HTTP) and **HTTP**, written without an SDK (why: section 8).
|
|
71
|
+
- **pytest, ruff, mypy** in CI on Python 3.11 to 3.13.
|
|
72
|
+
|
|
73
|
+
## 4. Core concepts
|
|
74
|
+
|
|
75
|
+
- **Risk class:** `read`, `write` or `destructive`. Anything undeclared is
|
|
76
|
+
destructive. Everything except `read` needs an approval.
|
|
77
|
+
- **Exact approval:** bound to the action and its arguments, used once, expires
|
|
78
|
+
after 15 minutes.
|
|
79
|
+
- **Effect claim:** recorded *before* the action runs, keyed on what the action
|
|
80
|
+
is. A retry finds it and gets the first result instead of acting again
|
|
81
|
+
([details](docs/receipt-guarantees.md)).
|
|
82
|
+
- **Pinning:** the MCP proxy saves each tool's definition; a changed tool is
|
|
83
|
+
hidden until a person accepts it.
|
|
84
|
+
- **Virtual key:** the gateway holds the real key; the agent gets a key that only
|
|
85
|
+
works for its allowed routes.
|
|
86
|
+
|
|
87
|
+
## 5. Architecture
|
|
88
|
+
|
|
89
|
+
How it works, in four steps:
|
|
90
|
+
|
|
91
|
+
1. **The agent asks.** Every tool call goes to the checkpoint (the library in
|
|
92
|
+
Python, or the MCP proxy). The agent cannot reach your tools, the real keys or
|
|
93
|
+
the records any other way.
|
|
94
|
+
2. **The checkpoint checks.** Limits, environment, and for anything that is not
|
|
95
|
+
a read, an approval from a person for that exact call.
|
|
96
|
+
3. **It runs once.** The action is claimed before it runs, so a retry or crash
|
|
97
|
+
never runs it twice. With the gateway, the real key is added there and the
|
|
98
|
+
agent never sees it.
|
|
99
|
+
4. **Everything is recorded.** A person sees it in the dashboard, approves calls,
|
|
100
|
+
settles actions with no clear result, and accepts changed tools.
|
|
101
|
+
|
|
102
|
+
```mermaid
|
|
103
|
+
flowchart LR
|
|
104
|
+
A["1. Your agent<br/>asks to run a tool"] --> C
|
|
105
|
+
|
|
106
|
+
subgraph C["2. Checkpoint: library or MCP proxy"]
|
|
107
|
+
direction TB
|
|
108
|
+
K["Check limits<br/>and environment"] --> AP{"Not a read:<br/>approved by<br/>a person?"}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
AP -->|no: blocked,<br/>approval requested| P
|
|
112
|
+
AP -->|yes| O["3. Run once<br/>(claimed first,<br/>never twice)"]
|
|
113
|
+
O --> T[Your tools /<br/>MCP servers]
|
|
114
|
+
O --> G["Gateway<br/>adds the real key"]
|
|
115
|
+
G --> API[Real APIs]
|
|
116
|
+
|
|
117
|
+
C --> R[("4. Records<br/>secrets hidden")]
|
|
118
|
+
O --> R
|
|
119
|
+
R --> P["Person<br/>dashboard or CLI"]
|
|
120
|
+
P -->|approves; agent<br/>tries again| A
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary><b>Show every part and step</b></summary>
|
|
125
|
+
|
|
126
|
+
```mermaid
|
|
127
|
+
flowchart TD
|
|
128
|
+
subgraph AG["Agent side"]
|
|
129
|
+
A["Your agent<br/>(proposes an action)"]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
subgraph CP["Checkpoint: the only way in"]
|
|
133
|
+
LIB["Library: session() / ctx.tool<br/>(Python functions)"]
|
|
134
|
+
PX["MCP proxy<br/>(stdio, or HTTP with a token)"]
|
|
135
|
+
PIN{"0. Tool definition<br/>same as pinned?"}
|
|
136
|
+
S1["1. Decide the risk<br/>read / write / destructive<br/>(undeclared = destructive)"]
|
|
137
|
+
S2{"2. Within limits?<br/>steps, time, cost, loops"}
|
|
138
|
+
S3{"3. Right environment?"}
|
|
139
|
+
S4{"4. Not a read:<br/>exact approval?<br/>(same action and arguments,<br/>unused, under 15 min)"}
|
|
140
|
+
S5{"5. Claim the effect:<br/>claimed before?"}
|
|
141
|
+
RUN["6. Run it, with the intent key"]
|
|
142
|
+
OUT{"Result?"}
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
subgraph TL["Your systems"]
|
|
146
|
+
T["Your tools / MCP servers"]
|
|
147
|
+
GW["Gateway<br/>virtual key in, real key out;<br/>routes, hosts, private-address check"]
|
|
148
|
+
API["Real APIs"]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
subgraph ST["Records (SQLite or PostgreSQL)"]
|
|
152
|
+
APR[("Approvals")]
|
|
153
|
+
RCP[("Receipts<br/>pending / done / failed / resolved")]
|
|
154
|
+
TR[("Run records<br/>secrets hidden")]
|
|
155
|
+
PN[("Pinned tools")]
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
subgraph HU["Person"]
|
|
159
|
+
D["Dashboard or CLI<br/>approve or deny, settle held actions,<br/>accept changed tools, see runs"]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
A -->|Python call| LIB
|
|
163
|
+
A -->|MCP call| PX
|
|
164
|
+
PX --> PIN
|
|
165
|
+
PIN -->|changed: hidden until accepted| PN
|
|
166
|
+
PIN -->|same| S1
|
|
167
|
+
LIB --> S1
|
|
168
|
+
S1 --> S2
|
|
169
|
+
S2 -->|no| BLK["Blocked, with the reason"]
|
|
170
|
+
S2 -->|yes| S3
|
|
171
|
+
S3 -->|no| BLK
|
|
172
|
+
S3 -->|yes| S4
|
|
173
|
+
S4 -->|no| REQ["Blocked: approval requested<br/>(agent gets an approval id)"]
|
|
174
|
+
REQ --> APR
|
|
175
|
+
S4 -->|yes, now used up| S5
|
|
176
|
+
S5 -->|done before| PREV["Return the first result<br/>(not run again)"]
|
|
177
|
+
S5 -->|pending: may have landed| HELD["Held: not run again"]
|
|
178
|
+
S5 -->|new, or failed before| RUN
|
|
179
|
+
RUN --> T
|
|
180
|
+
RUN --> GW
|
|
181
|
+
GW --> API
|
|
182
|
+
RUN --> OUT
|
|
183
|
+
OUT -->|ok| OK["Mark done, return the result"]
|
|
184
|
+
OUT -->|clear error| FAIL["Mark failed<br/>(safe to try again)"]
|
|
185
|
+
OUT -->|timeout or no answer| HELD
|
|
186
|
+
|
|
187
|
+
OK --> RCP
|
|
188
|
+
FAIL --> RCP
|
|
189
|
+
HELD --> RCP
|
|
190
|
+
BLK --> TR
|
|
191
|
+
REQ --> TR
|
|
192
|
+
OK --> TR
|
|
193
|
+
PREV --> TR
|
|
194
|
+
|
|
195
|
+
APR --> D
|
|
196
|
+
RCP --> D
|
|
197
|
+
TR --> D
|
|
198
|
+
PN --> D
|
|
199
|
+
D -->|approve| APR
|
|
200
|
+
D -->|settle: landed or not| RCP
|
|
201
|
+
D -->|accept| PN
|
|
202
|
+
REQ -.->|agent retries with the approval id| A
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
</details>
|
|
206
|
+
|
|
207
|
+
| Part | Use it when your agent calls | Checks | Guide |
|
|
208
|
+
|---|---|---|---|
|
|
209
|
+
| **Library** (`session()`) | Python functions | everything in section 6 | [SDK guide](docs/sdk.md#sessions) |
|
|
210
|
+
| **MCP proxy** (`agent-gateway mcp-proxy`) | MCP tools, started as a command or reached by URL (`--http`) | everything in section 6, plus pinning | [MCP proxy](docs/sdk.md#mcp-proxy) |
|
|
211
|
+
| **Gateway** (`agent-gateway gateway`) | HTTP APIs, key kept from the agent | routes, environment, key custody, approval (off when the route file holds keys); no limits or effect claim of its own | [gateway guide](docs/gateway-deployment.md) |
|
|
212
|
+
|
|
213
|
+
For full checks *and* key custody, put the gateway behind the proxy
|
|
214
|
+
([how](docs/gateway-deployment.md#behind-the-mcp-proxy)). Package layout:
|
|
215
|
+
[architecture](docs/architecture.md).
|
|
216
|
+
|
|
217
|
+
## 6. Execution flow
|
|
218
|
+
|
|
219
|
+
Every call goes through `enforce()` in this order. Nothing reaches the tool until
|
|
220
|
+
all checks pass, and every outcome is recorded.
|
|
221
|
+
|
|
222
|
+
```mermaid
|
|
223
|
+
flowchart TD
|
|
224
|
+
I{"Required inputs given?"} -->|no| Q[Stop and ask]
|
|
225
|
+
I -->|yes| K["Decide the risk<br/>(undeclared = destructive)"]
|
|
226
|
+
K --> L{"Within limits?"}
|
|
227
|
+
L -->|yes| E{"Right environment?"}
|
|
228
|
+
E -->|yes| P{"Not a read: exact approval?"}
|
|
229
|
+
P -->|yes| O{"Claimed before?"}
|
|
230
|
+
O -->|no, or failed before| R[Run it]
|
|
231
|
+
O -->|done| D[Return the earlier result]
|
|
232
|
+
O -->|pending| H[Held until a person settles it]
|
|
233
|
+
R -->|timeout or no answer| H
|
|
234
|
+
L -->|no| B[Block, with the reason]
|
|
235
|
+
E -->|no| B
|
|
236
|
+
P -->|no| A[Block, and request an approval]
|
|
237
|
+
R --> REC[(Record)]
|
|
238
|
+
D --> REC
|
|
239
|
+
H --> REC
|
|
240
|
+
B --> REC
|
|
241
|
+
A --> REC
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The approval loop and the held path, step by step:
|
|
245
|
+
[architecture](docs/architecture.md#the-approval-loop-step-by-step).
|
|
246
|
+
|
|
247
|
+
## 7. Implementation
|
|
248
|
+
|
|
249
|
+
| Feature | Main files |
|
|
250
|
+
|---|---|
|
|
251
|
+
| Check pipeline | `engine/enforcement.py` |
|
|
252
|
+
| Sessions, wrapped tools, stop-and-ask | `runtime/session.py` |
|
|
253
|
+
| Approvals, limits | `policy/locks.py`, `policy/fuses.py` |
|
|
254
|
+
| Effect claims | `audit/receipts.py`, `policy/fingerprint.py` |
|
|
255
|
+
| MCP proxy, per-call risk | `integrations/mcp_proxy.py`, `guards/sql.py` |
|
|
256
|
+
| Gateway, key custody | `integrations/gateway.py`, `credential/` |
|
|
257
|
+
| Redaction | `guards/redaction.py` |
|
|
258
|
+
|
|
259
|
+
Wrap a tool and give the agent the wrapped version:
|
|
260
|
+
|
|
261
|
+
~~~python
|
|
262
|
+
from agent_action_gateway import session
|
|
263
|
+
|
|
264
|
+
def drop_table(table: str, intent_key: str = "") -> dict:
|
|
265
|
+
# Your real code. Pass `intent_key` to your provider as an idempotency key.
|
|
266
|
+
return {"dropped": table}
|
|
267
|
+
|
|
268
|
+
with session(environment="prod") as ctx:
|
|
269
|
+
drop = ctx.tool(drop_table, action="db.drop_table", risk="destructive")
|
|
270
|
+
|
|
271
|
+
drop(table="users") # blocked: needs approval
|
|
272
|
+
|
|
273
|
+
approval = ctx.request_approval("db.drop_table", {"table": "users"})
|
|
274
|
+
ctx.approve(approval.approval_id, "on-call engineer")
|
|
275
|
+
drop(table="orders", approval_id=approval.approval_id) # blocked: approval was for "users"
|
|
276
|
+
drop(table="users", approval_id=approval.approval_id) # allowed, and only once
|
|
277
|
+
~~~
|
|
278
|
+
|
|
279
|
+
Your agent is any function that takes the task and the tools:
|
|
280
|
+
|
|
281
|
+
~~~python
|
|
282
|
+
result = ctx.run(agent, task, tools={"drop_table": drop})
|
|
283
|
+
result["status"] # "blocked" if any action was refused
|
|
284
|
+
~~~
|
|
285
|
+
|
|
286
|
+
More: [SDK guide](docs/sdk.md).
|
|
287
|
+
|
|
288
|
+
## 8. Technical decisions
|
|
289
|
+
|
|
290
|
+
| Decision | Why | Trade-off |
|
|
291
|
+
|---|---|---|
|
|
292
|
+
| Unknown means destructive | a forgotten tool must not run freely | new tools need a rule or an approval |
|
|
293
|
+
| Approval used once, for exact arguments | it cannot be reused for another action | a retry after a failure needs a new approval |
|
|
294
|
+
| Claim the effect before running | the only way to catch a repeat after a crash | needs a store that survives restarts |
|
|
295
|
+
| A proxy instead of changing MCP servers | works with servers you do not control | calls that skip the proxy are not checked |
|
|
296
|
+
| Keys in a separate gateway | an agent cannot leak a key it never had | one more service to run |
|
|
297
|
+
| MCP written without the SDK | no dependencies, full control in a security proxy; tested against the official SDK client | we follow MCP spec changes ourselves |
|
|
298
|
+
| Built-in release gate, not promptfoo or DeepEval | it reads the gateway's own records: blocked, approved and repeated actions | fewer features than those tools |
|
|
299
|
+
|
|
300
|
+
## 9. Failures, security and limits
|
|
301
|
+
|
|
302
|
+
- **Unknown result:** a timeout, a dropped connection, a 5xx or a crash mid-call
|
|
303
|
+
may have landed, so the action is held and never repeated silently; settle it
|
|
304
|
+
with `agent-gateway receipts`. A failure that proves nothing happened (a
|
|
305
|
+
refused connection, a 4xx) may be retried, with the same intent key
|
|
306
|
+
([details](docs/receipt-guarantees.md#which-failures-may-be-retried)).
|
|
307
|
+
- **Dead MCP server:** restarted (at most 3 times a minute), tools re-checked
|
|
308
|
+
against the pins. A broken config edit keeps the last good config.
|
|
309
|
+
- **Proxy isolation:** run with `--http` as its own user or container, so the
|
|
310
|
+
agent cannot change its config or approvals; agents need a token
|
|
311
|
+
([details](docs/sdk.md#mcp-proxy)).
|
|
312
|
+
- **Secrets:** records are redacted before they are written.
|
|
313
|
+
- **Dashboard:** needs the token printed at start (then a strict cookie);
|
|
314
|
+
refuses non-local addresses without one; every form has CSRF and origin checks.
|
|
315
|
+
Approver names are typed, not verified.
|
|
316
|
+
- **Gateway:** refuses unregistered routes, hosts not on the allow-list, and
|
|
317
|
+
names that resolve to private addresses.
|
|
318
|
+
|
|
319
|
+
**Limits:** it checks actions, not reasoning. It cannot detect a guessed value.
|
|
320
|
+
Only calls through the checkpoint are checked: an agent with a terminal can go
|
|
321
|
+
around it unless it runs where it has no keys and no direct network route to
|
|
322
|
+
your systems ([setups](docs/gateway-deployment.md#choosing-a-setup)). The SQL check cannot see inside
|
|
323
|
+
your own database functions. "Once" needs a provider idempotency key or lookup.
|
|
324
|
+
Not independently audited. ([full list](docs/gateway-deployment.md#known-limitations))
|
|
325
|
+
|
|
326
|
+
## 10. Testing
|
|
327
|
+
|
|
328
|
+
- About 675 automated tests, plus lint and type checks, in CI.
|
|
329
|
+
- `make proof`: 1,000 crashed retries cause **1** side effect; **0** destructive
|
|
330
|
+
actions run without a valid approval.
|
|
331
|
+
- Tried once with Claude Code against the MCP proxy (test tools); not yet with
|
|
332
|
+
Claude Desktop or Cursor. PostgreSQL tests need a test database.
|
|
333
|
+
|
|
334
|
+
## 11. Setup
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
pip install agent-action-gateway
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
| To | Run |
|
|
341
|
+
|---|---|
|
|
342
|
+
| check MCP tool calls | `agent-gateway mcp-proxy --config servers.json` |
|
|
343
|
+
| run the proxy as its own service | `agent-gateway mcp-proxy --config servers.json --http` |
|
|
344
|
+
| run the key-holding gateway | `agent-gateway gateway --config routes.json --db gateway.db` |
|
|
345
|
+
| approve, settle held actions, accept tools, see runs | `agent-gateway dashboard` |
|
|
346
|
+
| settle actions held with an unknown outcome | `agent-gateway receipts list` |
|
|
347
|
+
| find calls that skip the checkpoint | `agent-gateway check --app your_agent.py` (`--format json` for CI) |
|
|
348
|
+
| test a new agent version | `agent-gateway gate check --cases your-cases.json ...` ([guide](docs/evaluation.md)) |
|
|
349
|
+
|
|
350
|
+
Secrets come from environment variables: the upstream keys named in the route
|
|
351
|
+
file, `AGENT_GATEWAY_MASTER_KEY`, `AGENT_GATEWAY_DASHBOARD_TOKEN`,
|
|
352
|
+
`AGENT_GATEWAY_PROXY_TOKEN` (proxy over HTTP), and `${NAME}`
|
|
353
|
+
in the proxy config. Run the gateway and the proxy where the agent cannot read
|
|
354
|
+
their keys, config or approvals (separate user, container or host).
|
|
355
|
+
[`deploy/`](deploy/) has a Compose setup for each, and `make verify-boundary` /
|
|
356
|
+
`make verify-proxy-boundary` check it from the agent's side; see the
|
|
357
|
+
[gateway guide](docs/gateway-deployment.md).
|
|
358
|
+
|
|
359
|
+
Develop: `pip install -e ".[dev]"`, then `make verify` and `make proof`.
|
|
360
|
+
|
|
361
|
+
## Documentation
|
|
362
|
+
|
|
363
|
+
| Guide | Read it for |
|
|
364
|
+
|---|---|
|
|
365
|
+
| [SDK guide](docs/sdk.md) | the library, approvals, limits, stop-and-ask, the [MCP proxy](docs/sdk.md#mcp-proxy) (rules, per-call risk, pinning, HTTP mode) |
|
|
366
|
+
| [Gateway guide](docs/gateway-deployment.md) | holding keys, deployment setups, checking your deployment, known limitations |
|
|
367
|
+
| [Receipt guarantees](docs/receipt-guarantees.md) | exactly what "once only" means |
|
|
368
|
+
| [Evaluation guide](docs/evaluation.md) | the release gate, `gate online`, `path`, `wall` |
|
|
369
|
+
| [Architecture](docs/architecture.md) | how the package is organized |
|
|
370
|
+
| [`deploy/`](deploy/) | Docker Compose for the gateway and the proxy, Kubernetes and systemd examples |
|
|
371
|
+
|
|
372
|
+
## License
|
|
373
|
+
|
|
374
|
+
MIT
|