Skip to main content
One protocol, many runtimes — pick the engine that runs a single agent turn without changing your Agent code. The user swaps runtimes without changing agent code; the registry resolves the engine and streams RuntimeResult deltas.
AgentRuntimeProtocol, resolve_runtime, register_runtime, and list_runtimes are importable directly from praisonaiagents as of PR #2335. The deep praisonaiagents.runtime.* paths remain available for backward compatibility.

Quick Start

1

Run a turn with the built-in runtime

2

Stream the response

The built-in praisonai runtime currently yields a single delta containing the full response. True token-by-token streaming is pending Agent-side support.
3

Register and use a custom runtime


How It Works

The registry auto-discovers built-in and plugin runtimes, then hands back an instance implementing AgentRuntimeProtocol.

Picking a Runtime


Configuration Options

AgentRuntimeProtocol

Any object implementing these three methods is a valid runtime: **kwargs understood by the built-in runtime: tools, max_tokens, temperature.

RuntimeConfig

RuntimeResult

The built-in runtime returns RuntimeResult(error=...) instead of raising an exception when execution fails. Custom runtimes should follow the same pattern so callers handle failure uniformly.

RuntimeDelta

RuntimeRegistryEntry

RuntimeRegistry methods


Common Patterns

Implement a custom runtime

Plugin runtime via pyproject.toml

Ship your runtime as an installable package. The registry discovers it automatically at import time.

Alias a runtime

Replace the default runtime

List available runtimes

Check if a runtime is available


Best Practices

The built-in runtime returns RuntimeResult(error=...) instead of raising. Custom runtimes should follow the same pattern so callers can handle failure uniformly with a single if result.error: check.
Pass register_runtime("id", lambda: MyRuntime()) so each resolve_runtime call gets a fresh instance. This is important for runtimes that hold per-turn state or open connections.
stream_turn yields RuntimeDeltas — emit type="text" for tokens, type="error" on failure, type="tool_call" or type="thinking" for richer UIs. Always end with an error delta rather than raising.
The registry is process-wide and thread-safe. Call RuntimeRegistry().clear() only in test teardown to avoid affecting other parts of your application.

Run the whole agent loop on remote provider infrastructure

Select runtimes by model or provider at the YAML level

Resolve and cache runtimes at turn time

Plug in tools from any Model Context Protocol server