noos (Python)
Python bindings for Noos, a reliability layer for LLM agents: scope drift, cost circuit breaks, procedural correction memory, and tool-call loop detection as event-driven decisions.
The Rust core is unchanged — this package ships a native extension
(noos.abi3.*.so / .pyd) built from the same crate published on
crates.io.
Status
0.1.0 — code complete + CI validated on ubuntu-latest. Publish
workflow (.github/workflows/publish.yml) builds and publishes
abi3-py39 wheels for Linux / macOS / Windows on every v* tag.
Requires PYPI_API_TOKEN repo secret.
Install
pip install noos
Wheels are published for CPython 3.9+ on Linux (x86_64, aarch64), macOS (x86_64, arm64), and Windows (x86_64). Other platforms build from source (requires a Rust toolchain).
Quick start
from noos import Regulator, LLMEvent
r = Regulator.for_user("alice").with_cost_cap(2000)
r.on_event(LLMEvent.turn_start("Refactor fetch_user to be async"))
# ... call your LLM of choice; collect response text ...
r.on_event(LLMEvent.turn_complete(response_text))
r.on_event(LLMEvent.cost(
tokens_in=25,
tokens_out=800,
wallclock_ms=500,
provider="anthropic",
))
decision = r.decide()
match decision.kind:
case "continue":
pass # deliver response
case "scope_drift_warn":
print(f"drift {decision.drift_score:.2f}: {decision.drift_tokens}")
case "circuit_break":
print(f"halt: {decision.suggestion} (reason: {decision.reason.kind})")
case "procedural_warning":
for p in decision.patterns:
print(f"learned rule {p.pattern_name}: {p.example_corrections}")
The full per-event contract + pre- vs post-generation decide() timing
rules lives in the Rust crate's
docs/regulator-guide.md.
API summary
| Class | Purpose |
|---|---|
Regulator |
Main API. for_user(id), with_cost_cap(n), on_event(e), decide(), export_json(), from_json(s) + accessors. |
LLMEvent |
Event constructors. turn_start, token, turn_complete, cost, quality_feedback, user_correction, tool_call, tool_result. |
Decision |
Output of decide(). .kind + variant-specific attributes. |
CircuitBreakReason |
Nested on Decision.reason when kind == "circuit_break". |
CorrectionPattern |
Items of Decision.patterns when kind == "procedural_warning". |
Decision variants
decision.kind is one of:
| kind | Available attributes |
|---|---|
continue |
— |
scope_drift_warn |
drift_score, drift_tokens, task_tokens |
circuit_break |
reason (a CircuitBreakReason), suggestion |
procedural_warning |
patterns (list of CorrectionPattern) |
low_confidence_spans |
reserved |
CircuitBreakReason variants
reason.kind is one of:
| kind | Available attributes |
|---|---|
cost_cap_reached |
tokens_spent, tokens_cap, mean_quality_last_n |
quality_decline_no_recovery |
turns, mean_delta |
repeated_failure_pattern |
cluster, failure_count |
repeated_tool_call_loop |
tool_name, consecutive_count |
Persistence
# Save
snapshot: str = r.export_json()
with open("regulator.json", "w") as f:
f.write(snapshot)
# Restore
with open("regulator.json") as f:
r = Regulator.from_json(f.read())
The snapshot carries cross-session learning (strategy EMA + correction
patterns above the emergence threshold). Malformed JSON raises
ValueError.
Path B helper (prompt injection)
Once a CorrectionPattern has emerged on a topic cluster, the cheapest
way to apply it is to prepend the learned examples to the next user
prompt:
prompt = r.inject_corrections(user_message)
response = my_llm.complete(prompt)
inject_corrections is a no-op when decide() wouldn't fire
procedural_warning — so it's safe to wrap every prompt.
Build from source
Requires: Rust toolchain (1.75+), Python 3.9+, maturin.
pip install maturin
cd bindings/python
maturin develop --release
For a wheel you can redistribute:
maturin build --release
# wheel lands in target/wheels/
License
MIT. Same as the Rust crate.
Metadata
Release files for noos 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| noos-0.1.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| noos-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| noos-0.1.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| noos-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 3.9 MB
Release files / noos-0.1.0-cp39-abi3-win_amd64.whl
| Download URL | noos-0.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 961.5 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0ec3572103755a2cf2a142ce1755ccafd77cab7d52e0d20a48ca22a4eef137d5
|
|
BLAKE2b-256 checksum How to use checksums |
de1f4bf66886ad9740852ca8968a7c317d265e62a341d9b811256b4f16e2c32f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / noos-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | noos-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2f2d79b3ab16073006b3c8a6c7ef49965ae9a23607f2d1e829c34caf25eed121
|
|
BLAKE2b-256 checksum How to use checksums |
72f2e7cfee57b6133e88face6a4e905491c0397603a33bffd07d04456748737b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / noos-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | noos-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 932.2 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3b5f0539718ef4f2eb195bdcb0bee2e7ecdd24bcd31159e1dffbf58355a7ac3e
|
|
BLAKE2b-256 checksum How to use checksums |
a9f2f3e21c6355b28fd72b676a4fb3aadadad04ad77c23b3bed59422b0cfba5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / noos-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | noos-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 985.1 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
6abd748862a286258da4409b1c3418c340f4aff672f7284e63bdcbf25e76cdea
|
|
BLAKE2b-256 checksum How to use checksums |
4a8ad029d02f484439b521d29d10d08e281297e76c1a73c16531c4fa8d48bbdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|