Skip to content

StreamPart

The parts a harness streams for a turn. They are the parts an Effect AI language model provider streams, in the encoded form LanguageModel.make takes from providers, and four that only an agent produces: a turn starting apart from the host, a step finishing, a file changing, and the conversation being compacted. Code that reads a provider’s stream reads a harness’s, and the parts cross the sandbox boundary as they are.

Tool calls and results name any tool and keep its params and result as they came. An agent runs tools of its own that no toolkit declares, while Effect AI’s decoded tool parts exist only for the tools of a toolkit. Params and results are therefore unknown, as JSON, even for the host’s tools; a caller that needs their types decodes them with the tool’s schemas.

Since v0.1.0

Drops the parts of a turn’s first steps steps, for an agent whose turn kept running to stream it again from the step after those the harness already has, as continueTurn asks.

Signature

declare const afterSteps: (
steps: number
) => <E, R>(self: Stream.Stream<StreamPart, E, R>) => Stream.Stream<StreamPart, E, R>

Source

Since v0.1.0

A turn’s steps, from its parts as far as they go, split at their finish-step parts.

Details

The turn’s finish part ends the turn rather than a step, so no step holds it. A step the parts end before its finish-step comes last when it has parts.

Example (Adding a turn’s parts up into steps)

import { StreamPart } from "@amends-dev/harness"
const steps = StreamPart.stepsOf([
{ type: "text-start", id: "answer" },
{ type: "text-delta", id: "answer", delta: "Hello, " },
{ type: "text-delta", id: "answer", delta: "world." },
{ type: "text-end", id: "answer" },
{ type: "finish-step", reason: "stop", usage: { inputTokens: {}, outputTokens: {} } },
{ type: "finish", reason: "stop", usage: { inputTokens: {}, outputTokens: {} } }
])
// steps[0].parts is [{ type: "text", text: "Hello, world." }]

Signature

declare const stepsOf: (parts: ReadonlyArray<StreamPart>) => ReadonlyArray<Step>

Source

Since v0.1.0

Reports that the agent replaced its conversation so far with a summary, because it was asked to (manual) or because the conversation outgrew its context (auto).

Details

The conversation goes on from the summary and the messages the agent kept, in place of everything before the compaction, as Session.recordStep records it. An agent that compacts during a turn streams the compaction between two steps, so that it starts the step after; AgentSession.compact returns one made between turns.

Signature

