SRBN
srbn is a small Python library for reliable long-horizon work with language
model systems. It does one thing: it runs a generator behind explicit checks,
records every attempt, and stops only when the accepted output satisfies the
declared tolerance or the policy says no further progress is certified.
It is a library, not an agent framework. There are no providers, planners, databases, background workers, or hidden orchestration layers in the core.
import srbn
def generate(prompt: str, feedback: str | None) -> str:
if feedback:
return "please approve the request"
return "approve the request"
result = srbn.run(
"Write a polite request",
generate=generate,
checks=[srbn.contains("please")],
)
assert result.ok
print(result.output)
Install
pip install srbn
# or
uv add srbn
Python 3.12+. The core package has zero runtime dependencies.
Model
Reliable long-horizon systems need to preserve checked state. SRBN expresses that requirement as a small control loop.
- A generator proposes an output.
- Checks report residuals.
- Residuals are aggregated into a non-negative score.
- Failed checks produce feedback for the next proposal.
- The trace records the evidence used to accept, stop, or exhaust the run.
The score is a runtime proxy for Lyapunov or barrier energy. A score of 0.0
means the configured checks pass cleanly. A positive score means some declared
condition remains unsatisfied.
With Policy(require_descent=True, on_no_descent="stop"), the loop also
enforces a measured descent gate: a new attempt must reduce the score by more
than min_descent, or the run stops with Status.STOPPED.
API
| Symbol | Purpose |
|---|---|
srbn.run(...) |
Text-in, text-out checked generation. |
srbn.stabilize(...) |
Generic loop for arbitrary typed state. |
srbn.Client(...) |
Reusable wrapper around run. |
srbn.Policy(...) |
Attempt budget, tolerance, and descent settings. |
srbn.CheckResult |
Check outcome: ok, score, feedback, evidence. |
srbn.BarrierResult |
Structured-state barrier outcome. |
srbn.Result.trace |
Complete attempt history. |
Built-in checks are intentionally plain:
checks = [
srbn.contains("SELECT"),
srbn.not_contains("DROP"),
srbn.json_valid(),
]
Domain checks are just callables that return CheckResult.
def has_ticket_id(output: str) -> srbn.CheckResult:
ok = "REQ-" in output
return srbn.CheckResult(
ok=ok,
score=0.0 if ok else 1.0,
feedback="" if ok else "Include a request id.",
name="has_ticket_id",
evidence={"required_prefix": "REQ-"},
)
Structured State
Use stabilize when the state is not text.
def barrier(x: int) -> srbn.BarrierResult:
residual = abs(x)
return srbn.BarrierResult(
ok=x == 0,
score=float(residual),
feedback="move toward zero",
correction=-1 if x > 0 else 1,
name="distance_to_zero",
)
def update(x: int, result: srbn.BarrierResult) -> int:
return x + int(result.correction or 0)
result = srbn.stabilize(3, barrier=barrier, update=update)
assert result.state == 0
What Belongs Outside Core
The core deliberately excludes:
- provider SDKs;
- tool execution;
- multi-agent orchestration;
- capability security;
- risk calibration;
- durable storage;
- domain-specific verifier suites.
Those are application or plugin concerns. The core stays small so it can be embedded anywhere.
Development
uv sync
uv run --with pytest python -m pytest projects/python/srbn/tests
uv run --with ruff python -m ruff check projects/python/srbn/src projects/python/srbn/tests
License
GNU Lesser General Public License v3.0 only.
Citing
If you use SRBN in research, cite the Stability Is All You Need paper series.
Release files for srbn 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| srbn-0.1.1.tar.gz | 30.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| srbn-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.9 kB
Release files / srbn-0.1.1.tar.gz
| Download URL | srbn-0.1.1.tar.gz |
|---|---|
| Size | 30.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62bc229632e58da68b2106565015d41509eca25a9b77fb7738cc9ffc580ac802
|
|
BLAKE2b-256 checksum How to use checksums |
11a977b29d93219ca0cce1757565f450f353ebbfb0a4367b9487fb6b234a9834
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / srbn-0.1.1-py3-none-any.whl
| Download URL | srbn-0.1.1-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b5da81bd7a6166334f7b1dd9b8e315c419a825c97e7bee702d47c558870c280
|
|
BLAKE2b-256 checksum How to use checksums |
a1aa392535602f1856024f1b09e0ff1b649f08e5b52e98afca23e122053e5610
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|