Turn
A turn: the agent’s work on a message, from TurnStarted to TurnEnded,
and how it ended. AgentSession.turn succeeds with TurnSucceeded or
fails with a TurnFailure, a Schema-described tagged error. The
TurnEnded event carries the same values in outcome, so a runner can
persist and replay them.
Since v0.3.0
Errors
Section titled “Errors”AgentFailed (class)
Section titled “AgentFailed (class)”The agent’s own failure: model/API error, a failed tool loop, max turns, and so on.
Signature
declare class AgentFailedSince v0.1.0
AuthFailed (class)
Section titled “AuthFailed (class)”Signature
declare class AuthFailedSince v0.1.0
ContextExhausted (class)
Section titled “ContextExhausted (class)”Signature
declare class ContextExhaustedSince v0.1.0
Interrupted (class)
Section titled “Interrupted (class)”The caller interrupted the turn.
Signature
declare class InterruptedSince v0.1.0
ProcessKilled (class)
Section titled “ProcessKilled (class)”The agent process died (signal, OOM killer, crash) rather than ending the turn itself.
Signature
declare class ProcessKilledSince v0.1.0
SpendCapReached (class)
Section titled “SpendCapReached (class)”The run’s spend cap was reached. estimated when the cost is computed from tokens (Codex).
Signature
declare class SpendCapReachedSince v0.1.0
Stalled (class)
Section titled “Stalled (class)”No events for longer than RunOptions.watchdog allows, so the turn was stopped.
Signature
declare class StalledSince v0.1.0
Throttled (class)
Section titled “Throttled (class)”Throttled or overloaded, and the provider gave up retrying. Retries in progress are Retrying events.
Signature
declare class ThrottledSince v0.1.0
TurnFailure
Section titled “TurnFailure”Every way a turn can fail: the error of AgentSession.turn, and the failed TurnEnded outcomes.
Signature
declare const TurnFailure: Schema.Union< readonly [ typeof AgentFailed, typeof UsageLimited, typeof Throttled, typeof AuthFailed, typeof SpendCapReached, typeof ContextExhausted, typeof ProcessKilled, typeof Stalled, typeof Interrupted, ]>Since v0.1.0
TurnFailure (type alias)
Section titled “TurnFailure (type alias)”Signature
type TurnFailure = typeof TurnFailure.TypeSince v0.1.0
UsageLimited (class)
Section titled “UsageLimited (class)”A subscription usage limit stopped the turn.
Signature
declare class UsageLimitedSince v0.1.0
Models
Section titled “Models”TurnId
Section titled “TurnId”Signature
declare const TurnId: Schema.brand<Schema.String, "effect-agent/TurnId">Since v0.1.0
TurnId (type alias)
Section titled “TurnId (type alias)”Signature
type TurnId = typeof TurnId.TypeSince v0.1.0
TurnOutcome
Section titled “TurnOutcome”How a turn ended: TurnSucceeded or a TurnFailure.
Signature
declare const TurnOutcome: Schema.Union< readonly [ Schema.TaggedStruct< "Succeeded", { readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId"> readonly finalText: Schema.String } >, Schema.Union< readonly [ typeof AgentFailed, typeof UsageLimited, typeof Throttled, typeof AuthFailed, typeof SpendCapReached, typeof ContextExhausted, typeof ProcessKilled, typeof Stalled, typeof Interrupted, ] >, ]>Since v0.1.0
TurnOutcome (type alias)
Section titled “TurnOutcome (type alias)”Signature
type TurnOutcome = typeof TurnOutcome.TypeSince v0.1.0
TurnSucceeded
Section titled “TurnSucceeded”The successful TurnOutcome.
Signature
declare const TurnSucceeded: Schema.TaggedStruct< "Succeeded", { readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId"> readonly finalText: Schema.String }>Since v0.1.0
TurnSucceeded (type alias)
Section titled “TurnSucceeded (type alias)”Signature
type TurnSucceeded = typeof TurnSucceeded.TypeSince v0.1.0