Skip to main content
Build one frozen turn plan from an Agent and prompt — any runtime (native, plugin, CLI) executes the same context.
from praisonaiagents import Agent
from praisonaiagents.runtime import default_context_builder

agent = Agent(name="Researcher", instructions="Find facts and cite sources.")
context = default_context_builder.build_context(agent, "Who built the Eiffel Tower?")
print(context.to_dict())
The user sends a prompt; the runtime builds one shared PreparedTurnContext for the turn.

Quick Start

1

Simple Usage

Inspect what the agent will send on the next turn:
from praisonaiagents import Agent
from praisonaiagents.runtime import default_context_builder

agent = Agent(name="Writer", instructions="Summarise pull requests.")
context = default_context_builder.build_context(agent, "Summarise this PR")

print(context.has_tools(), context.get_message_count())
print(context.to_dict())
2

With Configuration

Run the same context through a custom harness:
import asyncio
from praisonaiagents import Agent
from praisonaiagents.runtime import default_context_builder
from praisonaiagents.runtime.example_harness import PluginHarnessRuntime

agent = Agent(name="Writer", instructions="Summarise pull requests.")
context = default_context_builder.build_context(agent, "Summarise this PR")

async def run():
    return await PluginHarnessRuntime().run_turn(context)

asyncio.run(run())

How It Works

StageWhat happens
BuildResolves model, tools, transcript, delivery, correlation
FreezeContext is immutable after construction
ExecuteAny TurnRuntimeProtocol runs the same plan
Key imports: PreparedTurnContext, default_context_builder, RuntimeMode, DeliveryChannels.

Configuration Options

FieldTypeNotes
runtime_modeRuntimeModeSYNC, ASYNC, STREAM, ASYNC_STREAM
deliveryDeliveryChannelsRequired for streaming modes
correlationSessionCorrelationsession_id, turn_id, agent_id, run_id
STREAM and ASYNC_STREAM raise ValueError if delivery.has_streaming() is false.

Best Practices

Fields are frozen — mutate via hooks, not assignment.
Do not cache plans across turns in multi-agent setups.
It is a module-level singleton — no need to instantiate your own builder.
Enable DeliveryChannels(enable_streaming=True, ...) before choosing stream modes.

Runtime Selection

Model-scoped runtime configuration

Streaming

Stream agent output token-by-token