Runtime

Declare agent capability requirements and select the optimal runtime implementation

Runtime Config lets agents declare what capabilities they need — streaming, native hooks, MCP tools — and validates availability at startup.

python
from praisonaiagents import Agent
from praisonaiagents.config import RuntimeConfig

agent = Agent(
    name="Assistant",
    instructions="You are a real-time streaming assistant.",
    runtime=RuntimeConfig(
        required_capabilities={"streaming_deltas"},
        preferred_runtime="native",
    ),
)

agent.start("Explain the latest developments in fusion energy.")

The user enables runtime configuration on the agent; declared capabilities are validated at startup before the run proceeds.

Diagram

Runtime Selection

Preferred available

Fallback allowed

Caps missing

📋 RuntimeConfig

✅ Validate Caps

🚀 Native Runtime

🔄 Alternative Runtime

❌ Startup Error

Quick Start

  1. Simple Usage
    python
    from praisonaiagents import Agent
    from praisonaiagents.config import RuntimeConfig
    
    agent = Agent(
        instructions="You are a helpful assistant with streaming support.",
        runtime=RuntimeConfig(required_capabilities={"streaming_deltas"}),
    )
    agent.start("Write a short poem about autumn.")
  2. With Preferred Runtime
    python
    from praisonaiagents import Agent
    from praisonaiagents.config import RuntimeConfig
    
    agent = Agent(
        instructions="You are a tool-using assistant.",
        runtime=RuntimeConfig(
            preferred_runtime="native",
            required_capabilities={"tool_loop", "mcp_tools"},
            fallback_allowed=True,
        ),
    )
    agent.start("Search for and summarize recent Python release notes.")

How It Works

Diagram
RuntimeAgentUserRuntimeAgentUseralt[All capabilities available][Capabilities missing +fallback_allowed][Capabilities missing + nofallback]Create agentValidate required_capabilitiesRuntime selectedagent.start(…)ResponseFallback runtime selectedagent.start(…)Response (degraded)RuntimeError at creation
PhaseWhat happens
1. ValidateAgent checks required capabilities against available runtimes
2. SelectPreferred runtime is used if available
3. FallbackAlternative runtime used if preferred is unavailable and fallback_allowed=True
4. ExecuteAgent runs on selected runtime

Configuration Options

Card

Full list of options, types, and defaults — RuntimeConfig

OptionTypeDefaultDescription
required_capabilities`list[str] \None`NoneCapabilities the agent requires
preferred_runtime`str \None`NonePreferred runtime implementation name
fallback_allowedboolTrueAllow fallback if preferred runtime is unavailable
validate_on_creationboolTrueValidate at agent creation (vs first execution)
metadata`dict \None`{}Additional runtime hints

Runtime Name Normalisation

preferred_runtime values are canonicalised before selection, so common spellings all resolve to the same capability matrix.

Normalisation is:

  • Case-insensitive — NATIVE, Native, nAtIvE all resolve to native.
  • Whitespace-tolerant — " native " is trimmed to native.
  • Separator-agnostic — - and _ are interchangeable (plugin_harness = plugin-harness).

Alias Table

Source: RUNTIME_ALIASES in praisonaiagents.config.feature_configs.

Alias (any spelling)Canonicalises toNotes
native, NATIVE, Native, native nativeFull native capability matrix
plugin_harness, plugin-harness, harness, plugin, reducedplugin-harnessReduced-harness capability matrix
my-plugin-runtime (any other unknown name)unchangedTreated as a third-party plugin runtime; falls back to the reduced harness
Diagram

Known alias

Close typo

Genuinely unknown

📥 preferred_runtime value

🔡 canonical_runtime_name

✅ Canonical name → full matrix

❌ ValueError + suggestion

🔌 Plugin runtime → reduced harness

Typo Detection

A value that is a close typo of a known runtime (e.g. nativ, natve, reducd, harnes) raises ValueError with a suggested spelling — instead of silently degrading to the reduced harness and dropping capabilities.

python
from praisonaiagents import Agent
from praisonaiagents.config import RuntimeConfig

# Raises ValueError: "Unknown runtime 'nativ'. Did you mean 'native'?"
Agent(
    instructions="You are a helpful assistant.",
    runtime=RuntimeConfig(preferred_runtime="nativ"),
)

The typo check runs at agent construction, so a mistyped RuntimeConfig fails immediately rather than silently at runtime.

Plugin Runtimes Still Accepted

An unrecognised name that is not a close typo is treated as an opaque plugin runtime name and passed through unchanged — a third-party runtime registered later keeps working.

python
from praisonaiagents import Agent
from praisonaiagents.config import RuntimeConfig

# Accepted as-is; falls back to the reduced harness
Agent(
    instructions="You are a helpful assistant.",
    runtime=RuntimeConfig(preferred_runtime="my-plugin-runtime"),
)

Normalised Input Surfaces

Every input form is normalised, and the caller’s object is never mutated — resolve_runtime returns a normalised copy.

python
from praisonaiagents import Agent

# String
Agent(instructions="…", runtime="NATIVE")

# Dict
Agent(instructions="…", runtime={"preferred_runtime": " native "})

# RuntimeConfig instance
from praisonaiagents.config import RuntimeConfig
Agent(instructions="…", runtime=RuntimeConfig(preferred_runtime="NATIVE"))

All three resolve preferred_runtime to native.


Common Patterns

Pattern 1 — Streaming-capable agent

python
from praisonaiagents import Agent
from praisonaiagents.config import RuntimeConfig

agent = Agent(
    instructions="You are a real-time assistant.",
    runtime=RuntimeConfig(
        required_capabilities={"streaming_deltas"},
        fallback_allowed=True,
    ),
)
response = agent.start("Write a detailed technical tutorial on async Python.")
print(response)

Pattern 2 — MCP-tools agent with strict requirements

python
from praisonaiagents import Agent
from praisonaiagents.config import RuntimeConfig

agent = Agent(
    instructions="You are an agent that uses MCP tools for file system operations.",
    runtime=RuntimeConfig(
        required_capabilities={"tool_loop", "mcp_tools", "native_hooks"},
        preferred_runtime="native",
        fallback_allowed=False,
    ),
)
agent.start("List all Python files modified in the last 7 days.")

Best Practices

Use validate_on_creation=True

Keeping validate_on_creation=True (the default) surfaces capability mismatches immediately when the agent is created, not halfway through a task. This prevents silent degradation.

Allow fallback for resilience

Set fallback_allowed=True unless your agent strictly requires a specific runtime. Fallback lets the agent work even in environments where the preferred runtime isn’t installed.

Check available capabilities

Capability names include streaming_deltas, tool_loop, mcp_tools, native_hooks. Use only documented capability names to ensure forward compatibility.


Related