agentbrake-sdk 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.
- agentbrake_sdk-0.1.0/.gitignore +11 -0
- agentbrake_sdk-0.1.0/CHANGELOG.md +30 -0
- agentbrake_sdk-0.1.0/GO-TO-MARKET.md +104 -0
- agentbrake_sdk-0.1.0/LICENSE +21 -0
- agentbrake_sdk-0.1.0/PKG-INFO +172 -0
- agentbrake_sdk-0.1.0/PROJECT-CONTEXT.md +117 -0
- agentbrake_sdk-0.1.0/README.md +145 -0
- agentbrake_sdk-0.1.0/RELEASE.md +52 -0
- agentbrake_sdk-0.1.0/WEBSITE-ARCHITECTURE.md +102 -0
- agentbrake_sdk-0.1.0/examples/README.md +40 -0
- agentbrake_sdk-0.1.0/examples/crewai_quickstart.py +67 -0
- agentbrake_sdk-0.1.0/examples/langchain_quickstart.py +100 -0
- agentbrake_sdk-0.1.0/pyproject.toml +38 -0
- agentbrake_sdk-0.1.0/src/agentbrake/__init__.py +57 -0
- agentbrake_sdk-0.1.0/src/agentbrake/core.py +193 -0
- agentbrake_sdk-0.1.0/src/agentbrake/crewai.py +239 -0
- agentbrake_sdk-0.1.0/src/agentbrake/langchain.py +248 -0
- agentbrake_sdk-0.1.0/tests/test_crewai.py +131 -0
- agentbrake_sdk-0.1.0/tests/test_engine.py +195 -0
- agentbrake_sdk-0.1.0/tests/test_langchain.py +127 -0
- agentbrake_sdk-0.1.0/tests/test_langchain_middleware.py +96 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to AgentBrake are documented here.
|
|
4
|
+
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [0.1.0] — unreleased
|
|
7
|
+
|
|
8
|
+
First public release.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Framework-agnostic engine** (`core`): live loop detection (identical
|
|
12
|
+
tool+args repeated N times), cost ceiling, step / tool-call / duration limits,
|
|
13
|
+
warn-at-80%, built-in pricing for GPT-4o, GPT-4, Claude, and Gemini.
|
|
14
|
+
- **LangChain 1.x support** via `LangChainBrakeMiddleware` — runs inside the
|
|
15
|
+
`create_agent` / LangGraph execution graph, so it can actually halt a run.
|
|
16
|
+
- **Classic LangChain (0.x) support** via the `LangChainBrake` callback for
|
|
17
|
+
`AgentExecutor`.
|
|
18
|
+
- **CrewAI 1.x support** via `CrewAIBrake` — patches every provider completion
|
|
19
|
+
class plus `ToolUsage._use`, with per-instance token-delta cost accounting.
|
|
20
|
+
- Runnable examples for both frameworks (LangChain demo needs no API key).
|
|
21
|
+
- Test suite covering the engine and both framework integrations against the
|
|
22
|
+
real `langchain` 1.3 and `crewai` 1.14 libraries.
|
|
23
|
+
|
|
24
|
+
### Notes
|
|
25
|
+
- On LangChain 1.x, callbacks are observe-only (the framework swallows
|
|
26
|
+
exceptions raised from them) — use `LangChainBrakeMiddleware` to brake, not the
|
|
27
|
+
callback. See the README for the 1.x-vs-0.x guidance.
|
|
28
|
+
- CrewAI cost accuracy depends on the provider reporting token usage; without it
|
|
29
|
+
the brake falls back to a rough length-based estimate while all other limits
|
|
30
|
+
(loop, steps, tool-calls, duration) remain exact.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 🚀 AgentBrake — Go-to-Market-Plan
|
|
2
|
+
|
|
3
|
+
*Wie du AgentBrake live bringst und die ersten Nutzer & Kunden gewinnst.*
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Die Grundregel für Entwickler-Tools
|
|
8
|
+
|
|
9
|
+
AgentBrake ist kein SaaS, das man über eine Landing Page verkauft. Es ist ein
|
|
10
|
+
Entwickler-Tool. Entwickler kaufen nicht wegen Marketing — sie übernehmen ein
|
|
11
|
+
Tool, weil es ihren echten Schmerz löst und andere Entwickler es empfehlen.
|
|
12
|
+
|
|
13
|
+
Deshalb ist die Reihenfolge: **erst Code & Verbreitung, dann Landing Page, dann Umsatz.**
|
|
14
|
+
Eine schöne Website für ein Tool, das auf GitHub 3 Stars hat, überzeugt niemanden.
|
|
15
|
+
Umgekehrt verkauft sich ein Tool mit 800 Stars fast von selbst.
|
|
16
|
+
|
|
17
|
+
Deine stärkste Waffe ist **eine Story**: der reale 47.000-Dollar-Loop. Die
|
|
18
|
+
verkauft das Produkt in einem Satz. Nutze sie überall.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Phase 1 — Fundament legen (Woche 1)
|
|
23
|
+
|
|
24
|
+
**Ziel:** Das Tool ist installierbar und auffindbar.
|
|
25
|
+
|
|
26
|
+
1. **CrewAI-Pfad echt testen** (siehe PROJECT-CONTEXT.md, offener Punkt #1).
|
|
27
|
+
Vor dem Launch muss beides nachweislich funktionieren.
|
|
28
|
+
2. **GitHub-Repo anlegen.** Code pushen. README ist schon launch-fertig.
|
|
29
|
+
- Repo-Beschreibung: „The emergency brake for multi-agent systems. Stop runaway LangChain & CrewAI agents before they burn your budget."
|
|
30
|
+
- Topics/Tags: `langchain`, `crewai`, `ai-agents`, `llm`, `cost-control`, `guardrails`, `finops`
|
|
31
|
+
3. **Auf PyPI veröffentlichen.** Dann ist `pip install agentbrake-sdk` weltweit live.
|
|
32
|
+
4. **Kurzes Demo-GIF/Video aufnehmen** (30-60 Sek): Terminal zeigt einen Loop,
|
|
33
|
+
die Kosten laufen hoch, AgentBrake schlägt zu. Das ist dein wichtigstes Asset —
|
|
34
|
+
es zeigt den „Aha"-Moment in Sekunden.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Phase 2 — Soft Launch in Communities (Woche 2-3)
|
|
39
|
+
|
|
40
|
+
**Ziel:** Erste echte Nutzer, erstes Feedback, erste GitHub-Stars.
|
|
41
|
+
|
|
42
|
+
Geh dorthin, wo LangChain/CrewAI-Entwickler über genau diesen Schmerz reden.
|
|
43
|
+
**Wichtig: erst Wert liefern, dann erst das Tool erwähnen.** Nicht spammen.
|
|
44
|
+
|
|
45
|
+
### Rented Channels (wo deine Käufer schon sind)
|
|
46
|
+
|
|
47
|
+
| Kanal | Was du postest | Aufhänger |
|
|
48
|
+
|-------|----------------|-----------|
|
|
49
|
+
| **r/LangChain** (Reddit) | „I built a one-line brake that stops runaway agent loops" + Demo-GIF | Der 47k-Loop |
|
|
50
|
+
| **r/CrewAI / r/AI_Agents** | Gleiche Story, CrewAI-fokussiert | Loop zwischen zwei Agenten |
|
|
51
|
+
| **Hacker News** (Show HN) | „Show HN: AgentBrake – stop runaway LangChain/CrewAI agents in real time" | Die Story + dass es Open Source ist |
|
|
52
|
+
| **LangChain Discord / CrewAI Discord** | Im #show-and-tell oder Hilfe-Channel, wenn jemand über Kosten klagt | Direkt auf konkreten Schmerz antworten |
|
|
53
|
+
| **X/Twitter** | Thread: „A LangChain agent once cost someone \$47.000 overnight. Here's the 1-line fix I built." | Story-Thread mit Demo-GIF am Ende |
|
|
54
|
+
|
|
55
|
+
### Die Hacker-News-„Show HN" ist dein wichtigster Moment
|
|
56
|
+
- Poste dienstags-donnerstags, früh US-Pazifik-Zeit (ca. 16-17 Uhr deutsche Zeit).
|
|
57
|
+
- Sei den ganzen Tag online und antworte auf JEDEN Kommentar.
|
|
58
|
+
- Sei ehrlich über den Stand („LangChain getestet, CrewAI frisch") — HN belohnt Ehrlichkeit, bestraft Hype.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Phase 3 — Momentum & erste Einnahmen (Monat 2-3)
|
|
63
|
+
|
|
64
|
+
**Ziel:** Aus Nutzern Fürsprecher machen, erste Zahlungsbereitschaft testen.
|
|
65
|
+
|
|
66
|
+
1. **Sammle Beweise.** Jeder, der sagt „das hat mir X gespart" → um ein kurzes
|
|
67
|
+
Zitat bitten. Diese Testimonials sind Gold für die Landing Page.
|
|
68
|
+
2. **Schreib einen ehrlichen Erfahrungs-Post:** „I open-sourced an agent brake.
|
|
69
|
+
Here's what 1.000 downloads taught me about runaway agents." → bringt Backlinks
|
|
70
|
+
und Glaubwürdigkeit.
|
|
71
|
+
3. **Product Hunt Launch**, sobald du GitHub-Traktion hast (nicht vorher).
|
|
72
|
+
Tagline-Vorschlag: „AgentBrake – The emergency brake for AI agents".
|
|
73
|
+
4. **Teste die bezahlte Idee.** Wenn genug Leute es nutzen: eine gehostete
|
|
74
|
+
Version mit Team-Dashboard, zentralen Limits über alle Agenten, Alerts.
|
|
75
|
+
Das ist, wofür Firmen zahlen — der Open-Source-Kern bleibt gratis.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Phase 4 — Auf den Radar der großen Firmen (Monat 4+)
|
|
80
|
+
|
|
81
|
+
Damit AgentBrake für eine Übernahme interessant wird, brauchst du genau das,
|
|
82
|
+
was Phase 1-3 aufbaut: **Nutzer, Downloads, einen Namen in der Nische.**
|
|
83
|
+
|
|
84
|
+
- Sprich auf Meetups/Konferenzen über „Runaway agents in production".
|
|
85
|
+
- Schreib Gastbeiträge in KI-Engineering-Newslettern.
|
|
86
|
+
- Tag relevante Leute bei LangChain Inc., Datadog, den Hyperscalern in deinen
|
|
87
|
+
Posts — nicht aufdringlich, aber sichtbar. Übernahmen beginnen oft damit,
|
|
88
|
+
dass ein Engineering-Leiter dein Tool schon kennt.
|
|
89
|
+
|
|
90
|
+
**Ehrliche Einordnung:** Eine Übernahme ist ein mögliches Ende, kein Plan, auf
|
|
91
|
+
den man bauen kann. Der realistische, in deiner Hand liegende Weg ist:
|
|
92
|
+
Open-Source-Verbreitung → bezahlte Cloud-Version → profitables kleines SaaS.
|
|
93
|
+
Eine Übernahme passiert *dann* von selbst, wenn überhaupt — weil du wertvoll
|
|
94
|
+
geworden bist, nicht weil du danach gefragt hast.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Die wichtigsten 3 Dinge, falls du nur Zeit für 3 hast
|
|
99
|
+
|
|
100
|
+
1. `pip install agentbrake-sdk` live bringen (GitHub + PyPI).
|
|
101
|
+
2. Das Demo-GIF mit der 47k-Story auf Hacker News + r/LangChain posten.
|
|
102
|
+
3. Auf jeden einzelnen Kommentar antworten und Feedback einbauen.
|
|
103
|
+
|
|
104
|
+
Alles andere folgt daraus.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentBrake
|
|
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,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentbrake-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The emergency brake for multi-agent systems. Stop runaway LangChain & CrewAI agents in real time — before 50 cents becomes $47,000.
|
|
5
|
+
Project-URL: Homepage, https://agentbrake.dev
|
|
6
|
+
Project-URL: Repository, https://github.com/marcoschulz7/agentbrake
|
|
7
|
+
Author: AgentBrake
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai-agents,cost-control,crewai,finops,guardrails,langchain,llm,observability
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: crewai>=0.80; extra == 'all'
|
|
19
|
+
Requires-Dist: langchain-core>=0.2; extra == 'all'
|
|
20
|
+
Provides-Extra: crewai
|
|
21
|
+
Requires-Dist: crewai>=0.80; extra == 'crewai'
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
24
|
+
Provides-Extra: langchain
|
|
25
|
+
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# 🛑 AgentBrake
|
|
29
|
+
|
|
30
|
+
**The emergency brake for multi-agent systems.**
|
|
31
|
+
Stop runaway LangChain & CrewAI agents in real time — *before* 50 cents turns into $47,000.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install agentbrake-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> The install name is `agentbrake-sdk`; you import it as `agentbrake`.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## The problem
|
|
42
|
+
|
|
43
|
+
In November 2025, four LangChain agents entered an infinite loop. They ran for 11 days. The bill was **$47,000**. Nobody noticed until it was over.
|
|
44
|
+
|
|
45
|
+
This is not rare. Autonomous agents fail *expensively* rather than loudly:
|
|
46
|
+
|
|
47
|
+
- An agent calls the same tool **14,000 times** with identical arguments.
|
|
48
|
+
- A planner expands one simple task into dozens of high-context subagent calls.
|
|
49
|
+
- A reasoning loop never hits its stopping condition and runs all night.
|
|
50
|
+
|
|
51
|
+
Observability tools **record** this. They don't **stop** it. By the time the alert fires — or someone reads it — the money is gone. The gap between "the alert fired" and "the run stopped" is exactly where the damage compounds.
|
|
52
|
+
|
|
53
|
+
**AgentBrake closes that gap. It intercepts, not just observes.**
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## How it works
|
|
58
|
+
|
|
59
|
+
AgentBrake hooks into your agent's execution and watches every step in real time. When a run crosses a limit you set, it raises a clean exception that **halts the agent before the next expensive call goes out.**
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from agentbrake import LangChainBrakeMiddleware
|
|
63
|
+
from langchain.agents import create_agent
|
|
64
|
+
|
|
65
|
+
agent = create_agent(
|
|
66
|
+
model, tools=tools,
|
|
67
|
+
middleware=[LangChainBrakeMiddleware(max_cost_usd=2.00, repeat_tool_limit=5)],
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
That's it. One line.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## What it catches
|
|
76
|
+
|
|
77
|
+
| Runaway pattern | How AgentBrake stops it |
|
|
78
|
+
|---|---|
|
|
79
|
+
| **Identical-tool loops** (same call, same args, over and over) | `repeat_tool_limit` — trips after N identical calls in a row |
|
|
80
|
+
| **Cost blowouts** (the $47k overnight run) | `max_cost_usd` — a hard ceiling, enforced live as tokens are spent |
|
|
81
|
+
| **Endless reasoning** (no stopping condition) | `max_steps` — caps total reasoning steps |
|
|
82
|
+
| **Tool-call storms** | `max_tool_calls` — caps total tool invocations |
|
|
83
|
+
| **Hung runs** | `max_duration_s` — wall-clock ceiling |
|
|
84
|
+
|
|
85
|
+
It warns at 80% of any limit, and stops at 100%.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## LangChain
|
|
90
|
+
|
|
91
|
+
LangChain has two agent stacks, and they intercept differently — AgentBrake
|
|
92
|
+
ships the right tool for each.
|
|
93
|
+
|
|
94
|
+
**LangChain 1.x** (`create_agent` / LangGraph) — use the middleware. It runs
|
|
95
|
+
inside the agent graph, so it can actually halt the run:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from agentbrake import LangChainBrakeMiddleware, AgentBrakeError
|
|
99
|
+
from langchain.agents import create_agent
|
|
100
|
+
|
|
101
|
+
agent = create_agent(
|
|
102
|
+
model, tools=tools,
|
|
103
|
+
middleware=[LangChainBrakeMiddleware(max_cost_usd=2.00, repeat_tool_limit=5, max_steps=30)],
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
agent.invoke({"messages": [("user", "...")]})
|
|
108
|
+
except AgentBrakeError as e:
|
|
109
|
+
print(f"Stopped safely: {e.reason}")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Classic `AgentExecutor`** (LangChain 0.x) — use the callback:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from agentbrake import LangChainBrake, AgentBrakeError
|
|
116
|
+
|
|
117
|
+
brake = LangChainBrake(
|
|
118
|
+
max_cost_usd=2.00,
|
|
119
|
+
repeat_tool_limit=5,
|
|
120
|
+
max_steps=30,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
try:
|
|
124
|
+
agent_executor.invoke({"input": "..."}, config={"callbacks": [brake]})
|
|
125
|
+
except AgentBrakeError as e:
|
|
126
|
+
print(f"Stopped safely: {e.reason}")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## CrewAI
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from agentbrake import CrewAIBrake, AgentBrakeError
|
|
133
|
+
|
|
134
|
+
CrewAIBrake(max_cost_usd=3.00, repeat_tool_limit=5).install()
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
crew.kickoff()
|
|
138
|
+
except AgentBrakeError as e:
|
|
139
|
+
print(f"Crew stopped safely: {e.reason}")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Live cost visibility
|
|
145
|
+
|
|
146
|
+
Every run prints where your money is going, step by step:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
[AgentBrake] step 1: web_search · running cost $0.0080
|
|
150
|
+
[AgentBrake] step 2: web_search · running cost $0.0160
|
|
151
|
+
[AgentBrake] ⚠️ approaching cost limit (1.60 of 2.00)
|
|
152
|
+
[AgentBrake] 🛑 STOPPED — loop detected: same tool call repeated 5× in a row
|
|
153
|
+
steps=5 tool_calls=5 llm_calls=4 tokens=9,200 cost=$0.032 elapsed=0.4s
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Pricing built in
|
|
159
|
+
|
|
160
|
+
AgentBrake ships with current pricing for GPT-4o, GPT-4, Claude (Opus/Sonnet/Haiku), and Gemini, so cost ceilings work out of the box. Override anytime with your own rates.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Why not just set a provider spend cap?
|
|
165
|
+
|
|
166
|
+
Provider caps are **monthly** and **account-wide** — they fire after the damage, across everything. AgentBrake is **per-run** and **in-process** — it stops *this* agent *now*, before the next call. It's the difference between a smoke alarm and a sprinkler.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT — free to use, including commercially.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# 📋 AgentBrake — Projekt-Kontext & Übergabe
|
|
2
|
+
|
|
3
|
+
*Dies ist der Übergabe-Brief. In Claude Code als Erstes lesen lassen, dann ist die neue Session sofort im Bild.*
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Was ist das hier?
|
|
8
|
+
|
|
9
|
+
**AgentBrake** — die Notbremse für Multi-Agenten-Systeme. Ein Python-Paket, das
|
|
10
|
+
Runaway-Loops in **LangChain** und **CrewAI** in Echtzeit stoppt, bevor aus
|
|
11
|
+
50 Cent ein 47.000-Dollar-Loop wird.
|
|
12
|
+
|
|
13
|
+
Das Produkt **existiert und funktioniert bereits** — es ist kein Konzept.
|
|
14
|
+
Es ist gegen die echten Libs verifiziert: CrewAI 1.14.6 und LangChain 1.3
|
|
15
|
+
(inkl. eines No-Key-Beispiels, das einen echten LangGraph-Loop bremst).
|
|
16
|
+
|
|
17
|
+
## Die Geschäftsidee in einem Satz
|
|
18
|
+
|
|
19
|
+
Solo-Entwickler-Produkt in einer brandneuen, noch nicht dominierten Nische
|
|
20
|
+
(Agenten-Kostenkontrolle). Open-Source-Kern (MIT) für Verbreitung, später
|
|
21
|
+
bezahlte Cloud-/Team-Version für Umsatz. Langfristiges Ziel: Übernahme durch
|
|
22
|
+
einen großen Player (Datadog, LangChain Inc., ein Hyperscaler) oder profitabler
|
|
23
|
+
SaaS.
|
|
24
|
+
|
|
25
|
+
## Warum diese Nische (Recherche-Ergebnis, Stand Juni 2026)
|
|
26
|
+
|
|
27
|
+
- Markt explodiert: LLM-API-Ausgaben haben sich 2024→2025 verdoppelt (3,5 → 8,4 Mrd. $).
|
|
28
|
+
- Schmerz ist real & teuer dokumentiert: ein LangChain-Loop kostete real $47.000 über 11 Tage.
|
|
29
|
+
- CrewAI: 12 Mio. Agenten-Läufe/Tag in Produktion. LangChain: 50.000+ Produktions-Apps.
|
|
30
|
+
- Die Lücke: Bestehende Tools **loggen** Loops, sie **stoppen** sie nicht in Echtzeit.
|
|
31
|
+
AgentBrake greift ein statt nur zu beobachten.
|
|
32
|
+
- Konkurrenz existiert (Magicrails, Waxell, Galileo), aber niemand besitzt die
|
|
33
|
+
Position „*die* LangChain/CrewAI-Notbremse" eindeutig. Markt ist erst Wochen alt.
|
|
34
|
+
|
|
35
|
+
## Was schon gebaut ist
|
|
36
|
+
|
|
37
|
+
| Datei | Inhalt | Status |
|
|
38
|
+
|-------|--------|--------|
|
|
39
|
+
| `src/agentbrake/__init__.py` | Öffentliche API (Exports), Package-Einstieg | ✅ |
|
|
40
|
+
| `src/agentbrake/core.py` | Framework-neutrale Engine: Loop-Detektor, Budget-Tracker, Preis-Tabelle | ✅ getestet (14 Tests) |
|
|
41
|
+
| `src/agentbrake/langchain.py` | **Zwei** Integrationen: `LangChainBrake` (Callback, klassisches 0.x) + `LangChainBrakeMiddleware` (1.x / LangGraph) | ✅ Unit-Tests + echte Integrationstests gegen LangChain **1.3** |
|
|
42
|
+
| `src/agentbrake/crewai.py` | CrewAI-Adapter via Monkey-Patching | ✅ gegen echtes CrewAI **1.14.6** verifiziert & repariert — siehe Hinweis unten |
|
|
43
|
+
| `tests/` | Engine + LangChain (Unit + Middleware-Integration) + CrewAI | ✅ **grün** — 20 ohne Frameworks, 22 mit LangChain, 26 mit CrewAI; nicht-installierte Pfade skippen sauber |
|
|
44
|
+
| `pyproject.toml` | Packaging (hatchling, src-Layout) + pytest-Config | ✅ Wheel baut, `pip install -e .` läuft |
|
|
45
|
+
| `README.md` | Doku + Verkaufstext | ✅ aktualisiert (1.x-Middleware vs. 0.x-Callback) |
|
|
46
|
+
| `examples/` | `langchain_quickstart.py` (läuft **ohne API-Key**), `crewai_quickstart.py` (braucht Key), `README.md` | ✅ |
|
|
47
|
+
|
|
48
|
+
### ⚠️ Wichtiger Hinweis zum LangChain-Adapter (Stand 1.x)
|
|
49
|
+
|
|
50
|
+
LangChain 1.x hat die Agenten-Architektur auf `create_agent` / LangGraph
|
|
51
|
+
umgebaut. Zwei Konsequenzen, die den Adapter direkt betreffen:
|
|
52
|
+
|
|
53
|
+
- **Callbacks können nicht mehr bremsen.** In LangGraph laufen Callback-Handler
|
|
54
|
+
als Beobachter; eine Exception aus einem Callback wird **geloggt und
|
|
55
|
+
verschluckt**, der Lauf geht weiter. Der klassische `LangChainBrake`-Callback
|
|
56
|
+
funktioniert daher nur noch beim alten `AgentExecutor` (0.x).
|
|
57
|
+
- **Für 1.x gibt es `LangChainBrakeMiddleware`.** Middleware läuft *im*
|
|
58
|
+
Ausführungsgraphen (`wrap_tool_call` / `wrap_model_call`), eine Exception
|
|
59
|
+
daraus stoppt den Lauf wirklich. Verifiziert: das No-Key-Beispiel bremst einen
|
|
60
|
+
echten LangGraph-Loop bei Step 3.
|
|
61
|
+
|
|
62
|
+
**Faustregel:** 1.x (`create_agent`) → `LangChainBrakeMiddleware`. Klassischer
|
|
63
|
+
`AgentExecutor` (0.x) → `LangChainBrake`-Callback.
|
|
64
|
+
|
|
65
|
+
### ⚠️ Wichtiger Hinweis zum CrewAI-Adapter (Stand 1.x)
|
|
66
|
+
|
|
67
|
+
CrewAI 1.x hat die interne Architektur umgebaut: `LLM(...)` ist jetzt eine
|
|
68
|
+
**Factory**, die provider-spezifische Subklassen (`OpenAICompletion`, …)
|
|
69
|
+
zurückgibt — das alte Patchen von `LLM.call` lief ins Leere. Der Adapter wurde
|
|
70
|
+
darauf umgebaut: er patcht jetzt **jede Provider-Klasse mit eigenem `call()`**
|
|
71
|
+
(plus `ToolUsage._use`). Was man wissen muss:
|
|
72
|
+
|
|
73
|
+
- **Loop-/Step-/Tool-/Duration-Limits** greifen zuverlässig (über `ToolUsage._use`).
|
|
74
|
+
- **Cost-Limit** ist so genau, wie der Provider seine Tokens meldet
|
|
75
|
+
(`_token_usage`); ohne gemeldete Tokens fällt der Adapter auf eine grobe
|
|
76
|
+
Längen-Schätzung zurück.
|
|
77
|
+
- `install()` muss **nach** dem Bauen der Agenten/LLMs laufen (CrewAI lädt
|
|
78
|
+
Provider lazy) — am besten direkt vor `crew.kickoff()`.
|
|
79
|
+
- Noch offen: ein echter End-to-End-Lauf mit live LLM-Key (kostet echtes Geld).
|
|
80
|
+
Patch-Punkte + Token-Buchhaltung sind aber gegen die reale Lib verifiziert.
|
|
81
|
+
|
|
82
|
+
## Die offenen nächsten Schritte (Priorität von oben)
|
|
83
|
+
|
|
84
|
+
1. **Echter End-to-End-Lauf mit live LLM-Key** (kostet ein paar Cent): einmal
|
|
85
|
+
`crewai_quickstart.py` mit `OPENAI_API_KEY` laufen lassen und einen echten
|
|
86
|
+
Crew-Loop bremsen sehen. Letzter ungetesteter Pfad — Mechanik ist verifiziert,
|
|
87
|
+
nur der Live-Lauf fehlt. (LangChain ist via No-Key-Beispiel schon abgedeckt.)
|
|
88
|
+
2. **Auf GitHub stellen.** Repo anlegen, Code pushen (LICENSE + .gitignore liegen bei).
|
|
89
|
+
3. **Auf PyPI veröffentlichen.** `pip install build twine`, `python -m build`,
|
|
90
|
+
`twine upload dist/*`. Dann ist `pip install agentbrake-sdk` weltweit live.
|
|
91
|
+
4. **Go-to-Market starten.** Siehe `GO-TO-MARKET.md` — der 47k-Loop ist die beste Story.
|
|
92
|
+
5. **Landing Page bauen.** Siehe `WEBSITE-ARCHITECTURE.md`.
|
|
93
|
+
|
|
94
|
+
**Erledigt (Juni 2026):** Packaging zu echtem `src/agentbrake`-Paket umgebaut
|
|
95
|
+
(`__init__.py`, Wheel baut, `pip install -e .` läuft) · Testsuite neu von Null
|
|
96
|
+
geschrieben · CrewAI-Adapter gegen echtes CrewAI 1.14.6 verifiziert und auf die
|
|
97
|
+
neue Provider-Factory-Architektur repariert · LangChain-1.x-Lücke gefunden
|
|
98
|
+
(Callbacks bremsen in LangGraph nicht mehr) und mit `LangChainBrakeMiddleware`
|
|
99
|
+
geschlossen — bremst nachweislich einen echten LangGraph-Loop ohne API-Key ·
|
|
100
|
+
Examples für beide Frameworks geschrieben.
|
|
101
|
+
|
|
102
|
+
## Arbeitsweise mit Marco (für Claude in der neuen Session)
|
|
103
|
+
|
|
104
|
+
- Marco kommuniziert auf Deutsch (informell).
|
|
105
|
+
- Marco will so wenig wie möglich selbst machen — Claude agiert als technischer
|
|
106
|
+
Co-Founder und trifft Entscheidungen, statt viele Fragen zu stellen.
|
|
107
|
+
- Marco schätzt Ehrlichkeit über Schönfärberei: echte Vorbehalte nennen
|
|
108
|
+
(z.B. „CrewAI-Cost-Limit hängt davon ab, dass der Provider Tokens meldet"),
|
|
109
|
+
nicht verstecken.
|
|
110
|
+
- Iterativ arbeiten: erste Version ist Startpunkt, nicht Endprodukt.
|
|
111
|
+
|
|
112
|
+
## Wichtiger realistischer Rahmen
|
|
113
|
+
|
|
114
|
+
Große Firmen kaufen selten reine Ideen oder frühe Tools. Was zählt, ist
|
|
115
|
+
**Traction**: echte Nutzer, GitHub-Stars, Downloads. Der Plan ist deshalb:
|
|
116
|
+
erst Verbreitung über Open Source + Communities, dann Umsatz, dann ggf. Exit.
|
|
117
|
+
Das ist ein Monate-bis-Jahre-Weg, kein Schnellschuss — ehrlich eingeordnet.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# 🛑 AgentBrake
|
|
2
|
+
|
|
3
|
+
**The emergency brake for multi-agent systems.**
|
|
4
|
+
Stop runaway LangChain & CrewAI agents in real time — *before* 50 cents turns into $47,000.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install agentbrake-sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
> The install name is `agentbrake-sdk`; you import it as `agentbrake`.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## The problem
|
|
15
|
+
|
|
16
|
+
In November 2025, four LangChain agents entered an infinite loop. They ran for 11 days. The bill was **$47,000**. Nobody noticed until it was over.
|
|
17
|
+
|
|
18
|
+
This is not rare. Autonomous agents fail *expensively* rather than loudly:
|
|
19
|
+
|
|
20
|
+
- An agent calls the same tool **14,000 times** with identical arguments.
|
|
21
|
+
- A planner expands one simple task into dozens of high-context subagent calls.
|
|
22
|
+
- A reasoning loop never hits its stopping condition and runs all night.
|
|
23
|
+
|
|
24
|
+
Observability tools **record** this. They don't **stop** it. By the time the alert fires — or someone reads it — the money is gone. The gap between "the alert fired" and "the run stopped" is exactly where the damage compounds.
|
|
25
|
+
|
|
26
|
+
**AgentBrake closes that gap. It intercepts, not just observes.**
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## How it works
|
|
31
|
+
|
|
32
|
+
AgentBrake hooks into your agent's execution and watches every step in real time. When a run crosses a limit you set, it raises a clean exception that **halts the agent before the next expensive call goes out.**
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from agentbrake import LangChainBrakeMiddleware
|
|
36
|
+
from langchain.agents import create_agent
|
|
37
|
+
|
|
38
|
+
agent = create_agent(
|
|
39
|
+
model, tools=tools,
|
|
40
|
+
middleware=[LangChainBrakeMiddleware(max_cost_usd=2.00, repeat_tool_limit=5)],
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That's it. One line.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## What it catches
|
|
49
|
+
|
|
50
|
+
| Runaway pattern | How AgentBrake stops it |
|
|
51
|
+
|---|---|
|
|
52
|
+
| **Identical-tool loops** (same call, same args, over and over) | `repeat_tool_limit` — trips after N identical calls in a row |
|
|
53
|
+
| **Cost blowouts** (the $47k overnight run) | `max_cost_usd` — a hard ceiling, enforced live as tokens are spent |
|
|
54
|
+
| **Endless reasoning** (no stopping condition) | `max_steps` — caps total reasoning steps |
|
|
55
|
+
| **Tool-call storms** | `max_tool_calls` — caps total tool invocations |
|
|
56
|
+
| **Hung runs** | `max_duration_s` — wall-clock ceiling |
|
|
57
|
+
|
|
58
|
+
It warns at 80% of any limit, and stops at 100%.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## LangChain
|
|
63
|
+
|
|
64
|
+
LangChain has two agent stacks, and they intercept differently — AgentBrake
|
|
65
|
+
ships the right tool for each.
|
|
66
|
+
|
|
67
|
+
**LangChain 1.x** (`create_agent` / LangGraph) — use the middleware. It runs
|
|
68
|
+
inside the agent graph, so it can actually halt the run:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from agentbrake import LangChainBrakeMiddleware, AgentBrakeError
|
|
72
|
+
from langchain.agents import create_agent
|
|
73
|
+
|
|
74
|
+
agent = create_agent(
|
|
75
|
+
model, tools=tools,
|
|
76
|
+
middleware=[LangChainBrakeMiddleware(max_cost_usd=2.00, repeat_tool_limit=5, max_steps=30)],
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
agent.invoke({"messages": [("user", "...")]})
|
|
81
|
+
except AgentBrakeError as e:
|
|
82
|
+
print(f"Stopped safely: {e.reason}")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Classic `AgentExecutor`** (LangChain 0.x) — use the callback:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from agentbrake import LangChainBrake, AgentBrakeError
|
|
89
|
+
|
|
90
|
+
brake = LangChainBrake(
|
|
91
|
+
max_cost_usd=2.00,
|
|
92
|
+
repeat_tool_limit=5,
|
|
93
|
+
max_steps=30,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
agent_executor.invoke({"input": "..."}, config={"callbacks": [brake]})
|
|
98
|
+
except AgentBrakeError as e:
|
|
99
|
+
print(f"Stopped safely: {e.reason}")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## CrewAI
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from agentbrake import CrewAIBrake, AgentBrakeError
|
|
106
|
+
|
|
107
|
+
CrewAIBrake(max_cost_usd=3.00, repeat_tool_limit=5).install()
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
crew.kickoff()
|
|
111
|
+
except AgentBrakeError as e:
|
|
112
|
+
print(f"Crew stopped safely: {e.reason}")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Live cost visibility
|
|
118
|
+
|
|
119
|
+
Every run prints where your money is going, step by step:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
[AgentBrake] step 1: web_search · running cost $0.0080
|
|
123
|
+
[AgentBrake] step 2: web_search · running cost $0.0160
|
|
124
|
+
[AgentBrake] ⚠️ approaching cost limit (1.60 of 2.00)
|
|
125
|
+
[AgentBrake] 🛑 STOPPED — loop detected: same tool call repeated 5× in a row
|
|
126
|
+
steps=5 tool_calls=5 llm_calls=4 tokens=9,200 cost=$0.032 elapsed=0.4s
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Pricing built in
|
|
132
|
+
|
|
133
|
+
AgentBrake ships with current pricing for GPT-4o, GPT-4, Claude (Opus/Sonnet/Haiku), and Gemini, so cost ceilings work out of the box. Override anytime with your own rates.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Why not just set a provider spend cap?
|
|
138
|
+
|
|
139
|
+
Provider caps are **monthly** and **account-wide** — they fire after the damage, across everything. AgentBrake is **per-run** and **in-process** — it stops *this* agent *now*, before the next call. It's the difference between a smoke alarm and a sprinkler.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT — free to use, including commercially.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Releasing AgentBrake
|
|
2
|
+
|
|
3
|
+
The package is built, `twine check`-clean, and committed. Publishing is
|
|
4
|
+
outward-facing, so it needs *your* accounts — here are the exact steps.
|
|
5
|
+
|
|
6
|
+
## 0. Public identity (decided)
|
|
7
|
+
|
|
8
|
+
- Homepage: `https://agentbrake.dev`
|
|
9
|
+
- Repository: `https://github.com/marcoschulz7/agentbrake`
|
|
10
|
+
|
|
11
|
+
The PyPI project name `agentbrake` still needs to be free — check
|
|
12
|
+
https://pypi.org/project/agentbrake/ before the upload.
|
|
13
|
+
|
|
14
|
+
## 1. Push to GitHub — done via gh
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
gh repo create marcoschulz7/agentbrake --public --source=. --remote=origin --push
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 2. Publish to PyPI
|
|
21
|
+
|
|
22
|
+
Use TestPyPI first to see the page render, then the real index.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# build fresh artifacts
|
|
26
|
+
uv build # -> dist/agentbrake-0.1.0.tar.gz + .whl
|
|
27
|
+
uvx twine check dist/* # must say PASSED for both
|
|
28
|
+
|
|
29
|
+
# dry run on TestPyPI (needs a TestPyPI token)
|
|
30
|
+
uvx twine upload --repository testpypi dist/*
|
|
31
|
+
pip install -i https://test.pypi.org/simple/ agentbrake-sdk # smoke-test the install
|
|
32
|
+
|
|
33
|
+
# the real thing (needs a PyPI token)
|
|
34
|
+
uvx twine upload dist/*
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
After this, `pip install agentbrake-sdk` is live worldwide.
|
|
38
|
+
|
|
39
|
+
## 3. Tag the release
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git tag -a v0.1.0 -m "AgentBrake 0.1.0"
|
|
43
|
+
git push origin v0.1.0
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Still open before/after launch
|
|
47
|
+
|
|
48
|
+
- **CrewAI live end-to-end run** with a real `OPENAI_API_KEY` (a few cents) —
|
|
49
|
+
run `examples/crewai_quickstart.py` and watch a real crew get braked. The
|
|
50
|
+
mechanics are verified against the real library; only the live run is left.
|
|
51
|
+
- Go-to-market — see `GO-TO-MARKET.md` (the $47k loop is the lead story).
|
|
52
|
+
- Landing page — see `WEBSITE-ARCHITECTURE.md`.
|