Beyond Prompt and Pray
Building policy-governed AI agents from scratch.
Most agent code is "prompt and pray" — you wire up a model, hand it tools, and
hope it stays in scope. This is the open, inspectable alternative: an agent loop
you can read in an afternoon, with typed actions, runtime gates that
detect and stop risky or out-of-scope behavior before it executes, multi-axis
budgets, human escalation, and a tamper-evident audit log. Everything
runs on the standard library plus pydantic — the baseline works with no
license and no GMS.
For production-grade guarantees — geometric plausibility, calibrated
admissibility, signed verdicts — the optional GMS backend
(knowlytix) snaps in via a lazy seam. Clone it, run the
baseline, see exactly where GMS lifts detection and validation.
Part of the "Beyond … and Pray" series: governed agents · trustworthy RAG · test & validate · LLMs from scratch
What's inside
- Governed agent loop — generator-based, every step inspectable
- Runtime gates —
ALLOW/DENY/ESCALATE, stop bad actions before they run - Typed actions —
ToolCall/AskUser/Finish/Escalate - Budgets — token / time / tool-call / dollar caps, first-class
- Human escalation — reviewer protocol, not an error path
- Tamper-evident audit — hash-chained record of every decision
- GMS-optional — baseline runs free; geometric guarantees via
knowlytix
Install
pip install forgeloop # core: loop, typed actions, tools, gates, audit, planning, memory
pip install "forgeloop[ml]" # + open-weight model tools (torch, transformers)
pip install "forgeloop[gms]" # + the licensed GMS backend (knowlytix; see below)
Quickstart
A gate (or policy) is just (action, state) -> ALLOW / DENY / ESCALATE:
from forgeloop.core import ToolCall
from forgeloop.governance import pii_policy
action = ToolCall(tool_name="send_reply", arguments={"message": "Your SSN is 123-45-6789."})
verdict = pii_policy(action, None)
print(verdict.decision.value, "—", verdict.reason) # escalate — detected PII: ssn
Those policies compose into a GovernanceHarness that runs gates before each
agent action. For the full live ALLOW / DENY / ESCALATE stream and the
hash-chained audit trail, see the runnable demos in
beyond-ship-and-pray.
The GMS upgrade (open-core)
forgeloop runs fully without a license. The GMS-backed features — geometric
plausibility gate, calibrated admissibility, signed verdicts — require the
licensed knowlytix package, installed separately.
forgeloop imports it lazily:
import forgeloop.gms as gms
gms.available() # True if the licensed backend is installed
gms.require() # returns knowlytix, or raises with install instructions
Some notebooks — the capstone *_companion deep-dives and the GMS-native
chapters — exercise these features and need the backend. It's a one-time setup:
get a free developer license, install
knowlytix, and every GMS notebook runs.
The production-grade, GMS-native edition is the Beyond Prompt and Pray, Pro Edition — see knowlytix.ai.
License
Apache-2.0. © 2026 Knowlytix.
Metadata
Release files for forgeloop 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| forgeloop-0.1.4.tar.gz | 106.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| forgeloop-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 245.2 kB
Release files / forgeloop-0.1.4.tar.gz
| Download URL | forgeloop-0.1.4.tar.gz |
|---|---|
| Size | 106.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
810fe0701b2ef3639353b2f6545e9425286279c023b367421f7c9a12662248f2
|
|
BLAKE2b-256 checksum How to use checksums |
24149d73471efe3e92268f1aafd1c0f9f6faf74822c0cbcd14384a5c0508f9f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.
Transparency logRelease files / forgeloop-0.1.4-py3-none-any.whl
| Download URL | forgeloop-0.1.4-py3-none-any.whl |
|---|---|
| Size | 138.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5d26f3422315aecb308bf6c7f3d3f79ef6e1abdaeb9ade6288443d1385eb01e
|
|
BLAKE2b-256 checksum How to use checksums |
b2d112852cf8fe5dddfed21c7ce6e75be26c9b2d1031634219aa26deaa5ec84b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.
Transparency log