Skip to main content
AgentTurn represents one live execution of an Agent. Create one with agent.turn(...). Do not instantiate AgentTurn directly unless you are extending the framework.

Import

Constructor

Normally called internally by:

Properties

str
Unique turn ID.
str
ID of the owning agent.
Agent[Any]
Owning agent instance.
Message
Initial user message for the turn.
TurnOptions
Per-turn options.
bool
True after the turn has started.
bool
True after the turn finishes, fails, or is aborted.

events

Starts the turn if needed and yields typed lifecycle events.
Common event types: Returns:
AsyncIterator[TurnEvent]
Stream of turn events. The iterator ends after turn.finished or turn.failed.

text_stream

Convenience stream over events() that yields only text.delta text.

result

Starts the turn if needed and waits for the structured result. Returns:
TurnResult
Final structured result.
Raises:
Exception
Raised if the turn is aborted.
Exception
Propagates provider, tool, or runtime failures.

wait

Alias for result().

send

Queues a steering message for the next safe step boundary. Parameters:
Content
required
Message content to inject into the active turn.
Literal['user', 'system']
Role for the injected message. Defaults to "user".
Notes:
  • send() does not mutate a provider request already in flight.
  • queued messages are injected before the next model call.
  • queued messages are scoped to this turn.

steer

Alias for send().

abort

Aborts the turn. Parameters:
str | None
Optional abort reason.

TurnOptions

Fields:
ToolSet | None
Per-turn tools. Defaults to the agent’s tools.
StopCondition | list[StopCondition] | None
Per-turn stop conditions. Defaults to the agent’s stop_when.
ReasoningConfig | None
Per-turn reasoning controls. Defaults to the agent’s reasoning.
ProviderOptions | None
Per-turn provider options. Defaults to the agent’s provider_options.
RetryPolicy | None
Per-turn provider-call retry policy. Defaults to the agent’s retry.
AbortSignal | None
External abort signal that also aborts the turn.
AgentHooks | None
Per-turn hook overrides. These merge over agent-level default hooks.
dict[str, Any]
Application metadata. Not sent to the provider by default.

TurnResult

TurnEvent

TurnStarted

TextDelta

ReasoningDelta

StepStarted

StepFinished

usage is the provider-reported usage for this step.

StepRetrying

Tool lifecycle events

AgentTurn forwards the same ToolCallStartedEvent, ToolCallDeltaEvent, ToolCallReadyEvent, ToolExecutionStartedEvent, ToolExecutionFinishedEvent, and ToolResultEvent objects exposed by stream_text().event_stream. This preserves tool call IDs, provider indexes, execution completion order, and normalized results across core and agent APIs.

TurnFinished

TurnFailed

Example

See Also