betaloop
A reusable, storage-free ReAct agent kernel: the engine, framework and
protocols that drive a tool-calling agent, plus optional capability bundles. It
knows nothing about how runs are stored (or even whether they are) — persistence
is an optional EventSink a host plugs in. Any application (a thesis-writing
platform, a coding agent, ...) implements its own tools + prompt + storage and
reuses this kernel.
Core (zero I/O, zero business)
runtime—AgentRuntimeReAct loop + event streamllm— OpenAI-compatible chat client (retry / jittered backoff / response-shape validation)tools—ToolRegistry(register / dispatch / mode filtering)actions—Action+UndoEngine(pure, storage-free undo)memory—replay_messages/recap_text+MemoryProviderevents—EventSink(display + record channels) + SSE serializationcontext/modes—AgentContext+AgentMode/ToolCategory
Optional bundles (betaloop.bundles)
-
host—AgentHosthost-adapter framework: message assembly, run envelope (run_start/done), error funneling,StoreSink(persist via a store),undo_run,DictToolAdapter(wrap a dict-based tool system). Eliminates the per-host boilerplate round 1 left behind. -
store—RunStore/ConversationStore/BlobStoreProtocols +JsonlRunStore(default, zero-database JSONL + content-addressed blob spillover). Hosts wanting a DB implement the Protocols; the default needs none. -
subagents—SubagentEngine+SubagentRoster/SubagentSpec+delegatetool: isolated worker agents the orchestrator hands subtasks to, tagged so undo still reverts them while the orchestrator's context stays lean. -
admin—tool_categories/list_tools_admin/list_tool_packages_admin/check_packagesover a registry + display packages (admin-panel source; packages are grouping only, tools stay per-name togglable). -
workspace— sandboxed file I/O + read/write/edit/list tools + file undo reverters -
sandbox— Python code execution (bubblewrap or passthrough backend) -
skills— markdown skill-pack library +load_skilltool -
mcp—MCPManager+MCPServerConfig+parse_servers: bridge external MCP servers (stdio transport, e.g.npx -y @z_ai/mcp-server) into the registry. Sessions outlive registry rebuilds;readOnlyHintannotations map to the READ category; MCP tools carry no undo reverters. Stdlib-only (newline-delimited JSON-RPC), secrets stay host-side:from betaloop.bundles import MCPManager, MCPServerConfig manager = MCPManager([MCPServerConfig( name="zai", command=["npx", "-y", "@z_ai/mcp-server"], env={"Z_AI_API_KEY": "...", "Z_AI_MODE": "ZHIPU"}, default_category="read")]) await manager.attach(registry) # registry gains zai__* tools
Install
pip install betaloop
# local dev (editable + test/lint deps):
pip install -e ".[dev]"
Storage model
The kernel stores nothing. A host provides:
- an
EventSink(write side) — persists message records however it likes (DB / file / nowhere); - a
MemoryProvider(read side, optional) — replays prior turns; - an
UndoEnginefed from wherever the host kept actions.
Minimal host sketch
from betaloop import LLMConfig, ToolRegistry
from betaloop.bundles import AgentHost, JsonlRunStore
from betaloop.bundles.workspace import register_file_tools
registry = ToolRegistry()
register_file_tools(registry, lambda ctx: f"/data/{ctx.user_id}") # your files
store = JsonlRunStore("/var/lib/myapp/agent") # zero-DB default
host = AgentHost(registry,
LLMConfig(model=..., base_url=..., api_key=...),
store, build_system_prompt=my_prompt_builder)
ctx = AgentContext(run_id=rid, user_id=uid)
async for event in host.run(ctx, task, history=prior_turns):
... # forward run_start / step / tool_call / tool_result / done to your frontend
A host supplies only its tools, system prompt, and (optionally) a store
backend — the engine, persistence, run envelope, undo, and (via subagents)
delegation are all reused.
License
MIT
Release files for betaloop 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| betaloop-0.4.6.tar.gz | 82.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| betaloop-0.4.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 150.2 kB
Release files / betaloop-0.4.6.tar.gz
| Download URL | betaloop-0.4.6.tar.gz |
|---|---|
| Size | 82.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fa5b54b2aa4dd76c7f557aa5b81de43655981c07e673069a3c5919421db9ef0
|
|
BLAKE2b-256 checksum How to use checksums |
17c73fe3aa5a7d6e8e3e4aeae22cffdfbdecf68772977a9688ce1f5e41b46abc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / betaloop-0.4.6-py3-none-any.whl
| Download URL | betaloop-0.4.6-py3-none-any.whl |
|---|---|
| Size | 68.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80659fab59b908f19211cdf83e99e8c2cbddb02fcbc869d999ecd79dc740e2cd
|
|
BLAKE2b-256 checksum How to use checksums |
8c39011080e6e2e06c48fb3dac414d2b04f1ada0542bcdc44650de0a8888039e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|