Skip to main content

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

Classes

RuntimeMode

Execution mode for the runtime.

ModelReference

Immutable reference to a resolved model configuration.

ToolSchema

Normalized tool schema for runtime execution.

TranscriptWindow

Immutable transcript window for a turn.

DeliveryChannels

Delivery channels for runtime execution results.

SessionCorrelation

Session correlation identifiers for tracing and debugging.

PreparedTurnContext

Immutable turn plan object for standardized runtime execution.

Functions

create_default_model_ref()

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.

Context Concept

Context Management

Context Strategies