Skip to main content
AgentTurn is the advanced agent primitive for interactive runtimes. Use it when chat() and stream() are too flat and your application needs lifecycle events, a structured final result, cancellation, or the ability to steer the model while it is working.

Why Turns Exist

Agents already provide simple methods:
Those are great for apps that only need a response. Live runtimes need more:
  • emit text as it streams
  • show step status
  • display reasoning events
  • cancel a run
  • inject new user guidance before the next model step
  • wait for the structured final result after streaming events
That is what agent.turn() is for.

Basic Turn

turn.events() starts the turn lazily. turn.result() also starts it if it has not started yet.

Event Stream

Current turn events:

Steering

Use send() to steer a live turn.
Steering is safe-boundary control. The message is queued and injected before the next model call. It does not mutate a provider request already in flight, and it does not interrupt a tool that is already running. steer() is an alias for send():

Cancellation

Aborting signals the active turn. Providers and tools must honor abort signals to stop immediately; otherwise cancellation happens at the next point the runtime checks the signal.

SSE Example

CLI Example

When Not To Use Turns

Do not start with AgentTurn for simple apps. Use:
  • chat() when you only need text
  • stream() when you only need streamed text
  • run() when you need metadata after completion
  • turn() when you need a live runtime