snubber-core 0.1.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.
- snubber_core-0.1.1/Cargo.toml +36 -0
- snubber_core-0.1.1/MANIFEST.in +4 -0
- snubber_core-0.1.1/PKG-INFO +149 -0
- snubber_core-0.1.1/README.md +141 -0
- snubber_core-0.1.1/build.rs +14 -0
- snubber_core-0.1.1/cbindgen.toml +8 -0
- snubber_core-0.1.1/pyproject.toml +12 -0
- snubber_core-0.1.1/setup.cfg +4 -0
- snubber_core-0.1.1/setup.py +18 -0
- snubber_core-0.1.1/snubber_core/__init__.py +40 -0
- snubber_core-0.1.1/snubber_core.egg-info/PKG-INFO +149 -0
- snubber_core-0.1.1/snubber_core.egg-info/SOURCES.txt +24 -0
- snubber_core-0.1.1/snubber_core.egg-info/dependency_links.txt +1 -0
- snubber_core-0.1.1/snubber_core.egg-info/not-zip-safe +1 -0
- snubber_core-0.1.1/snubber_core.egg-info/top_level.txt +1 -0
- snubber_core-0.1.1/src/bin/snubber-bench/main.rs +86 -0
- snubber_core-0.1.1/src/bin/snubber-harness/main.rs +4 -0
- snubber_core-0.1.1/src/bin/snubber-proxy/main.rs +58 -0
- snubber_core-0.1.1/src/bin/snubber-proxy/proxy.rs +291 -0
- snubber_core-0.1.1/src/canonical.rs +34 -0
- snubber_core-0.1.1/src/config.rs +105 -0
- snubber_core-0.1.1/src/engine.rs +94 -0
- snubber_core-0.1.1/src/history.rs +161 -0
- snubber_core-0.1.1/src/lib.rs +113 -0
- snubber_core-0.1.1/src/state.rs +63 -0
- snubber_core-0.1.1/src/tests.rs +70 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "snubber"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
crate-type = ["cdylib", "staticlib", "rlib"]
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
async-stream = "0.3.6"
|
|
11
|
+
axum = "0.8.9"
|
|
12
|
+
regex = { version = "1.12.4", default-features = false }
|
|
13
|
+
reqwest = { version = "0.13.4", features = ["json"] }
|
|
14
|
+
serde = { version = "1.0.228", features = ["derive", "alloc"] }
|
|
15
|
+
serde_json = { version = "1.0.150", default-features = false, features = ["alloc"] }
|
|
16
|
+
serde_yaml = "0.9.34"
|
|
17
|
+
tokio = { version = "1.52.3", features = ["rt-multi-thread", "macros", "net", "signal"] }
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[[bin]]
|
|
21
|
+
name = "snubber-proxy"
|
|
22
|
+
path = "src/bin/snubber-proxy/main.rs"
|
|
23
|
+
|
|
24
|
+
[[bin]]
|
|
25
|
+
name = "snubber-bench"
|
|
26
|
+
path = "src/bin/snubber-bench/main.rs"
|
|
27
|
+
|
|
28
|
+
[build-dependencies]
|
|
29
|
+
cbindgen = "0.29.4"
|
|
30
|
+
|
|
31
|
+
[profile.release]
|
|
32
|
+
opt-level = "z"
|
|
33
|
+
lto = true
|
|
34
|
+
codegen-units = 1
|
|
35
|
+
panic = "abort"
|
|
36
|
+
strip = true
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: snubber-core
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Snubber Core C ABI wrapped in ctypes for Python adapters
|
|
5
|
+
Author: Tanmay Devare
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="assets/snubber-logo.svg" alt="Snubber Logo" width="600">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="assets/snubber-architecture.svg" alt="Snubber Architecture Diagram" width="90%" style="max-width: 900px;">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<em>Catch the shock. Stop AI agents from burning tokens on infinite loops.</em>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
23
|
+
<a href="Cargo.toml"><img src="https://img.shields.io/badge/rustc-2024+-orange" alt="Rust Edition 2024"></a>
|
|
24
|
+
<a href="src/lib.rs"><img src="https://img.shields.io/badge/no__std-compatible-success" alt="no_std compatible"></a>
|
|
25
|
+
<a href="https://github.com/tanmaydevare/snubber"><img src="https://img.shields.io/badge/build-passing-brightgreen" alt="Build Status"></a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Snubber: Two Products, One Safety Layer
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## What Is Snubber?
|
|
35
|
+
|
|
36
|
+
**Snubber** is the runtime safety layer for autonomous agents. It detects and blocks tool‑call loops before they burn tokens or crash your infrastructure. It works in any harness, any language, in under 70 microseconds.
|
|
37
|
+
|
|
38
|
+
We ship **two products** that serve different audiences:
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Product 1: Snubber Core
|
|
43
|
+
|
|
44
|
+
### The Engine
|
|
45
|
+
|
|
46
|
+
The Snubber Core is a **C ABI library** written in Rust (`no_std`). It does exactly one thing: it takes a tool call, checks it against a sliding window of recent calls, and returns a decision — `ALLOW`, `WARN`, `BLOCK_RETRY`, or `BLOCK_HALT`.
|
|
47
|
+
|
|
48
|
+
**Key properties:**
|
|
49
|
+
- **<2µs overhead** – zero allocations in the hot path
|
|
50
|
+
- **<200KB binary** – no runtime dependencies
|
|
51
|
+
- **C ABI** – embeds anywhere C runs (Python, Node.js, Go, Rust, C++)
|
|
52
|
+
|
|
53
|
+
**What it does:**
|
|
54
|
+
- **Semantic loop detection** (`ignore_args: true`) – catches the same tool with different arguments
|
|
55
|
+
- **Error‑aware counting** (`count_mode: ErrorsOnly`) – ignores legitimate polling
|
|
56
|
+
- **Circuit breaker** – per‑tool cooldown prevents retry storms
|
|
57
|
+
- **Output validation** – regex + JSON schema on tool outputs
|
|
58
|
+
|
|
59
|
+
**Who it’s for:**
|
|
60
|
+
- Harness developers (LangChain, CrewAI, AutoGen maintainers)
|
|
61
|
+
- Systems engineers embedding safety in custom agents
|
|
62
|
+
- Rust developers building agent frameworks
|
|
63
|
+
|
|
64
|
+
**Distribution:**
|
|
65
|
+
- Crates.io: `cargo add snubber`
|
|
66
|
+
- GitHub: `snubber-rs/snubber`
|
|
67
|
+
- Pre‑built binaries: `libsnubber.so`, `libsnubber.dylib`, `snubber.dll`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Product 2: Snubber Adapters + Reference Harness
|
|
72
|
+
|
|
73
|
+
### The Drop‑In Safety Layer
|
|
74
|
+
|
|
75
|
+
For developers who don’t want to build from scratch, Snubber provides **ready‑to‑use adapters** that wrap the core into your existing agent harness. One line of code, instant safety.
|
|
76
|
+
|
|
77
|
+
**Available adapters:**
|
|
78
|
+
- **LangChain** – `pip install snubber-langchain`
|
|
79
|
+
- **CrewAI** – `pip install snubber-crewai`
|
|
80
|
+
- **AutoGen** – `pip install snubber-autogen`
|
|
81
|
+
- **LangGraph** – `pip install snubber-langgraph`
|
|
82
|
+
- **Node.js (coming soon)** – `npm install @snubber/langchain`
|
|
83
|
+
|
|
84
|
+
**Also included:**
|
|
85
|
+
- **Snubber Harness** – a complete, safety‑first Rust ReAct agent harness. It’s open‑source and serves as a reference implementation, showcasing how to build a harness with Snubber embedded as a first‑class primitive.
|
|
86
|
+
|
|
87
|
+
**Who it’s for:**
|
|
88
|
+
- Python developers using LangChain, CrewAI, AutoGen, or LangGraph
|
|
89
|
+
- Teams that want to drop safety into their existing codebase without rewriting
|
|
90
|
+
- Early adopters who want to see Snubber in action before committing
|
|
91
|
+
|
|
92
|
+
**Distribution:**
|
|
93
|
+
- PyPI: `pip install snubber-*`
|
|
94
|
+
- npm: `npm install @snubber/*`
|
|
95
|
+
- Docker: `docker run snubber/harness`
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## How They Work Together
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
103
|
+
│ YOUR APPLICATION │
|
|
104
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
105
|
+
│ │ LangChain / CrewAI / AutoGen / LangGraph │ │
|
|
106
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
107
|
+
│ │ │
|
|
108
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
109
|
+
│ │ Snubber Adapter (Python / JS / Go) │ │
|
|
110
|
+
│ │ – Calls the C ABI core │ │
|
|
111
|
+
│ │ – Intercepts tool calls │ │
|
|
112
|
+
│ │ – Injects SYSTEM INTERCEPT messages │ │
|
|
113
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
114
|
+
│ │ │
|
|
115
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
116
|
+
│ │ Snubber Core (libsnubber.so) │ │
|
|
117
|
+
│ │ – Sliding window │ │
|
|
118
|
+
│ │ – Semantic detection │ │
|
|
119
|
+
│ │ – Circuit breaker │ │
|
|
120
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
121
|
+
└─────────────────────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## The Value Proposition
|
|
127
|
+
|
|
128
|
+
| User | Problem | Snubber Solution |
|
|
129
|
+
|------|---------|------------------|
|
|
130
|
+
| **Python developer** | LangChain loop detection is experimental | `pip install snubber-langchain` – instant safety |
|
|
131
|
+
| **Rust developer** | Need embeddable loop detection | `cargo add snubber` – <2µs, zero allocations |
|
|
132
|
+
| **Enterprise team** | 429 crashes, token waste | Snubber blocked loops in 4 harnesses, saved 100% of tokens |
|
|
133
|
+
| **Harness maintainer** | Want to add safety to your framework | Snubber Core – C ABI, embeddable anywhere |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Summary
|
|
138
|
+
|
|
139
|
+
| Product | What It Is | Who It’s For | Get It |
|
|
140
|
+
|---------|------------|--------------|--------|
|
|
141
|
+
| **Snubber Core** | C ABI library (Rust `no_std`) | Framework devs, systems engineers | `cargo add snubber` |
|
|
142
|
+
| **Snubber Adapters** | Drop‑in wrappers for LangChain, CrewAI, AutoGen, LangGraph | Python agent developers | `pip install snubber-*` |
|
|
143
|
+
| **Snubber Harness** | Reference Rust ReAct agent harness | Rust developers, early adopters | `cargo install snubber-harness` |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT — use it, fork it, ship it. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/snubber-logo.svg" alt="Snubber Logo" width="600">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="assets/snubber-architecture.svg" alt="Snubber Architecture Diagram" width="90%" style="max-width: 900px;">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<em>Catch the shock. Stop AI agents from burning tokens on infinite loops.</em>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
15
|
+
<a href="Cargo.toml"><img src="https://img.shields.io/badge/rustc-2024+-orange" alt="Rust Edition 2024"></a>
|
|
16
|
+
<a href="src/lib.rs"><img src="https://img.shields.io/badge/no__std-compatible-success" alt="no_std compatible"></a>
|
|
17
|
+
<a href="https://github.com/tanmaydevare/snubber"><img src="https://img.shields.io/badge/build-passing-brightgreen" alt="Build Status"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Snubber: Two Products, One Safety Layer
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## What Is Snubber?
|
|
27
|
+
|
|
28
|
+
**Snubber** is the runtime safety layer for autonomous agents. It detects and blocks tool‑call loops before they burn tokens or crash your infrastructure. It works in any harness, any language, in under 70 microseconds.
|
|
29
|
+
|
|
30
|
+
We ship **two products** that serve different audiences:
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Product 1: Snubber Core
|
|
35
|
+
|
|
36
|
+
### The Engine
|
|
37
|
+
|
|
38
|
+
The Snubber Core is a **C ABI library** written in Rust (`no_std`). It does exactly one thing: it takes a tool call, checks it against a sliding window of recent calls, and returns a decision — `ALLOW`, `WARN`, `BLOCK_RETRY`, or `BLOCK_HALT`.
|
|
39
|
+
|
|
40
|
+
**Key properties:**
|
|
41
|
+
- **<2µs overhead** – zero allocations in the hot path
|
|
42
|
+
- **<200KB binary** – no runtime dependencies
|
|
43
|
+
- **C ABI** – embeds anywhere C runs (Python, Node.js, Go, Rust, C++)
|
|
44
|
+
|
|
45
|
+
**What it does:**
|
|
46
|
+
- **Semantic loop detection** (`ignore_args: true`) – catches the same tool with different arguments
|
|
47
|
+
- **Error‑aware counting** (`count_mode: ErrorsOnly`) – ignores legitimate polling
|
|
48
|
+
- **Circuit breaker** – per‑tool cooldown prevents retry storms
|
|
49
|
+
- **Output validation** – regex + JSON schema on tool outputs
|
|
50
|
+
|
|
51
|
+
**Who it’s for:**
|
|
52
|
+
- Harness developers (LangChain, CrewAI, AutoGen maintainers)
|
|
53
|
+
- Systems engineers embedding safety in custom agents
|
|
54
|
+
- Rust developers building agent frameworks
|
|
55
|
+
|
|
56
|
+
**Distribution:**
|
|
57
|
+
- Crates.io: `cargo add snubber`
|
|
58
|
+
- GitHub: `snubber-rs/snubber`
|
|
59
|
+
- Pre‑built binaries: `libsnubber.so`, `libsnubber.dylib`, `snubber.dll`
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Product 2: Snubber Adapters + Reference Harness
|
|
64
|
+
|
|
65
|
+
### The Drop‑In Safety Layer
|
|
66
|
+
|
|
67
|
+
For developers who don’t want to build from scratch, Snubber provides **ready‑to‑use adapters** that wrap the core into your existing agent harness. One line of code, instant safety.
|
|
68
|
+
|
|
69
|
+
**Available adapters:**
|
|
70
|
+
- **LangChain** – `pip install snubber-langchain`
|
|
71
|
+
- **CrewAI** – `pip install snubber-crewai`
|
|
72
|
+
- **AutoGen** – `pip install snubber-autogen`
|
|
73
|
+
- **LangGraph** – `pip install snubber-langgraph`
|
|
74
|
+
- **Node.js (coming soon)** – `npm install @snubber/langchain`
|
|
75
|
+
|
|
76
|
+
**Also included:**
|
|
77
|
+
- **Snubber Harness** – a complete, safety‑first Rust ReAct agent harness. It’s open‑source and serves as a reference implementation, showcasing how to build a harness with Snubber embedded as a first‑class primitive.
|
|
78
|
+
|
|
79
|
+
**Who it’s for:**
|
|
80
|
+
- Python developers using LangChain, CrewAI, AutoGen, or LangGraph
|
|
81
|
+
- Teams that want to drop safety into their existing codebase without rewriting
|
|
82
|
+
- Early adopters who want to see Snubber in action before committing
|
|
83
|
+
|
|
84
|
+
**Distribution:**
|
|
85
|
+
- PyPI: `pip install snubber-*`
|
|
86
|
+
- npm: `npm install @snubber/*`
|
|
87
|
+
- Docker: `docker run snubber/harness`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## How They Work Together
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
95
|
+
│ YOUR APPLICATION │
|
|
96
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
97
|
+
│ │ LangChain / CrewAI / AutoGen / LangGraph │ │
|
|
98
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
99
|
+
│ │ │
|
|
100
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
101
|
+
│ │ Snubber Adapter (Python / JS / Go) │ │
|
|
102
|
+
│ │ – Calls the C ABI core │ │
|
|
103
|
+
│ │ – Intercepts tool calls │ │
|
|
104
|
+
│ │ – Injects SYSTEM INTERCEPT messages │ │
|
|
105
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
106
|
+
│ │ │
|
|
107
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
108
|
+
│ │ Snubber Core (libsnubber.so) │ │
|
|
109
|
+
│ │ – Sliding window │ │
|
|
110
|
+
│ │ – Semantic detection │ │
|
|
111
|
+
│ │ – Circuit breaker │ │
|
|
112
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
113
|
+
└─────────────────────────────────────────────────────────────┘
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## The Value Proposition
|
|
119
|
+
|
|
120
|
+
| User | Problem | Snubber Solution |
|
|
121
|
+
|------|---------|------------------|
|
|
122
|
+
| **Python developer** | LangChain loop detection is experimental | `pip install snubber-langchain` – instant safety |
|
|
123
|
+
| **Rust developer** | Need embeddable loop detection | `cargo add snubber` – <2µs, zero allocations |
|
|
124
|
+
| **Enterprise team** | 429 crashes, token waste | Snubber blocked loops in 4 harnesses, saved 100% of tokens |
|
|
125
|
+
| **Harness maintainer** | Want to add safety to your framework | Snubber Core – C ABI, embeddable anywhere |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Summary
|
|
130
|
+
|
|
131
|
+
| Product | What It Is | Who It’s For | Get It |
|
|
132
|
+
|---------|------------|--------------|--------|
|
|
133
|
+
| **Snubber Core** | C ABI library (Rust `no_std`) | Framework devs, systems engineers | `cargo add snubber` |
|
|
134
|
+
| **Snubber Adapters** | Drop‑in wrappers for LangChain, CrewAI, AutoGen, LangGraph | Python agent developers | `pip install snubber-*` |
|
|
135
|
+
| **Snubber Harness** | Reference Rust ReAct agent harness | Rust developers, early adopters | `cargo install snubber-harness` |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT — use it, fork it, ship it. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
extern crate cbindgen;
|
|
2
|
+
|
|
3
|
+
use std::env;
|
|
4
|
+
|
|
5
|
+
fn main() {
|
|
6
|
+
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
7
|
+
|
|
8
|
+
cbindgen::Builder::new()
|
|
9
|
+
.with_crate(crate_dir)
|
|
10
|
+
.with_config(cbindgen::Config::from_file("cbindgen.toml").unwrap())
|
|
11
|
+
.generate()
|
|
12
|
+
.expect("Unable to generate bindings")
|
|
13
|
+
.write_to_file("snubber.h");
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "setuptools-rust>=1.5.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "snubber-core"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Snubber Core C ABI wrapped in ctypes for Python adapters"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Tanmay Devare" }]
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
dependencies = []
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
from setuptools_rust import Binding, RustExtension
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="snubber-core",
|
|
6
|
+
version="0.1.0",
|
|
7
|
+
description="Snubber Core C ABI wrapped in ctypes for Python adapters",
|
|
8
|
+
author="Tanmay Devare",
|
|
9
|
+
packages=["snubber_core"],
|
|
10
|
+
rust_extensions=[
|
|
11
|
+
RustExtension(
|
|
12
|
+
"snubber_core.snubber",
|
|
13
|
+
path="Cargo.toml",
|
|
14
|
+
binding=Binding.NoBinding,
|
|
15
|
+
)
|
|
16
|
+
],
|
|
17
|
+
zip_safe=False,
|
|
18
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
# Locate the compiled Rust library
|
|
6
|
+
lib_name = "libsnubber.so"
|
|
7
|
+
if sys.platform == "darwin":
|
|
8
|
+
lib_name = "libsnubber.dylib"
|
|
9
|
+
elif sys.platform == "win32":
|
|
10
|
+
lib_name = "snubber.dll"
|
|
11
|
+
|
|
12
|
+
lib_path = os.path.join(os.path.dirname(__file__), lib_name)
|
|
13
|
+
|
|
14
|
+
if not os.path.exists(lib_path):
|
|
15
|
+
raise FileNotFoundError(f"Could not find Snubber core library at {lib_path}. Did you build the Rust extension?")
|
|
16
|
+
|
|
17
|
+
# Load the library
|
|
18
|
+
lib = ctypes.CDLL(lib_path)
|
|
19
|
+
|
|
20
|
+
# Expose C ABI functions (assuming standard init/verify/free from earlier)
|
|
21
|
+
lib.snubber_init.argtypes = [ctypes.c_char_p, ctypes.c_size_t]
|
|
22
|
+
lib.snubber_init.restype = ctypes.c_void_p
|
|
23
|
+
|
|
24
|
+
lib.snubber_verify.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p, ctypes.c_size_t]
|
|
25
|
+
lib.snubber_verify.restype = ctypes.c_uint8
|
|
26
|
+
|
|
27
|
+
lib.snubber_free.argtypes = [ctypes.c_void_p]
|
|
28
|
+
lib.snubber_free.restype = None
|
|
29
|
+
|
|
30
|
+
def init_snubber(yaml_config: str) -> ctypes.c_void_p:
|
|
31
|
+
encoded = yaml_config.encode('utf-8')
|
|
32
|
+
return lib.snubber_init(encoded, len(encoded))
|
|
33
|
+
|
|
34
|
+
def verify_call(state_ptr: ctypes.c_void_p, tool_name: str, args_json: str) -> int:
|
|
35
|
+
t_encoded = tool_name.encode('utf-8')
|
|
36
|
+
a_encoded = args_json.encode('utf-8')
|
|
37
|
+
return lib.snubber_verify(state_ptr, t_encoded, len(t_encoded), a_encoded, len(a_encoded))
|
|
38
|
+
|
|
39
|
+
def free_snubber(state_ptr: ctypes.c_void_p):
|
|
40
|
+
lib.snubber_free(state_ptr)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: snubber-core
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Snubber Core C ABI wrapped in ctypes for Python adapters
|
|
5
|
+
Author: Tanmay Devare
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="assets/snubber-logo.svg" alt="Snubber Logo" width="600">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="assets/snubber-architecture.svg" alt="Snubber Architecture Diagram" width="90%" style="max-width: 900px;">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<em>Catch the shock. Stop AI agents from burning tokens on infinite loops.</em>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
23
|
+
<a href="Cargo.toml"><img src="https://img.shields.io/badge/rustc-2024+-orange" alt="Rust Edition 2024"></a>
|
|
24
|
+
<a href="src/lib.rs"><img src="https://img.shields.io/badge/no__std-compatible-success" alt="no_std compatible"></a>
|
|
25
|
+
<a href="https://github.com/tanmaydevare/snubber"><img src="https://img.shields.io/badge/build-passing-brightgreen" alt="Build Status"></a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Snubber: Two Products, One Safety Layer
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## What Is Snubber?
|
|
35
|
+
|
|
36
|
+
**Snubber** is the runtime safety layer for autonomous agents. It detects and blocks tool‑call loops before they burn tokens or crash your infrastructure. It works in any harness, any language, in under 70 microseconds.
|
|
37
|
+
|
|
38
|
+
We ship **two products** that serve different audiences:
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Product 1: Snubber Core
|
|
43
|
+
|
|
44
|
+
### The Engine
|
|
45
|
+
|
|
46
|
+
The Snubber Core is a **C ABI library** written in Rust (`no_std`). It does exactly one thing: it takes a tool call, checks it against a sliding window of recent calls, and returns a decision — `ALLOW`, `WARN`, `BLOCK_RETRY`, or `BLOCK_HALT`.
|
|
47
|
+
|
|
48
|
+
**Key properties:**
|
|
49
|
+
- **<2µs overhead** – zero allocations in the hot path
|
|
50
|
+
- **<200KB binary** – no runtime dependencies
|
|
51
|
+
- **C ABI** – embeds anywhere C runs (Python, Node.js, Go, Rust, C++)
|
|
52
|
+
|
|
53
|
+
**What it does:**
|
|
54
|
+
- **Semantic loop detection** (`ignore_args: true`) – catches the same tool with different arguments
|
|
55
|
+
- **Error‑aware counting** (`count_mode: ErrorsOnly`) – ignores legitimate polling
|
|
56
|
+
- **Circuit breaker** – per‑tool cooldown prevents retry storms
|
|
57
|
+
- **Output validation** – regex + JSON schema on tool outputs
|
|
58
|
+
|
|
59
|
+
**Who it’s for:**
|
|
60
|
+
- Harness developers (LangChain, CrewAI, AutoGen maintainers)
|
|
61
|
+
- Systems engineers embedding safety in custom agents
|
|
62
|
+
- Rust developers building agent frameworks
|
|
63
|
+
|
|
64
|
+
**Distribution:**
|
|
65
|
+
- Crates.io: `cargo add snubber`
|
|
66
|
+
- GitHub: `snubber-rs/snubber`
|
|
67
|
+
- Pre‑built binaries: `libsnubber.so`, `libsnubber.dylib`, `snubber.dll`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Product 2: Snubber Adapters + Reference Harness
|
|
72
|
+
|
|
73
|
+
### The Drop‑In Safety Layer
|
|
74
|
+
|
|
75
|
+
For developers who don’t want to build from scratch, Snubber provides **ready‑to‑use adapters** that wrap the core into your existing agent harness. One line of code, instant safety.
|
|
76
|
+
|
|
77
|
+
**Available adapters:**
|
|
78
|
+
- **LangChain** – `pip install snubber-langchain`
|
|
79
|
+
- **CrewAI** – `pip install snubber-crewai`
|
|
80
|
+
- **AutoGen** – `pip install snubber-autogen`
|
|
81
|
+
- **LangGraph** – `pip install snubber-langgraph`
|
|
82
|
+
- **Node.js (coming soon)** – `npm install @snubber/langchain`
|
|
83
|
+
|
|
84
|
+
**Also included:**
|
|
85
|
+
- **Snubber Harness** – a complete, safety‑first Rust ReAct agent harness. It’s open‑source and serves as a reference implementation, showcasing how to build a harness with Snubber embedded as a first‑class primitive.
|
|
86
|
+
|
|
87
|
+
**Who it’s for:**
|
|
88
|
+
- Python developers using LangChain, CrewAI, AutoGen, or LangGraph
|
|
89
|
+
- Teams that want to drop safety into their existing codebase without rewriting
|
|
90
|
+
- Early adopters who want to see Snubber in action before committing
|
|
91
|
+
|
|
92
|
+
**Distribution:**
|
|
93
|
+
- PyPI: `pip install snubber-*`
|
|
94
|
+
- npm: `npm install @snubber/*`
|
|
95
|
+
- Docker: `docker run snubber/harness`
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## How They Work Together
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
103
|
+
│ YOUR APPLICATION │
|
|
104
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
105
|
+
│ │ LangChain / CrewAI / AutoGen / LangGraph │ │
|
|
106
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
107
|
+
│ │ │
|
|
108
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
109
|
+
│ │ Snubber Adapter (Python / JS / Go) │ │
|
|
110
|
+
│ │ – Calls the C ABI core │ │
|
|
111
|
+
│ │ – Intercepts tool calls │ │
|
|
112
|
+
│ │ – Injects SYSTEM INTERCEPT messages │ │
|
|
113
|
+
│ └─────────────────────┬───────────────────────────────┘ │
|
|
114
|
+
│ │ │
|
|
115
|
+
│ ┌─────────────────────▼───────────────────────────────┐ │
|
|
116
|
+
│ │ Snubber Core (libsnubber.so) │ │
|
|
117
|
+
│ │ – Sliding window │ │
|
|
118
|
+
│ │ – Semantic detection │ │
|
|
119
|
+
│ │ – Circuit breaker │ │
|
|
120
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
121
|
+
└─────────────────────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## The Value Proposition
|
|
127
|
+
|
|
128
|
+
| User | Problem | Snubber Solution |
|
|
129
|
+
|------|---------|------------------|
|
|
130
|
+
| **Python developer** | LangChain loop detection is experimental | `pip install snubber-langchain` – instant safety |
|
|
131
|
+
| **Rust developer** | Need embeddable loop detection | `cargo add snubber` – <2µs, zero allocations |
|
|
132
|
+
| **Enterprise team** | 429 crashes, token waste | Snubber blocked loops in 4 harnesses, saved 100% of tokens |
|
|
133
|
+
| **Harness maintainer** | Want to add safety to your framework | Snubber Core – C ABI, embeddable anywhere |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Summary
|
|
138
|
+
|
|
139
|
+
| Product | What It Is | Who It’s For | Get It |
|
|
140
|
+
|---------|------------|--------------|--------|
|
|
141
|
+
| **Snubber Core** | C ABI library (Rust `no_std`) | Framework devs, systems engineers | `cargo add snubber` |
|
|
142
|
+
| **Snubber Adapters** | Drop‑in wrappers for LangChain, CrewAI, AutoGen, LangGraph | Python agent developers | `pip install snubber-*` |
|
|
143
|
+
| **Snubber Harness** | Reference Rust ReAct agent harness | Rust developers, early adopters | `cargo install snubber-harness` |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT — use it, fork it, ship it. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Cargo.toml
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
build.rs
|
|
5
|
+
cbindgen.toml
|
|
6
|
+
pyproject.toml
|
|
7
|
+
setup.py
|
|
8
|
+
snubber_core/__init__.py
|
|
9
|
+
snubber_core.egg-info/PKG-INFO
|
|
10
|
+
snubber_core.egg-info/SOURCES.txt
|
|
11
|
+
snubber_core.egg-info/dependency_links.txt
|
|
12
|
+
snubber_core.egg-info/not-zip-safe
|
|
13
|
+
snubber_core.egg-info/top_level.txt
|
|
14
|
+
src/canonical.rs
|
|
15
|
+
src/config.rs
|
|
16
|
+
src/engine.rs
|
|
17
|
+
src/history.rs
|
|
18
|
+
src/lib.rs
|
|
19
|
+
src/state.rs
|
|
20
|
+
src/tests.rs
|
|
21
|
+
src/bin/snubber-bench/main.rs
|
|
22
|
+
src/bin/snubber-harness/main.rs
|
|
23
|
+
src/bin/snubber-proxy/main.rs
|
|
24
|
+
src/bin/snubber-proxy/proxy.rs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
snubber_core
|