Skip to content

AgentEvent

The normalized event stream. Every event keeps the provider’s original frame in raw so it can be persisted as-is; anything not mapped comes through as Other.

Since v0.1.0

Every event a session or Agent.history emits.

Signature

declare const AgentEvent: Schema.Union<
readonly [
Schema.TaggedStruct<
"SessionStarted",
{
readonly sessionId: Schema.brand<Schema.String, "effect-agent/SessionId">
readonly provider: Schema.String
readonly version: Schema.NullOr<Schema.String>
readonly model: Schema.NullOr<Schema.String>
readonly resumed: Schema.Boolean
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"TurnStarted",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"MessageLanded",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"MessageDropped",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly reason: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"UserMessage",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly messageId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/MessageId">
>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Text",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"ToolCall",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly callId: Schema.String
readonly name: Schema.String
readonly summary: Schema.String
readonly input: Schema.Unknown
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"ToolResult",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly callId: Schema.String
readonly isError: Schema.Boolean
readonly output: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Retrying",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly attempt: Schema.NullOr<Schema.Number>
readonly maxAttempts: Schema.NullOr<Schema.Number>
readonly delayMs: Schema.NullOr<Schema.Number>
readonly message: Schema.String
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"LimitsUpdated",
{
readonly windows: Schema.$Array<
Schema.Struct<{
readonly window: Schema.Literals<readonly ["five_hour", "weekly", "other"]>
readonly label: Schema.String
readonly usedPercent: Schema.NullOr<Schema.Number>
readonly resetsAt: Schema.NullOr<Schema.DateTimeUtcFromMillis>
readonly model: Schema.OptionFromNullOr<Schema.String>
}>
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Compacted",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly trigger: Schema.NullOr<Schema.Literals<readonly ["auto", "manual"]>>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"Heartbeat",
{
readonly turnId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/TurnId">
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<
"TurnEnded",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly outcome: 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,
]
>,
]
>
readonly usage: Schema.NullOr<
Schema.Struct<{
readonly inputTokens: Schema.Number
readonly cachedInputTokens: Schema.Number
readonly outputTokens: Schema.Number
readonly reasoningTokens: Schema.NullOr<Schema.Number>
}>
>
readonly cost: Schema.NullOr<
Schema.Struct<{
readonly usd: Schema.Number
readonly source: Schema.Literals<readonly ["reported", "estimated"]>
}>
>
readonly raw: Schema.Unknown
}
>,
Schema.TaggedStruct<"Other", { readonly raw: Schema.Unknown }>,
]
>

Source

Since v0.1.0

Signature

type AgentEvent = typeof AgentEvent.Type

Source

Since v0.1.0

The provider compacted the session’s context.

Signature

declare const Compacted: Schema.TaggedStruct<
"Compacted",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly trigger: Schema.NullOr<Schema.Literals<readonly ["auto", "manual"]>>
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

The agent is alive and working (thinking, streaming, tool progress) without a user-visible event.

Signature

declare const Heartbeat: Schema.TaggedStruct<
"Heartbeat",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

The provider reported new usage-limit window status.

Signature

declare const LimitsUpdated: Schema.TaggedStruct<
"LimitsUpdated",
{
readonly windows: Schema.$Array<
Schema.Struct<{
readonly window: Schema.Literals<readonly ["five_hour", "weekly", "other"]>
readonly label: Schema.String
readonly usedPercent: Schema.NullOr<Schema.Number>
readonly resetsAt: Schema.NullOr<Schema.DateTimeUtcFromMillis>
readonly model: Schema.OptionFromNullOr<Schema.String>
}>
>
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

The provider refused, cancelled or discarded a message before it reached a turn.

Signature

declare const MessageDropped: Schema.TaggedStruct<
"MessageDropped",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly reason: Schema.String
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

A message from send, steer or turn was taken into a turn.

Signature

declare const MessageLanded: Schema.TaggedStruct<
"MessageLanded",
{
readonly messageId: Schema.brand<Schema.String, "effect-agent/MessageId">
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

A provider frame with no normalized mapping.

Signature

declare const Other: Schema.TaggedStruct<"Other", { readonly raw: Schema.Unknown }>

Source

Since v0.1.0

The provider is retrying a failed request; not an error unless the turn later ends Throttled.

Signature

declare const Retrying: Schema.TaggedStruct<
"Retrying",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly attempt: Schema.NullOr<Schema.Number>
readonly maxAttempts: Schema.NullOr<Schema.Number>
readonly delayMs: Schema.NullOr<Schema.Number>
readonly message: Schema.String
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

Signature

declare const SessionStarted: Schema.TaggedStruct<
"SessionStarted",
{
readonly sessionId: Schema.brand<Schema.String, "effect-agent/SessionId">
readonly provider: Schema.String
readonly version: Schema.NullOr<Schema.String>
readonly model: Schema.NullOr<Schema.String>
readonly resumed: Schema.Boolean
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

A complete block of assistant text.

Signature

declare const Text: Schema.TaggedStruct<
"Text",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

Signature

declare const ToolCall: Schema.TaggedStruct<
"ToolCall",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly callId: Schema.String
readonly name: Schema.String
readonly summary: Schema.String
readonly input: Schema.Unknown
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

The result of a ToolCall with the same callId.

Signature

declare const ToolResult: Schema.TaggedStruct<
"ToolResult",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly callId: Schema.String
readonly isError: Schema.Boolean
readonly output: Schema.String
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

Terminal event for a turn. usage is this turn’s; cost is cumulative for the session when known.

Signature

declare const TurnEnded: Schema.TaggedStruct<
"TurnEnded",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly outcome: 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,
]
>,
]
>
readonly usage: Schema.NullOr<
Schema.Struct<{
readonly inputTokens: Schema.Number
readonly cachedInputTokens: Schema.Number
readonly outputTokens: Schema.Number
readonly reasoningTokens: Schema.NullOr<Schema.Number>
}>
>
readonly cost: Schema.NullOr<
Schema.Struct<{
readonly usd: Schema.Number
readonly source: Schema.Literals<readonly ["reported", "estimated"]>
}>
>
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

Signature

declare const TurnStarted: Schema.TaggedStruct<
"TurnStarted",
{
readonly turnId: Schema.brand<Schema.String, "effect-agent/TurnId">
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0

A user message. Emitted by history; live sessions report their own messages as MessageLanded.

Signature

declare const UserMessage: Schema.TaggedStruct<
"UserMessage",
{
readonly turnId: Schema.NullOr<Schema.brand<Schema.String, "effect-agent/TurnId">>
readonly messageId: Schema.NullOr<
Schema.brand<Schema.String, "effect-agent/MessageId">
>
readonly text: Schema.String
readonly raw: Schema.Unknown
}
>

Source

Since v0.1.0