One-shot streaming session lifecycle.
Starts a store and adapter under supervision, runs SessionManager.run_once
in a monitored task, and exposes the event stream as a lazy Stream.resource.
Usage
{:ok, stream, close_fun, meta} =
StreamSession.start(
adapter: {ClaudeAdapter, model: Models.default_model(:claude)},
input: %{messages: [%{role: "user", content: "Hello"}]}
)
stream
|> Stream.each(&IO.inspect/1)
|> Stream.run()
close_fun.()With existing store and adapter
{:ok, stream, close_fun, meta} =
StreamSession.start(
store: existing_store_pid,
adapter: existing_adapter_pid,
input: %{messages: [%{role: "user", content: "Hello"}]}
)Options
:adapter— Required.{AdapterModule, opts}tuple or a pid of a running adapter.:input— Required. Input map forSessionManager.run_once/4.:store— Optional. Pid of an existing SessionStore. Defaults to starting an InMemorySessionStore.:agent_id— Optional. Agent identifier for the session.:run_opts— Optional. Additional keyword opts forwarded toSessionManager.run_once/4.:idle_timeout— Optional. Stream idle timeout in ms. Default: 120_000.:shutdown_timeout— Optional. Task shutdown grace period in ms. Default: 5_000.
Summary
Types
Functions
@spec start(keyword()) :: {:ok, Enumerable.t(), close_fun(), meta()} | {:error, term()}