agentboxx 0.2.1__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.
- agentboxx-0.2.1/LICENSE +201 -0
- agentboxx-0.2.1/PKG-INFO +265 -0
- agentboxx-0.2.1/README.md +233 -0
- agentboxx-0.2.1/pyproject.toml +50 -0
- agentboxx-0.2.1/setup.cfg +4 -0
- agentboxx-0.2.1/src/agentbox/__init__.py +5 -0
- agentboxx-0.2.1/src/agentbox/agent.py +138 -0
- agentboxx-0.2.1/src/agentbox/cli.py +252 -0
- agentboxx-0.2.1/src/agentbox/docker_backend.py +167 -0
- agentboxx-0.2.1/src/agentbox/error_signatures.py +46 -0
- agentboxx-0.2.1/src/agentbox/executor.py +102 -0
- agentboxx-0.2.1/src/agentbox/loop_detector.py +71 -0
- agentboxx-0.2.1/src/agentbox/recorder.py +73 -0
- agentboxx-0.2.1/src/agentbox/redact.py +71 -0
- agentboxx-0.2.1/src/agentbox/report.py +266 -0
- agentboxx-0.2.1/src/agentbox/sandbox_stats.py +80 -0
- agentboxx-0.2.1/src/agentbox/signer.py +148 -0
- agentboxx-0.2.1/src/agentbox/streaming.py +133 -0
- agentboxx-0.2.1/src/agentbox/workspace.py +83 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/PKG-INFO +265 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/SOURCES.txt +43 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/dependency_links.txt +1 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/entry_points.txt +2 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/requires.txt +6 -0
- agentboxx-0.2.1/src/agentboxx.egg-info/top_level.txt +1 -0
- agentboxx-0.2.1/tests/test_agent.py +14 -0
- agentboxx-0.2.1/tests/test_audit_regressions.py +87 -0
- agentboxx-0.2.1/tests/test_cli.py +218 -0
- agentboxx-0.2.1/tests/test_container_user.py +54 -0
- agentboxx-0.2.1/tests/test_detector_signals.py +128 -0
- agentboxx-0.2.1/tests/test_docker_backend.py +16 -0
- agentboxx-0.2.1/tests/test_docker_events.py +29 -0
- agentboxx-0.2.1/tests/test_docker_limits.py +31 -0
- agentboxx-0.2.1/tests/test_error_signatures.py +75 -0
- agentboxx-0.2.1/tests/test_existing_log.py +23 -0
- agentboxx-0.2.1/tests/test_limits.py +83 -0
- agentboxx-0.2.1/tests/test_live_model.py +61 -0
- agentboxx-0.2.1/tests/test_loop_detector.py +20 -0
- agentboxx-0.2.1/tests/test_manifest.py +68 -0
- agentboxx-0.2.1/tests/test_redact.py +81 -0
- agentboxx-0.2.1/tests/test_report.py +160 -0
- agentboxx-0.2.1/tests/test_sandbox_stats.py +97 -0
- agentboxx-0.2.1/tests/test_schema.py +199 -0
- agentboxx-0.2.1/tests/test_signer.py +29 -0
- agentboxx-0.2.1/tests/test_workspace.py +125 -0
agentboxx-0.2.1/LICENSE
ADDED
|
@@ -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
|
|
95
|
+
Derivative 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 [yyyy] [name of copyright owner]
|
|
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.
|
agentboxx-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentboxx
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A tamper-evident flight recorder for AI agents
|
|
5
|
+
Author-email: Prathmesh Kokate <prathmeshkokate775@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Prathmesh010190/Agentboxx
|
|
8
|
+
Project-URL: Repository, https://github.com/Prathmesh010190/Agentboxx
|
|
9
|
+
Project-URL: Issues, https://github.com/Prathmesh010190/Agentboxx/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/Prathmesh010190/Agentboxx/tree/main/docs
|
|
11
|
+
Keywords: ai,agents,security,audit,flight-recorder,tamper-evident,sandbox
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Classifier: Topic :: System :: Logging
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff; extra == "dev"
|
|
30
|
+
Requires-Dist: jsonschema; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
|
|
35
|
+
# agentbox
|
|
36
|
+
|
|
37
|
+
**A tamper-evident flight recorder for AI agents.**
|
|
38
|
+
|
|
39
|
+
Run agent commands in an isolated sandbox, record what actually happened, sign every record, and catch agents that get stuck.
|
|
40
|
+
|
|
41
|
+
[](https://github.com/Prathmesh010190/Agentboxx/actions/workflows/ci.yml)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+

|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
> [!NOTE]
|
|
49
|
+
> **v0.2 MVP.** Working prototype validated end-to-end with sandboxed execution, cryptographic signing, loop detection, and live model execution. Interfaces may evolve before v1.0. Known gaps are listed under [Limitations](#limitations).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Why agentbox
|
|
54
|
+
|
|
55
|
+
Most agent tooling records what the agent *says* it did, from inside the agent's own process. agentbox observes from the outside.
|
|
56
|
+
|
|
57
|
+
| | What it gives you |
|
|
58
|
+
|---|---|
|
|
59
|
+
| **Host-side capture** | Output, exit codes and timing are recorded by the host, not reported by the agent. |
|
|
60
|
+
| **Tamper-evident logs** | Every record is hash-chained and HMAC-signed with a key that never enters the sandbox. Edits, deletions and reordering are detected by `agentbox verify`. |
|
|
61
|
+
| **State-aware loop detection** | A repeated command only counts when the workspace did not change, which separates retrying from making progress. |
|
|
62
|
+
| **Hint feedback** | When the detector fires, a hint is added to the agent's next observation so it can change approach. |
|
|
63
|
+
| **Hardened sandbox** | Docker backend with no network, read-only root filesystem, dropped capabilities, non-root user and resource limits. |
|
|
64
|
+
|
|
65
|
+
## Architecture
|
|
66
|
+
|
|
67
|
+
<p align="center">
|
|
68
|
+
<img src="docs/architecture.svg" alt="agentbox architecture: model, Docker sandbox, recorder, signed log, and loop detector feeding hints back to the model" width="900">
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
| Module | Role |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `signer.py` | Hash-chained, HMAC-signed event log and `verify_file` |
|
|
74
|
+
| `executor.py` | Local command runner, error fingerprints, workspace hashing |
|
|
75
|
+
| `docker_backend.py` | Runs commands in a locked-down container |
|
|
76
|
+
| `loop_detector.py` | Exact repeat, repeated error, no-progress and cycle detection |
|
|
77
|
+
| `recorder.py` | Main API: `Recorder.run(command)` |
|
|
78
|
+
| `agent.py` | Minimal ReAct-style loop that feeds detector hints back to the model |
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
Requires Python 3.10+. Docker is optional and used by the sandbox demos.
|
|
83
|
+
|
|
84
|
+
~~~bash
|
|
85
|
+
pip install agentboxx
|
|
86
|
+
~~~
|
|
87
|
+
|
|
88
|
+
Or install from source:
|
|
89
|
+
|
|
90
|
+
~~~bash
|
|
91
|
+
git clone https://github.com/Prathmesh010190/Agentboxx.git
|
|
92
|
+
cd Agentboxx
|
|
93
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
94
|
+
pip install -e ".[dev]"
|
|
95
|
+
pytest
|
|
96
|
+
~~~
|
|
97
|
+
|
|
98
|
+
Try it with one command (no Docker, no API key, nothing left behind):
|
|
99
|
+
|
|
100
|
+
~~~bash
|
|
101
|
+
agentbox demo
|
|
102
|
+
~~~
|
|
103
|
+
|
|
104
|
+
Run the demos from the repo:
|
|
105
|
+
|
|
106
|
+
~~~bash
|
|
107
|
+
python examples/demo_agent.py # stuck-agent demo (local backend)
|
|
108
|
+
python examples/demo_docker.py # shows what the Docker sandbox blocks
|
|
109
|
+
python examples/demo_agent_loop.py # full pipeline: detect, hint, recover
|
|
110
|
+
|
|
111
|
+
agentbox report runs/agent-demo.ndjson # readable summary
|
|
112
|
+
agentbox verify runs/agent-demo.ndjson # integrity check
|
|
113
|
+
agentbox list # every log in ./runs: session, start time, steps, verifies?
|
|
114
|
+
agentbox --version
|
|
115
|
+
~~~
|
|
116
|
+
|
|
117
|
+
`report` uses color for errors and warnings when writing to a terminal. Set `NO_COLOR=1` to turn it off. It supports `--format text|json|html` (default: `text`) and `--output <file>` (or `-o`) to export reports; HTML reports are completely self-contained with no external assets.
|
|
118
|
+
|
|
119
|
+
### Example: a stuck agent recovers
|
|
120
|
+
|
|
121
|
+
The scripted agent repeats a failing command. After the third identical failure on an unchanged workspace, the detector raises warnings and the next observation carries a hint:
|
|
122
|
+
|
|
123
|
+
~~~text
|
|
124
|
+
[2] Run it.
|
|
125
|
+
$ python3 main.py -> exit 1
|
|
126
|
+
[3] Run it.
|
|
127
|
+
$ python3 main.py -> exit 1
|
|
128
|
+
[4] Run it.
|
|
129
|
+
$ python3 main.py -> exit 1
|
|
130
|
+
!! warn: loop.exact
|
|
131
|
+
!! warn: loop.error_repeat
|
|
132
|
+
!! warn: loop.no_progress
|
|
133
|
+
[5] The hint is right: x = 0 causes the crash. Fix the value.
|
|
134
|
+
$ sed -i 's/x = 0/x = 2/' main.py -> exit 0
|
|
135
|
+
[6] Run it again.
|
|
136
|
+
$ python3 main.py -> exit 0
|
|
137
|
+
|
|
138
|
+
Result: {'reason': 'final_answer', 'final': 'Fixed the divide-by-zero; script prints 5.0.'}
|
|
139
|
+
~~~
|
|
140
|
+
|
|
141
|
+
### Example: tamper detection
|
|
142
|
+
|
|
143
|
+
Change any value in a log file and verification fails:
|
|
144
|
+
|
|
145
|
+
~~~text
|
|
146
|
+
$ agentbox verify runs/demo.ndjson
|
|
147
|
+
LOG HAS BEEN TAMPERED WITH OR IS CORRUPT:
|
|
148
|
+
- line 3: content was modified
|
|
149
|
+
~~~
|
|
150
|
+
|
|
151
|
+
## Use it in your own agent
|
|
152
|
+
|
|
153
|
+
~~~python
|
|
154
|
+
from agentbox import Recorder
|
|
155
|
+
from agentbox.docker_backend import DockerSandbox
|
|
156
|
+
|
|
157
|
+
sandbox = DockerSandbox("./workspace") # no network by default
|
|
158
|
+
sandbox.start()
|
|
159
|
+
rec = Recorder("my-session", workspace="./workspace", sandbox=sandbox)
|
|
160
|
+
|
|
161
|
+
result = rec.run("pytest -x", thought="Run the tests")
|
|
162
|
+
print(result["signals"]) # loop warnings, if any
|
|
163
|
+
|
|
164
|
+
rec.close("done") # also stops the container
|
|
165
|
+
~~~
|
|
166
|
+
|
|
167
|
+
`agentbox.agent.run_agent` wraps this in a ReAct-style loop. `ScriptedModel` needs no API key. `GeminiModel` connects to Google Gemini via standard-library REST (needs `GEMINI_API_KEY`, validated end-to-end). `AnthropicModel` is an optional adapter (`pip install anthropic`, set `ANTHROPIC_API_KEY`).
|
|
168
|
+
|
|
169
|
+
## What `agentbox verify` reports
|
|
170
|
+
|
|
171
|
+
| Result | Exit code | Meaning |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `OK` | 0 | Chain, signatures and the closing manifest all match |
|
|
174
|
+
| `TAMPERED` | 1 | A record was edited, removed or reordered, or the log no longer matches its signed manifest |
|
|
175
|
+
| `INCOMPLETE` | 2 | The log is intact so far but was never closed: a crash, a running session, or a removed tail |
|
|
176
|
+
| *(error)* | 3 | The file is missing, empty, a directory or unreadable. This is not a verdict on the log, and `report` uses the same code |
|
|
177
|
+
|
|
178
|
+
The manifest (`<session>.manifest.json`) is written when a session closes and records the final record count and hash, signed with the same key. The verifier requires the manifest: a closed session whose manifest is missing is reported as `INCOMPLETE`, and a truncated log whose manifest is still present is reported as `TAMPERED`. Anyone who can read the signing key can forge both files, so copy manifests somewhere the agent host cannot write to if that matters. Public-key signing, as used for Nanda Town's evidence attestations, would let third parties verify logs without holding a secret, and is a possible future change.
|
|
179
|
+
|
|
180
|
+
## Detection signals
|
|
181
|
+
|
|
182
|
+
| Signal | Meaning |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `loop.exact` | The same command was repeated on an unchanged workspace |
|
|
185
|
+
| `loop.error_repeat` | The same normalized error keeps recurring |
|
|
186
|
+
| `loop.no_progress` | Several steps failed while no files changed |
|
|
187
|
+
| `loop.cycle` | The agent alternates between the same few commands |
|
|
188
|
+
|
|
189
|
+
Warnings become hints for the model. Critical severity (for example five identical repeats) stops the run.
|
|
190
|
+
|
|
191
|
+
## Sandbox resource and crash events
|
|
192
|
+
|
|
193
|
+
With the Docker backend, the host records two extra signed events after each step: `sandbox.resource` (memory, CPU, process count) and `sandbox.crash` (an out-of-memory kill, or a container that stopped). Everything is read on the host through Docker, so the agent cannot influence it.
|
|
194
|
+
|
|
195
|
+
- Resource sampling adds about a second per step. Turn it off with `DockerSandbox(resource_stats=False)`.
|
|
196
|
+
- A sample is a snapshot after the step, not a peak.
|
|
197
|
+
- The local backend has no equivalent, and `agentbox report` does not show these events yet.
|
|
198
|
+
|
|
199
|
+
## Error signatures
|
|
200
|
+
|
|
201
|
+
Repeated-error detection compares normalized error signatures, so the same failure matches even when line numbers, file paths or runtime versions differ.
|
|
202
|
+
|
|
203
|
+
| Language | Recognized output | Signature class |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| Python | Tracebacks | Exception name, e.g. `ZeroDivisionError` |
|
|
206
|
+
| Node.js | Uncaught errors with stack frames | e.g. `TypeError`, `Error[ERR_MODULE_NOT_FOUND]` |
|
|
207
|
+
| Go | Panics, fatal errors, compile errors | `GoPanic`, `GoFatalError`, `GoCompileError` |
|
|
208
|
+
|
|
209
|
+
Anything else falls back to hashing the last lines of stderr. To add a language, see `src/agentbox/error_signatures.py`.
|
|
210
|
+
|
|
211
|
+
## Secret redaction
|
|
212
|
+
|
|
213
|
+
Commands, output and the model's reasoning are redacted **before** they are signed, because a signed record cannot be edited afterward. Recognized: private key blocks, AWS, GitHub, Slack and Google keys, `sk-` style API keys, JWTs, `Authorization` headers, passwords in URLs, and `NAME=value` where the name contains `password`, `secret`, `token` or `api_key`. Each step records only a count per pattern, never the value.
|
|
214
|
+
|
|
215
|
+
Limits to know about:
|
|
216
|
+
- Patterns are heuristics. They miss some secrets (for example a secret with no recognizable name or format) and sometimes hide harmless values such as a long `*_token=` setting.
|
|
217
|
+
- The command itself still runs with the real value. Only the **record** is redacted.
|
|
218
|
+
- With the agent loop, the model also receives the redacted output, so it cannot read a secret that a command printed.
|
|
219
|
+
- Files in the workspace are not logged, but anything a command prints from them is covered by these patterns only.
|
|
220
|
+
- Add your own patterns with `agentbox.redact.add_pattern(name, regex)`.
|
|
221
|
+
|
|
222
|
+
## Log format
|
|
223
|
+
|
|
224
|
+
The log format is documented in [docs/log-format.md](docs/log-format.md) and described by JSON Schemas ([record](docs/schema.json), [manifest](docs/manifest.schema.json)). [examples/verify_standalone.py](examples/verify_standalone.py) verifies a log using only the Python standard library, as an independent check that the spec is complete.
|
|
225
|
+
|
|
226
|
+
## Threat model
|
|
227
|
+
|
|
228
|
+
- **Docker backend:** commands run as a non-root user in a container with no network, a read-only root filesystem, all Linux capabilities dropped, `no-new-privileges`, and CPU, memory and process limits. The signing key and logs stay on the host and are never mounted into the container.
|
|
229
|
+
- **Local backend:** no isolation. The agent runs as your user and could read the signing key. Use it only for trusted experiments.
|
|
230
|
+
- Docker isolation is strong but not a perfect boundary. Run untrusted agents in a disposable VM.
|
|
231
|
+
- The log shows that records were not altered after writing. It does not prove the agent's intent, and it cannot see anything that bypasses the executor.
|
|
232
|
+
|
|
233
|
+
## Limitations
|
|
234
|
+
|
|
235
|
+
- Windows is experimental. The Docker backend no longer needs Unix user IDs and runs as user `1000:1000` in the container (override with `DockerSandbox(user=...)`), but it has not been run on real Windows hardware yet. It needs Docker Desktop with Linux containers. The local backend still needs `bash` (Git Bash), and on Windows a timeout kills only the direct child process.
|
|
236
|
+
- Detector thresholds are initial values, not calibrated on real agent traces.
|
|
237
|
+
- No network capture yet (the sandbox simply has no network).
|
|
238
|
+
- No semantic drift detection yet; detection is command and state based.
|
|
239
|
+
- Error signatures cover Python, Node.js and Go only. Other languages use a generic fallback.
|
|
240
|
+
|
|
241
|
+
## Roadmap
|
|
242
|
+
|
|
243
|
+
- [x] Signed, hash-chained event log with verification
|
|
244
|
+
- [x] Docker sandbox backend
|
|
245
|
+
- [x] Loop detection with hint feedback
|
|
246
|
+
- [x] ReAct-style agent loop
|
|
247
|
+
- [x] Stable error signatures for Python, Node.js and Go
|
|
248
|
+
- [x] Truncation detection with a signed closing manifest
|
|
249
|
+
- [x] Secret redaction before signing
|
|
250
|
+
- [ ] Output size cap and process-tree kill on timeout
|
|
251
|
+
- [x] Sandbox resource and crash events (Docker backend)
|
|
252
|
+
- [ ] Public-key signing so third parties can verify logs
|
|
253
|
+
- [x] Validate against a live model ([#5](https://github.com/Prathmesh010190/Agentboxx/issues/5))
|
|
254
|
+
- [ ] Network egress capture (design in [docs/network-egress.md](docs/network-egress.md))
|
|
255
|
+
- [ ] Semantic drift detector
|
|
256
|
+
- [ ] Session replay UI
|
|
257
|
+
- [ ] Threshold calibration on recorded sessions
|
|
258
|
+
|
|
259
|
+
## Contributing
|
|
260
|
+
|
|
261
|
+
Contributions are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md) and the issues labeled [`good first issue`](https://github.com/Prathmesh010190/Agentboxx/labels/good%20first%20issue).
|
|
262
|
+
|
|
263
|
+
## License
|
|
264
|
+
|
|
265
|
+
Apache-2.0. See [LICENSE](LICENSE).
|