OpenWalrusOpenWalrus

Runtime

The OpenWalrus runtime — agent registry, tool schema store, and concurrent execution.

The runtime is the central coordinator that manages agents and their tool schemas.

What the runtime does

Runtime<M, H> is generic over a model type M and a hook type H. It provides:

  • Agent registry — stores named agents, each behind a Mutex for safe concurrent access
  • Tool schema store — holds tool definitions registered by hooks
  • Execution dispatch — routes events to the correct agent and spawns async tasks

Creating a runtime

The runtime is built from a config and a hook:

let runtime = Runtime::new(model, hook).await?;

During construction, the hook's on_register_tools() is called to populate the tool schema store.

Agent isolation

Each agent lives behind an Arc<Mutex<Agent>>. When an event targets an agent:

  1. The runtime locks the agent's mutex
  2. Calls agent.run_stream() with the registered tool schemas
  3. Streams events back to the caller
  4. Releases the lock when the agent stops

This means agents never interfere with each other — but a single agent handles one request at a time.

Tool dispatch

Tools are registered as schemas only (no handlers). When an agent requests a tool call, the runtime sends a ToolRequest through a channel. The hook handles the actual dispatch.

This separation means the runtime doesn't need to know how tools work — it just passes requests through.

Relation to the daemon

In a typical setup, you don't create a runtime directly. The daemon wraps the runtime and connects it to transports (socket, Telegram, Discord).

See agents for how individual agents execute, and hooks for how tools are registered.

On this page