agentbreak 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AgentBreak contributors
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,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentbreak
3
+ Version: 0.1.0
4
+ Summary: Minimal chaos proxy for OpenAI-compatible LLM apps.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/mnvsk97/agentbreak
7
+ Project-URL: Repository, https://github.com/mnvsk97/agentbreak
8
+ Project-URL: Issues, https://github.com/mnvsk97/agentbreak/issues
9
+ Keywords: llm,openai,proxy,chaos-testing,resilience
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: fastapi>=0.115.0
21
+ Requires-Dist: httpx>=0.27.0
22
+ Requires-Dist: pyyaml>=6.0.0
23
+ Requires-Dist: typer>=0.12.0
24
+ Requires-Dist: uvicorn>=0.30.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # AgentBreak
30
+
31
+ AgentBreak helps you test what your app does when an AI provider is slow, flaky, or down.
32
+
33
+ In simple terms:
34
+
35
+ - put AgentBreak between your app and OpenAI-compatible APIs
36
+ - tell AgentBreak to randomly fail some requests, slow some down, or return rate limits
37
+ - see whether your app retries, falls back, or breaks
38
+
39
+ This is useful because provider outages are normal, not rare.
40
+
41
+ ```mermaid
42
+ flowchart LR
43
+ subgraph Mock["Mock Mode"]
44
+ A1["Your app"] --> B1["AgentBreak"]
45
+ B1 --> C1["Fake AI response<br/>or injected failure"]
46
+ end
47
+
48
+ subgraph Proxy["Proxy Mode"]
49
+ A2["Your app"] --> B2["AgentBreak"]
50
+ B2 -->|usually| C2["Real AI provider"]
51
+ B2 -->|sometimes| D2["Injected failure<br/>slowdown / 429 / 500"]
52
+ end
53
+ ```
54
+
55
+ Provider outages, slowdowns, rate limits, and partial failures happen regularly. That is the reason this tool exists: you should be able to test them before your users find them for you.
56
+
57
+ If you know Toxiproxy, AgentBreak is the same basic idea for LLM APIs: it injects OpenAI-style failures, latency, and weighted fault scenarios so you can test retries, fallbacks, and resilience logic.
58
+
59
+ AgentBreak can run in two modes:
60
+
61
+ - `proxy`: send requests to the real provider, but occasionally simulate failures on the way
62
+ - `mock`: do not call a real provider; return a tiny fake response unless a failure is injected
63
+
64
+ When you stop it, AgentBreak prints a simple scorecard showing how your app handled those failures.
65
+
66
+ ## Quick Start
67
+
68
+ Fastest way to try it, with no real provider needed:
69
+
70
+ ```bash
71
+ pip install -e .
72
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
73
+ ```
74
+
75
+ Then point your app at AgentBreak instead of directly at OpenAI:
76
+
77
+ ```bash
78
+ export OPENAI_BASE_URL=http://localhost:5000/v1
79
+ ```
80
+
81
+ ## Install
82
+
83
+ ```bash
84
+ pip install -e .
85
+ ```
86
+
87
+ Run it with:
88
+
89
+ ```bash
90
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
91
+ ```
92
+
93
+ Run tests with:
94
+
95
+ ```bash
96
+ pip install -e '.[dev]'
97
+ pytest -q
98
+ ```
99
+
100
+ ## Config
101
+
102
+ AgentBreak will automatically load `config.yaml` from the current directory if it exists.
103
+
104
+ You can also pass a custom file:
105
+
106
+ ```bash
107
+ agentbreak start --config agentbreak.yaml
108
+ ```
109
+
110
+ CLI flags override YAML values.
111
+
112
+ You can also set `request_count` in `config.yaml` for the included example apps. They will send that many requests to AgentBreak unless `AGENTBREAK_REQUEST_COUNT` is set.
113
+
114
+ Quick start:
115
+
116
+ ```bash
117
+ cp config.example.yaml config.yaml
118
+ agentbreak start
119
+ ```
120
+
121
+ See `config.example.yaml`.
122
+
123
+ ## Real Provider Mode
124
+
125
+ ```bash
126
+ agentbreak start --mode proxy --upstream-url https://api.openai.com --scenario mixed-transient --fail-rate 0.2
127
+ ```
128
+
129
+ This forwards traffic to the real provider, but injects failures along the way.
130
+
131
+ Point your app at AgentBreak:
132
+
133
+ ```bash
134
+ export OPENAI_BASE_URL=http://localhost:5000/v1
135
+ ```
136
+
137
+ ## Fake Provider Mode
138
+
139
+ ```bash
140
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
141
+ ```
142
+
143
+ This never calls a real provider. It is useful for local testing, demos, and retry logic checks.
144
+
145
+ For SDKs that require an API key even in mock mode, use any dummy value:
146
+
147
+ ```bash
148
+ export OPENAI_API_KEY=dummy
149
+ ```
150
+
151
+ ## Exact Failure Mix
152
+
153
+ If you want a very specific test, you can choose the exact mix of failures:
154
+
155
+ ```bash
156
+ agentbreak start --mode proxy --upstream-url https://api.openai.com --faults 500=0.30,429=0.45
157
+ ```
158
+
159
+ That means:
160
+
161
+ - `30%` of requests get `500`
162
+ - `45%` of requests get `429`
163
+ - the rest pass through normally
164
+
165
+ AgentBreak currently:
166
+
167
+ - handles `POST /v1/chat/completions`
168
+ - can inject `400, 401, 403, 404, 413, 429, 500, 503`
169
+ - can inject latency
170
+ - tracks duplicate requests
171
+ - prints a resilience scorecard on shutdown
172
+
173
+ ```bash
174
+ curl http://localhost:5000/_agentbreak/scorecard
175
+ curl http://localhost:5000/_agentbreak/requests
176
+ ```
177
+
178
+ ## Reading The Scorecard
179
+
180
+ The scorecard is a quick signal, not a perfect pass/fail oracle.
181
+
182
+ - `duplicate_requests` means AgentBreak saw the same request body more than once
183
+ - `suspected_loops` means AgentBreak saw the same request body at least three times
184
+
185
+ That can indicate a real problem such as:
186
+
187
+ - a retry loop with no backoff
188
+ - an app resending the same request after an error
189
+ - a framework getting stuck and replaying work
190
+
191
+ But it can also happen during normal agent execution. Some agent frameworks make repeated underlying completion calls while planning, using tools, or recovering from intermediate steps.
192
+
193
+ So:
194
+
195
+ - treat high duplicate counts as a clue to inspect
196
+ - use `/_agentbreak/requests` to see what was repeated
197
+ - do not assume every duplicate is a bug
198
+
199
+ ## Scenarios
200
+
201
+ - `mixed-transient`
202
+ - `rate-limited`
203
+ - `provider-flaky`
204
+ - `non-retryable`
205
+ - `brownout`
206
+
207
+ ## Examples
208
+
209
+ Run the simple LangChain example:
210
+
211
+ ```bash
212
+ cd examples/simple_langchain
213
+ pip install -r requirements.txt
214
+ OPENAI_API_KEY=dummy OPENAI_BASE_URL=http://localhost:5000/v1 python main.py
215
+ ```
216
+
217
+ More examples: `examples/README.md`.
218
+
219
+ ## Codex Skill
220
+
221
+ A repo-local Codex skill is included at `skills/agentbreak-testing/SKILL.md`.
222
+
223
+ ## Install The Skill
224
+
225
+ If you already cloned this repo, install the skill into Codex by copying it into your local skills directory:
226
+
227
+ ```bash
228
+ mkdir -p ~/.codex/skills/agentbreak-testing
229
+ cp skills/agentbreak-testing/SKILL.md ~/.codex/skills/agentbreak-testing/SKILL.md
230
+ ```
231
+
232
+ Then restart Codex so it reloads local skills.
233
+
234
+ ## Use The Skill
235
+
236
+ Ask for it in plain English by name. For example:
237
+
238
+ ```text
239
+ Use the agentbreak-testing skill to run the simple_langchain example in mock mode with request_count 10.
240
+ ```
241
+
242
+ Or:
243
+
244
+ ```text
245
+ Use the agentbreak-testing skill to run proxy mode against https://api.openai.com and summarize the scorecard.
246
+ ```
247
+
248
+ You can also ask more generally:
249
+
250
+ - `Use the agentbreak-testing skill to test my app against rate limits.`
251
+ - `Use the agentbreak-testing skill to run AgentBreak in mock mode and inspect the scorecard.`
252
+ - `Use the agentbreak-testing skill to run the simple_langchain example with request_count 10.`
253
+
254
+ What the skill does:
255
+
256
+ - starts AgentBreak in `mock` or `proxy` mode
257
+ - points your app at `OPENAI_BASE_URL`
258
+ - runs your target command or example app
259
+ - checks `/_agentbreak/scorecard` and `/_agentbreak/requests`
260
+ - summarizes resilience signals like retries, duplicates, and failures
261
+
262
+ This repo is a local single-skill repo, not a published multi-skill registry like [truefoundry/tfy-agent-skills](https://github.com/truefoundry/tfy-agent-skills). So the install flow here is a local copy, not `npx skills add ...`.
263
+
264
+ Get started locally:
265
+
266
+ ```bash
267
+ python3 -m venv .venv
268
+ source .venv/bin/activate
269
+ pip install -e '.[dev]' -r examples/simple_langchain/requirements.txt
270
+ cp config.example.yaml config.yaml
271
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0
272
+ ```
273
+
274
+ ## Project Status
275
+
276
+ AgentBreak is currently an early-stage developer tool. Expect the API surface and scorecard heuristics to evolve.
277
+
278
+ ## Contributing
279
+
280
+ See `CONTRIBUTING.md`.
281
+
282
+ ## Security
283
+
284
+ See `SECURITY.md`.
285
+
286
+ ## License
287
+
288
+ MIT. See `LICENSE`.
@@ -0,0 +1,260 @@
1
+ # AgentBreak
2
+
3
+ AgentBreak helps you test what your app does when an AI provider is slow, flaky, or down.
4
+
5
+ In simple terms:
6
+
7
+ - put AgentBreak between your app and OpenAI-compatible APIs
8
+ - tell AgentBreak to randomly fail some requests, slow some down, or return rate limits
9
+ - see whether your app retries, falls back, or breaks
10
+
11
+ This is useful because provider outages are normal, not rare.
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ subgraph Mock["Mock Mode"]
16
+ A1["Your app"] --> B1["AgentBreak"]
17
+ B1 --> C1["Fake AI response<br/>or injected failure"]
18
+ end
19
+
20
+ subgraph Proxy["Proxy Mode"]
21
+ A2["Your app"] --> B2["AgentBreak"]
22
+ B2 -->|usually| C2["Real AI provider"]
23
+ B2 -->|sometimes| D2["Injected failure<br/>slowdown / 429 / 500"]
24
+ end
25
+ ```
26
+
27
+ Provider outages, slowdowns, rate limits, and partial failures happen regularly. That is the reason this tool exists: you should be able to test them before your users find them for you.
28
+
29
+ If you know Toxiproxy, AgentBreak is the same basic idea for LLM APIs: it injects OpenAI-style failures, latency, and weighted fault scenarios so you can test retries, fallbacks, and resilience logic.
30
+
31
+ AgentBreak can run in two modes:
32
+
33
+ - `proxy`: send requests to the real provider, but occasionally simulate failures on the way
34
+ - `mock`: do not call a real provider; return a tiny fake response unless a failure is injected
35
+
36
+ When you stop it, AgentBreak prints a simple scorecard showing how your app handled those failures.
37
+
38
+ ## Quick Start
39
+
40
+ Fastest way to try it, with no real provider needed:
41
+
42
+ ```bash
43
+ pip install -e .
44
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
45
+ ```
46
+
47
+ Then point your app at AgentBreak instead of directly at OpenAI:
48
+
49
+ ```bash
50
+ export OPENAI_BASE_URL=http://localhost:5000/v1
51
+ ```
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install -e .
57
+ ```
58
+
59
+ Run it with:
60
+
61
+ ```bash
62
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
63
+ ```
64
+
65
+ Run tests with:
66
+
67
+ ```bash
68
+ pip install -e '.[dev]'
69
+ pytest -q
70
+ ```
71
+
72
+ ## Config
73
+
74
+ AgentBreak will automatically load `config.yaml` from the current directory if it exists.
75
+
76
+ You can also pass a custom file:
77
+
78
+ ```bash
79
+ agentbreak start --config agentbreak.yaml
80
+ ```
81
+
82
+ CLI flags override YAML values.
83
+
84
+ You can also set `request_count` in `config.yaml` for the included example apps. They will send that many requests to AgentBreak unless `AGENTBREAK_REQUEST_COUNT` is set.
85
+
86
+ Quick start:
87
+
88
+ ```bash
89
+ cp config.example.yaml config.yaml
90
+ agentbreak start
91
+ ```
92
+
93
+ See `config.example.yaml`.
94
+
95
+ ## Real Provider Mode
96
+
97
+ ```bash
98
+ agentbreak start --mode proxy --upstream-url https://api.openai.com --scenario mixed-transient --fail-rate 0.2
99
+ ```
100
+
101
+ This forwards traffic to the real provider, but injects failures along the way.
102
+
103
+ Point your app at AgentBreak:
104
+
105
+ ```bash
106
+ export OPENAI_BASE_URL=http://localhost:5000/v1
107
+ ```
108
+
109
+ ## Fake Provider Mode
110
+
111
+ ```bash
112
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0.2
113
+ ```
114
+
115
+ This never calls a real provider. It is useful for local testing, demos, and retry logic checks.
116
+
117
+ For SDKs that require an API key even in mock mode, use any dummy value:
118
+
119
+ ```bash
120
+ export OPENAI_API_KEY=dummy
121
+ ```
122
+
123
+ ## Exact Failure Mix
124
+
125
+ If you want a very specific test, you can choose the exact mix of failures:
126
+
127
+ ```bash
128
+ agentbreak start --mode proxy --upstream-url https://api.openai.com --faults 500=0.30,429=0.45
129
+ ```
130
+
131
+ That means:
132
+
133
+ - `30%` of requests get `500`
134
+ - `45%` of requests get `429`
135
+ - the rest pass through normally
136
+
137
+ AgentBreak currently:
138
+
139
+ - handles `POST /v1/chat/completions`
140
+ - can inject `400, 401, 403, 404, 413, 429, 500, 503`
141
+ - can inject latency
142
+ - tracks duplicate requests
143
+ - prints a resilience scorecard on shutdown
144
+
145
+ ```bash
146
+ curl http://localhost:5000/_agentbreak/scorecard
147
+ curl http://localhost:5000/_agentbreak/requests
148
+ ```
149
+
150
+ ## Reading The Scorecard
151
+
152
+ The scorecard is a quick signal, not a perfect pass/fail oracle.
153
+
154
+ - `duplicate_requests` means AgentBreak saw the same request body more than once
155
+ - `suspected_loops` means AgentBreak saw the same request body at least three times
156
+
157
+ That can indicate a real problem such as:
158
+
159
+ - a retry loop with no backoff
160
+ - an app resending the same request after an error
161
+ - a framework getting stuck and replaying work
162
+
163
+ But it can also happen during normal agent execution. Some agent frameworks make repeated underlying completion calls while planning, using tools, or recovering from intermediate steps.
164
+
165
+ So:
166
+
167
+ - treat high duplicate counts as a clue to inspect
168
+ - use `/_agentbreak/requests` to see what was repeated
169
+ - do not assume every duplicate is a bug
170
+
171
+ ## Scenarios
172
+
173
+ - `mixed-transient`
174
+ - `rate-limited`
175
+ - `provider-flaky`
176
+ - `non-retryable`
177
+ - `brownout`
178
+
179
+ ## Examples
180
+
181
+ Run the simple LangChain example:
182
+
183
+ ```bash
184
+ cd examples/simple_langchain
185
+ pip install -r requirements.txt
186
+ OPENAI_API_KEY=dummy OPENAI_BASE_URL=http://localhost:5000/v1 python main.py
187
+ ```
188
+
189
+ More examples: `examples/README.md`.
190
+
191
+ ## Codex Skill
192
+
193
+ A repo-local Codex skill is included at `skills/agentbreak-testing/SKILL.md`.
194
+
195
+ ## Install The Skill
196
+
197
+ If you already cloned this repo, install the skill into Codex by copying it into your local skills directory:
198
+
199
+ ```bash
200
+ mkdir -p ~/.codex/skills/agentbreak-testing
201
+ cp skills/agentbreak-testing/SKILL.md ~/.codex/skills/agentbreak-testing/SKILL.md
202
+ ```
203
+
204
+ Then restart Codex so it reloads local skills.
205
+
206
+ ## Use The Skill
207
+
208
+ Ask for it in plain English by name. For example:
209
+
210
+ ```text
211
+ Use the agentbreak-testing skill to run the simple_langchain example in mock mode with request_count 10.
212
+ ```
213
+
214
+ Or:
215
+
216
+ ```text
217
+ Use the agentbreak-testing skill to run proxy mode against https://api.openai.com and summarize the scorecard.
218
+ ```
219
+
220
+ You can also ask more generally:
221
+
222
+ - `Use the agentbreak-testing skill to test my app against rate limits.`
223
+ - `Use the agentbreak-testing skill to run AgentBreak in mock mode and inspect the scorecard.`
224
+ - `Use the agentbreak-testing skill to run the simple_langchain example with request_count 10.`
225
+
226
+ What the skill does:
227
+
228
+ - starts AgentBreak in `mock` or `proxy` mode
229
+ - points your app at `OPENAI_BASE_URL`
230
+ - runs your target command or example app
231
+ - checks `/_agentbreak/scorecard` and `/_agentbreak/requests`
232
+ - summarizes resilience signals like retries, duplicates, and failures
233
+
234
+ This repo is a local single-skill repo, not a published multi-skill registry like [truefoundry/tfy-agent-skills](https://github.com/truefoundry/tfy-agent-skills). So the install flow here is a local copy, not `npx skills add ...`.
235
+
236
+ Get started locally:
237
+
238
+ ```bash
239
+ python3 -m venv .venv
240
+ source .venv/bin/activate
241
+ pip install -e '.[dev]' -r examples/simple_langchain/requirements.txt
242
+ cp config.example.yaml config.yaml
243
+ agentbreak start --mode mock --scenario mixed-transient --fail-rate 0
244
+ ```
245
+
246
+ ## Project Status
247
+
248
+ AgentBreak is currently an early-stage developer tool. Expect the API surface and scorecard heuristics to evolve.
249
+
250
+ ## Contributing
251
+
252
+ See `CONTRIBUTING.md`.
253
+
254
+ ## Security
255
+
256
+ See `SECURITY.md`.
257
+
258
+ ## License
259
+
260
+ MIT. See `LICENSE`.
@@ -0,0 +1,3 @@
1
+ __all__ = ["__version__"]
2
+
3
+ __version__ = "0.1.0"