Golem Streaming Agent Effect

Adds nested input and output streams to Effect Golem agents. Use for incremental or large RPC values.

golemcloud caa5811 1.3 KB Updated

File contents

Effect agent streams

Declare streams with the SDK schema and use native Effect streams:

import { Effect, Stream, Schema } from "effect"
import { method, WitTypes } from "@golemcloud/effect-golem"

const doubled = method({
  input: { values: WitTypes.AgentStream(Schema.Number) },
  success: WitTypes.AgentStream(Schema.Number),
})

const handler = ({ values }: { values: Stream.Stream<number, unknown> }) =>
  Effect.succeed(values.pipe(Stream.map((value) => value * 2)))

Local streams are reusable. Streams received from Preview 3 endpoints are affine and single-reader: consume or forward them exactly once. Keep consumption and RPC clients scoped. Streams may be nested in structs. Never convert a potentially large stream to an array just to cross RPC; interruption must release the producer.

Transformations remain lazy: a mapped or effectfully constructed stream claims its underlying received endpoint when execution reaches it, not when the program is encoded for RPC. Directly forwarding a known received endpoint transfers ownership immediately. Competing consumers fail; they never consume or close the endpoint owned by the successful reader.

golemcloud/golem/tree/main/golem-skills/skills/effect/golem-streaming-agent-effect commit caa5811198

Frequently asked questions

npx skillmds@latest add golemcloud/golem-streaming-agent-effect