Turn Context • AI Agent SDK
Turn Context and Runtime Protocol for PraisonAI Agents.
turn_context
AI Agent
Turn Context and Runtime Protocol for PraisonAI Agents.
This module defines the PreparedTurnContext dataclass and TurnRuntimeProtocol that standardize runtime preparation across different execution paths in the PraisonAI agent framework.
Design Goals:
- Single immutable plan object passed into runtime run_turn
- Standardize tool assembly, transcript building, and delivery channels
- Eliminate duplication between native loop and plugin harnesses
- Enable consistent metrics and tracing across harness types
- Multi-agent safe: context is per-turn, not stored on shared agent globals
Import
from praisonaiagents.runtime import turn_contextClasses
Execution mode for the runtime.
ModelReferenceImmutable reference to a resolved model configuration.
ToolSchemaNormalized tool schema for runtime execution.
TranscriptWindowImmutable transcript window for a turn.
DeliveryChannelsDelivery channels for runtime execution results.
SessionCorrelationSession correlation identifiers for tracing and debugging.
PreparedTurnContextImmutable turn plan object for standardized runtime execution.
Functions
Create a default ModelReference for testing and basic usage.
create_empty_transcript()Create an empty transcript window with optional system prompt.
create_default_delivery()Create default delivery channels with no streaming.
create_session_correlation()Create session correlation with basic IDs.