declare const CompactionPart: Schema.Struct<{
readonly type: Schema.tag<"compaction">
readonly trigger: Schema.Literals<readonly ["manual", "auto"]>
readonly summary: Schema.String
readonly kept: Schema.optional<
Schema.$Array<Schema.toEncoded<Schema.Codec<Prompt.Message, Prompt.MessageEncoded, never, never>>>
>
readonly tokensBefore: Schema.optional<Schema.Int>
readonly tokensAfter: Schema.optional<Schema.Int>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>

Source

Since v0.1.0

Signature

export interface CompactionPart extends Schema.Schema.Type<typeof CompactionPart> {}

Source

Since v0.1.0

Reports that the agent created, modified, or deleted a file in the sandbox.

Signature

declare const FileChangePart: Schema.Struct<{
readonly type: Schema.tag<"file-change">
readonly event: Schema.Literals<readonly ["create", "modify", "delete"]>
readonly path: Schema.String
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>

Source

Since v0.1.0

Signature

export interface FileChangePart extends Schema.Schema.Type<typeof FileChangePart> {}

Source

Since v0.1.0

Ends one step of a turn: one response from the model and the tool calls it made. A turn takes one or more steps, and its finish part reports the whole turn’s usage.

Signature

declare const FinishStepPart: Schema.Struct<{
readonly type: Schema.tag<"finish-step">
readonly reason: Schema.Literals<
["stop", "length", "content-filter", "tool-calls", "error", "pause", "other", "unknown"]
>
readonly usage: Schema.toEncoded<typeof Response.Usage>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>

Source

Since v0.1.0

Signature

export interface FinishStepPart extends Schema.Schema.Type<typeof FinishStepPart> {}

Source

Since v0.1.0

One step of a turn: what the model wrote, the tools it called and their results, in the order the step streamed them, and the finish-step part that ended it.

Details

A step the turn ended partway through, by failing or being stopped, has what it streamed so far and no finish. A step is JSON, for callers that store a turn’s steps.

Signature

declare const Step: Schema.Struct<{
readonly parts: Schema.$Array<
Schema.Union<
readonly [
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"text">
readonly text: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"reasoning">
readonly text: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"tool-call">
readonly id: Schema.String
readonly name: Schema.String
readonly params: Schema.Unknown
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"tool-result">
readonly id: Schema.String
readonly name: Schema.String
readonly result: Schema.Unknown
readonly isFailure: Schema.Boolean
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly preliminary: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-approval-request">
readonly approvalId: Schema.String
readonly toolCallId: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"file">
readonly mediaType: Schema.String
readonly data: Schema.Uint8ArrayFromBase64
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"document">
readonly id: Schema.String
readonly mediaType: Schema.String
readonly title: Schema.String
readonly fileName: Schema.optionalKey<Schema.String>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"url">
readonly id: Schema.String
readonly url: Schema.URLFromString
readonly title: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"response-metadata">
readonly id: Schema.optional<Schema.String>
readonly modelId: Schema.optional<Schema.String>
readonly timestamp: Schema.optional<Schema.DateTimeUtcFromString>
readonly request: Schema.optional<typeof Response.HttpRequestDetails>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"error">
readonly error: Schema.Unknown
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"file-change">
readonly event: Schema.Literals<readonly ["create", "modify", "delete"]>
readonly path: Schema.String
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"compaction">
readonly trigger: Schema.Literals<readonly ["manual", "auto"]>
readonly summary: Schema.String
readonly kept: Schema.optional<
Schema.$Array<Schema.toEncoded<Schema.Codec<Prompt.Message, Prompt.MessageEncoded, never, never>>>
>
readonly tokensBefore: Schema.optional<Schema.Int>
readonly tokensAfter: Schema.optional<Schema.Int>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>
]
>
>
readonly finish: Schema.optional<
Schema.Struct<{
readonly type: Schema.tag<"finish-step">
readonly reason: Schema.Literals<
["stop", "length", "content-filter", "tool-calls", "error", "pause", "other", "unknown"]
>
readonly usage: Schema.toEncoded<typeof Response.Usage>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>
>
}>

Source

Since v0.1.0

Signature

export interface Step extends Schema.Schema.Type<typeof Step> {}

Source

Since v0.1.0

A part of a step as the step’s stream adds up: a text or a reasoning whole rather than its deltas, a tool call without the params it streamed on its way, and a tool’s final result.

Details

These are the parts Effect AI’s generateText returns for a response, and those only an agent produces.

Signature

declare const StepPart: Schema.Union<
readonly [
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"text">
readonly text: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"reasoning">
readonly text: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"tool-call">
readonly id: Schema.String
readonly name: Schema.String
readonly params: Schema.Unknown
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"tool-result">
readonly id: Schema.String
readonly name: Schema.String
readonly result: Schema.Unknown
readonly isFailure: Schema.Boolean
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly preliminary: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-approval-request">
readonly approvalId: Schema.String
readonly toolCallId: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"file">
readonly mediaType: Schema.String
readonly data: Schema.Uint8ArrayFromBase64
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"document">
readonly id: Schema.String
readonly mediaType: Schema.String
readonly title: Schema.String
readonly fileName: Schema.optionalKey<Schema.String>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"url">
readonly id: Schema.String
readonly url: Schema.URLFromString
readonly title: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"response-metadata">
readonly id: Schema.optional<Schema.String>
readonly modelId: Schema.optional<Schema.String>
readonly timestamp: Schema.optional<Schema.DateTimeUtcFromString>
readonly request: Schema.optional<typeof Response.HttpRequestDetails>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"error">
readonly error: Schema.Unknown
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"file-change">
readonly event: Schema.Literals<readonly ["create", "modify", "delete"]>
readonly path: Schema.String
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"compaction">
readonly trigger: Schema.Literals<readonly ["manual", "auto"]>
readonly summary: Schema.String
readonly kept: Schema.optional<
Schema.$Array<Schema.toEncoded<Schema.Codec<Prompt.Message, Prompt.MessageEncoded, never, never>>>
>
readonly tokensBefore: Schema.optional<Schema.Int>
readonly tokensAfter: Schema.optional<Schema.Int>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>
]
>

Source

Since v0.1.0

Signature

type StepPart = typeof StepPart.Type

Source

Since v0.1.0

A part of a turn’s stream: an Effect AI provider’s part in its encoded form, or one of the four only an agent produces.

Signature

declare const StreamPart: Schema.Union<
readonly [
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"text-start">
readonly id: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"text-delta">
readonly id: Schema.String
readonly delta: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"text-end">
readonly id: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"reasoning-start">
readonly id: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"reasoning-delta">
readonly id: Schema.String
readonly delta: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"reasoning-end">
readonly id: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-params-start">
readonly id: Schema.String
readonly name: Schema.String
readonly providerExecuted: Schema.withDecodingDefaultKey<Schema.Boolean>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-params-delta">
readonly id: Schema.String
readonly delta: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-params-end">
readonly id: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"tool-call">
readonly id: Schema.String
readonly name: Schema.String
readonly params: Schema.Unknown
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"tool-result">
readonly id: Schema.String
readonly name: Schema.String
readonly result: Schema.Unknown
readonly isFailure: Schema.Boolean
readonly providerExecuted: Schema.optional<Schema.Boolean>
readonly preliminary: Schema.optional<Schema.Boolean>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"tool-approval-request">
readonly approvalId: Schema.String
readonly toolCallId: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"file">
readonly mediaType: Schema.String
readonly data: Schema.Uint8ArrayFromBase64
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"document">
readonly id: Schema.String
readonly mediaType: Schema.String
readonly title: Schema.String
readonly fileName: Schema.optionalKey<Schema.String>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"source">
readonly sourceType: Schema.tag<"url">
readonly id: Schema.String
readonly url: Schema.URLFromString
readonly title: Schema.String
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"response-metadata">
readonly id: Schema.optional<Schema.String>
readonly modelId: Schema.optional<Schema.String>
readonly timestamp: Schema.optional<Schema.DateTimeUtcFromString>
readonly request: Schema.optional<typeof Response.HttpRequestDetails>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"finish">
readonly reason: Schema.Literals<
["stop", "length", "content-filter", "tool-calls", "error", "pause", "other", "unknown"]
>
readonly usage: typeof Response.Usage
readonly response: Schema.optional<typeof Response.HttpResponseDetails>
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.toEncoded<
Schema.Struct<{
readonly type: Schema.tag<"error">
readonly error: Schema.Unknown
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
readonly metadata: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>>
}>
>,
Schema.Struct<{
readonly type: Schema.tag<"finish-step">
readonly reason: Schema.Literals<
["stop", "length", "content-filter", "tool-calls", "error", "pause", "other", "unknown"]
>
readonly usage: Schema.toEncoded<typeof Response.Usage>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"file-change">
readonly event: Schema.Literals<readonly ["create", "modify", "delete"]>
readonly path: Schema.String
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"compaction">
readonly trigger: Schema.Literals<readonly ["manual", "auto"]>
readonly summary: Schema.String
readonly kept: Schema.optional<
Schema.$Array<Schema.toEncoded<Schema.Codec<Prompt.Message, Prompt.MessageEncoded, never, never>>>
>
readonly tokensBefore: Schema.optional<Schema.Int>
readonly tokensAfter: Schema.optional<Schema.Int>
readonly metadata: Schema.optional<
Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>>
>
}>,
Schema.Struct<{
readonly type: Schema.tag<"turn-start">
readonly agentState: Schema.Codec<Schema.Json, Schema.Json, never, never>
}>
]
>

Source

Since v0.1.0

Signature

type StreamPart = Superset<typeof StreamPart.Type, Response.StreamPartEncoded>

Source

Since v0.1.0

Starts a turn that runs apart from the host, as in a sandbox, with what createSession takes as the unfinished turn’s agentState.

Details

A caller that keeps it continues the turn with continueStream once the host that ran it is gone, catching up on the steps it does not have.

Signature

declare const TurnStartPart: Schema.Struct<{
readonly type: Schema.tag<"turn-start">
readonly agentState: Schema.Codec<Schema.Json, Schema.Json, never, never>
}>

Source

Since v0.1.0

Signature

export interface TurnStartPart extends Schema.Schema.Type<typeof TurnStartPart> {}

Source

Since v0.1.0