Skip to main content

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 — AgentRuntime ReAct loop + event stream
  • llm — 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 + MemoryProvider
  • events — EventSink (display + record channels) + SSE serialization
  • context / modes — AgentContext + AgentMode / ToolCategory

Optional bundles (betaloop.bundles)

  • host — AgentHost host-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/BlobStore Protocols + JsonlRunStore (default, zero-database JSONL + content-addressed blob spillover). Hosts wanting a DB implement the Protocols; the default needs none.

  • subagents — SubagentEngine + SubagentRoster/SubagentSpec + delegate tool: 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_packages over 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_skill tool

  • 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; readOnlyHint annotations 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 UndoEngine fed 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)

Source distribution for betaloop 0.4.6
File Size Uploaded
betaloop-0.4.6.tar.gz 82.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for betaloop 0.4.6
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page