Skip to main content

PreparedTurnContext

Defined in the Turn Context module.
AI Agent Immutable turn plan object for standardized runtime execution. This dataclass captures all the context needed for a single agent turn, prepared in a preflight step before run_attempt. It eliminates the scattered tool assembly and message building across different execution paths. The context is read-only during execution - mutations must go through defined hooks only. This ensures consistent behavior across different runtime harnesses (native, plugin, managed, etc.). Attributes: model_ref: Resolved model configuration and capabilities agent_runtime: The runtime protocol instance to execute with tools: Normalized tool schemas for the turn transcript: Prepared conversation window for the turn delivery: Streaming and output delivery configuration correlation: Session and tracing identifiers runtime_mode: Execution mode (sync/async/stream) turn_metadata: Additional turn-specific metadata created_at: Timestamp when context was prepared

Properties

ModelReference
No description available.
AgentProtocol
No description available.
Tuple[ToolSchema, ...]
No description available.
TranscriptWindow
No description available.
DeliveryChannels
No description available.
SessionCorrelation
No description available.
RuntimeMode
No description available.
Mapping[str, Any]
No description available.
float
No description available.

Methods

get_tool_by_name()

Get a tool by name from the prepared tools.

has_tools()

Check if any tools are available for this turn.

has_system_prompt()

Check if a system prompt is configured.

get_message_count()

Get the number of messages in the transcript window.
  • to_dict: Convert to dictionary for logging and debugging.

Source

View on GitHub

praisonaiagents/runtime/turn_context.py at line 174

Context Concept

Context Management

Context Strategies