quickstart · for developers
Attach the harness in a few lines.
laserbrain checks your agent against the goal it started from and returns it when it drifts. The check runs locally and free — a pure function, no key, no latency. Add a key later to retain history and get the fleet view. Here is the whole surface.
1 · install
Same name on both registries, independent release lines — neither is ahead of the other. Both are checked against the same conformance corpus, so a verdict is a verdict either side. One difference worth knowing: the Node build comes from a Worker context with no user-turn signal, so reground — the verdict for “the human changed the goal” — cannot arise there. Every other reason is identical.
Source, MIT: github.com/degibug-del/laserbrain · PyPI · npm
2 · the check
Each step, your agent spells its state — the goal, whether it’s advancing, and how far from done. laserbrain remembers the ground it started from and tells you if it has drifted.
progress is advancing | stuck | circling; distance is 0–10 to done. Reasons: advancing, grounded, goal-drift, stalled, self-report, ungrammatical.
Pass tokens and it can tell you what the drift cost.
Optional, one line. With a key, the count is recorded beside the verdict and your account totals everything spent at or after the first drifting verdict — a ledger of tokens actually spent on runs already off-goal, not an estimate. Leave it out and the check is identical; you simply have no cost figure at the end of the month.
3 · close the loop — the act layer
Hand laserbrain your step and it detects drift and injects the return. Your step reads ctx["return"] and steers back. The return cuts steps — that is measured. Whether it keeps the answer as good is not established, and fewer steps is not fewer tokens: the studies, nulls included.
4 · async agents
Same loop, awaited — your step and callbacks may be async, and the API mirror runs off the event loop so it never blocks. Afterward, report() prints the shape of the run.
5 · your framework
Already on LangGraph, CrewAI, AutoGen, or the OpenAI Agents SDK? You map your state to (goal, progress, distance), and laserbrain watches from inside your loop. No adapter imports a framework — install only the one you use.
6 · when a return doesn’t take — a human decides
If the drift persists past a few self-corrections, escalate it to a person. They see only what the fixed reference caught, and their decision overrides the auto-return. Every check is also written to a tamper-evident, offline-verifiable audit log.
what’s proven — and what isn’t
The single-agent detector is a theorem — a fixed external reference is necessary and sufficient to catch drift, and no self-watching monitor is. Whether returning makes the final answer better is an open question we’ve tested and not established. The multi-agent teams are a prototype. We say plainly what each is. The proof and every study →
go further