Skip to content

0.9.0-preview.15

Pre-release
Pre-release

Choose a tag to compare

@Blind-Striker Blind-Striker released this 01 Nov 10:26
0abcae5

The SDK speaks opencode 2.2.x and allocates much less. The pinned server moves from 2.1.4 to
2.2.5. That moves the session log to ExperimentalClient, changes several generated protocol models
(listed below), and adds experimental schedules, artifacts, image and decision generation, usage
limits and file watching, a types filter on the event stream, and renaming of persistent terminals.
Open enums become generated extensible enums. On .NET 10, a prompt's event stream allocates about a
third less per frame, a one-shot call about a quarter less, and a 16 KiB terminal paste about 1 KB
instead of about 17 KB; the Performance section has the figures and the two trade-offs.

💥 Breaking changes

  • The upstream pin moves to opencode v2.2.5. Most entries below follow a change upstream made
    between v2.1.4 and v2.2.5. The open-enum, IMcp, savedPermissionId, OnStart and Optional<T>
    entries are the SDK's own.
  • The session log moves to ExperimentalClient.ReadSessionLogAsync. Upstream serves it as
    experimental.session.log, so SessionClient.ReadLogAsync is gone and SessionLogRequest is
    ExperimentalSessionLogRequest, with the same After and Follow. Migrate
    client.Sessions.GetSessionClient(id).ReadLogAsync(new SessionLogRequest { … }) to
    client.Experimental.ReadSessionLogAsync(id, new ExperimentalSessionLogRequest { … }). The
    session-log types now carry OPENCODE001, the experimental client's diagnostic, and OPENCODE003
    is retired: a suppression of OPENCODE003 becomes one of OPENCODE001.
  • ExperimentalClient.SetVoiceSessionInstructionsAsync is removed, with
    ExperimentalVoiceInstructionsRequest and ExperimentalVoiceInstructionsResponse: upstream
    removed the operation.
  • EventsClient.SubscribeAsync takes an optional EventSubscribeRequest first. Its Types
    limits the stream to the listed event types. A call that passed requestOptions by position
    names it instead: SubscribeAsync(requestOptions: options).
  • Model variants have their own settings type. ModelVariant.Settings is
    ModelVariantSettings? and ConfigModelVariants.Settings is ConfigModelVariantSettings?, as
    upstream separates a variant's settings from a model's.
  • VoiceModel.Integration, VoiceModel.Workspace and ExperimentalVoiceSessionData.Session
    are removed
    , with VoiceSessionReference: upstream no longer declares them.
  • ConfigInfoCompaction.Buffer is ConfigInfoCompactionBuffer?, not long?. Upstream now
    accepts a share of the context window such as "20%" besides a token count, so the value is a
    carrier: Kind says which arm it holds, Text the percentage and WholeNumber the token count.
    Migrate config.Compaction.Buffer to buffer.WholeNumber after checking
    buffer.Kind == ConfigInfoCompactionBufferKind.WholeNumber, and set it with
    ConfigInfoCompactionBuffer.FromWholeNumber(...) or FromText("20%").
  • PersistentPtyInfo.UserTitle is required. It is the title a user gave the terminal, or
    null when none was given; upstream always sends the key, so a terminal from a server that omits
    it no longer deserializes, and an initializer that builds a PersistentPtyInfo must set it.
  • PersistentPtyUpdateRequest.Size is optional (PtySize?), no longer required. Code reading
    it must handle null before accessing its dimensions.
  • Open enums are generated extensible enums, not string. A string enum beside a free string,
    such as a reasoning field's known names, now binds a generated extensible enum that carries any
    other value too. ModelCompatibility.ReasoningField and ProviderCompatibility.ReasoningField
    are ModelReasoningField?, TuiCommandExecuteData.Command is TuiCommandName,
    ConfigWebSearchInfo.Provider is WebSearchProviderChoice, and
    SessionInstructionsUpdatedData.Delta's values are SessionInstructionChange.
    Migrate a comparison with ModelReasoningField.ReasoningContent (or the type's Values strings),
    and read the text with ToString(); nothing on the wire changes.
  • IMcp is now IMcpServerConfig, and UnknownMcp is now UnknownMcpServerConfig.
    The union represents one MCP server's configuration, the value type of ConfigInfoMcp.Servers
    and of ExperimentalMcpAddRequest.Config. Migrate by renaming type references; IMcpTimeout
    keeps its name, and nothing on the wire changes.
  • PermissionsClient.UpdateSavedAsync takes savedPermissionId. Its route value was a bare
    id; it now matches RemoveSavedAsync. Only calls that name the argument (id: …) need to
    change; nothing on the wire changes.
  • OpenCodeServerEnsureOptions.OnStart now takes an OpenCodeServerEnsureStartContext.
    Action<OpenCodeServerEnsureReason, string?> becomes Action<OpenCodeServerEnsureStartContext>.
    Migrate (reason, previous) => … to start => … start.Reason … start.PreviousVersion.
  • Optional<T>.Value is annotated [MaybeNull].
    Reading an Optional<string> (non-nullable T) may produce a new nullable warning.
    Migrate a receiving string local to string? and check for null before dereferencing it.

⚡ Performance

Figures are approximate, from short benchmark runs on .NET 10 unless stated.

  • The event stream and the session log read on bytes. The reader no longer builds a UTF-16 string
    per frame, and it is faster. Its own cost falls from about 5 KB to under 10 B per large frame, and
    from about 25 KB to about 400 B per enumeration. A prompt's event stream allocates about 1,430 B per
    frame instead of about 2,210 B, and the largest session-log items about 5,900 B instead of about
    11,300 B.
  • A one-shot call allocates about a quarter less. About 2,000 B instead of about 2,600 B on a call
    that doesn't suspend (HttpClient alone takes about 940 B), and about 3,400 B instead of about
    3,900 B on one that does. Part of that comes from pooled state-machine boxes on .NET, a saving that
    shrinks as concurrency grows.
  • A JsonElement dictionary shares one document. A large message allocates about 5.1 MB instead of
    about 5.5 MB. The trade-off: a value you keep holds the whole dictionary's JSON alive, and
    Clone() doesn't detach it; JsonElement.Parse(value.GetRawText()) does.
  • On net472 and netstandard2.0, a known union tag allocates no marker string. A large message
    allocates about 5.2 MB instead of about 5.4 MB on net472.
  • A terminal connection reuses a pooled 16 KiB receive buffer. It rents it from the shared array
    pool for as long as the connection reads, so a connection after the first usually allocates about
    16 KB less.
  • Terminal input reuses a pooled buffer for the message it sends. A 16 KiB paste allocates about
    1 KB instead of about 17 KB; a pool miss still allocates one. The buffer is cleared when it goes back
    to the pool, because input can carry typed secrets, and that isn't a process-memory guarantee: the
    socket keeps its own buffer. A persistent paste on net472 takes about 3.7 µs instead of about 2.0 µs;
    how much of that is the clearing wasn't measured.
  • A PtySession frame keeps the UTF-8 it was received as. PtyOutputFrame.Text decodes on its
    first read, with the same replacement decoding, and every read returns the same string. A queued
    frame of mostly ASCII output now holds about half what it did; box-drawing and CJK output holds about
    1.5 times more, since those characters take 3 bytes in UTF-8 and 2 in UTF-16. The trade-off: the
    decode moves to the consumer's first read, so draining a queued burst takes longer.

🔧 Changes

  • Rename persistent terminals through PersistentPtyClient.UpdateAsync. Set Title to a non-empty string,
    or null to clear the user's title; a terminal service that predates renaming answers 501 with
    PtyFeatureUnsupportedError.
  • Deleting a session now removes its persistent terminals.
  • The operations the refresh adds. ExperimentalClient gains WatchFileAsync,
    UnwatchFileAsync, GenerateDecisionsAsync, GenerateImagesAsync, GetMediaAsync,
    GetUsageLimitsAsync, and the schedule operations CreateScheduleAsync, GetScheduleAsync,
    ListSchedulesAsync, PauseScheduleAsync, ResumeScheduleAsync and DeleteScheduleAsync;
    PluginsClient gains GetGuiAsync. event.subscribe takes a types filter of EventType
    values, and model.list takes a types filter. Upstream's legacy text generation endpoint is
    left out, as both of upstream's own clients leave it out.
    New members follow upstream too, among them SessionInfoTime.Busy, a Cache setting on models
    and providers, ConfigInfo.Timezone and VcsDiffRequest.Untracked, and a local plugin's
    PluginSourceLocal.Path is now the path it was configured with.
    ExperimentalClient also gains the artifacts operations
    ListArtifactsAsync, GetArtifactAsync, CreateArtifactAsync, UpdateArtifactAsync,
    DeleteArtifactAsync, ListArtifactProvidersAsync and GetArtifactFileAsync; they need
    experimental.artifacts in the location's config. The event stream gains ArtifactUpdated and
    PersistentPtyUpdated, the error family gains ArtifactNotFoundError and
    PtyFeatureUnsupportedError, ConfigInfoExperimental gains Artifacts, and policy actions
    gain integration.connect, mcp.use, skill.use and plugin.use. A schedule's condition is a
    shell check or a Code Mode script: ScheduleInfo.If and Until are IScheduleCondition?, and
    ScheduleConditionInput is built with FromScheduleConditionInputRun or
    FromScheduleConditionInputCode. Other new members include ConfigInfoExperimental.Schedules,
    MediaBlob and ImageGenerate, PromptInputFileAttachment.Source, ModelCompatibility.MediaInput,
    ModelInfo.Type, ServerInfo.Hostname, FileDiffInfo.More, McpServer.Title and
    PluginFeatures.Gui.
  • Clearer IntelliSense documentation. EnumerateSessionsAsync and EnumerateMessagesAsync
    link their page methods and carry those methods' summaries; server.connected renders as code in
    SubscribeAsync's remarks.
  • Known stream tags can now arrive as the unknown arm. On event.subscribe and the session log,
    a frame whose normal decoding fails arrives as UnknownEvent or UnknownSessionLogItem when
    the existing carrier can preserve it; its neighbours continue on the same connection or request.
    Invalid JSON and carrier refusals keep their original failures.
  • The streaming guide's "a server upgrade cannot break your event loop" promise is now scoped
    tolerance
    , including the payloads that still fail and when a regenerated frame becomes typed.
  • Match stream boundaries on Type. A loop that detects a reconnect with is EventServerConnected
    or a replay boundary with is EventLogSynced should match Type against "server.connected" or
    "log.synced" instead: a drifted marker can now arrive as the unknown arm. The same holds for a
    turn's end ("session.execution.succeeded", "session.execution.failed",
    "session.execution.interrupted"); the streaming guide's EndsTurn and SessionOf helpers also
    read the session of an unknown arm from its payload.
  • The event stream's connect-bound failure names its case. Before any response it says "The
    opencode server did not answer the event stream request within 2 seconds."; when headers arrived
    but no first event followed it says "The opencode server answered the event stream request but
    sent no event within 2 seconds." Both replace "The opencode event stream did not connect within 2
    seconds."
  • IntelliSense explains the event stream and session members. EventsClient.SubscribeAsync's
    XML now states the reconnect and termination contract; the session list's archive filter and the
    two idle timestamps now state their meaning or unit.
  • The guides explain file-system entry path formats and timestamp units, including
    provider-specific voice expiry and the persistent-PTY handoff's expiry in milliseconds since the
    Unix epoch.
  • Repeated JSON literals in a JsonElement dictionary no longer compare equal by default.
    Repeated true, false and null values no longer compare equal under JsonElement's default
    equality; compare JSON values with JsonElement.DeepEquals, as System.Text.Json recommends.

🐛 Fixes

  • Response envelope logging keeps the page cursor and resolved location. ToString() now
    includes Cursor and Location when the response has them, so a logged page such as
    SessionListResponse keeps its continuation token.
  • On Windows, an event stream to a refused loopback port reports the refusal. A .NET connect
    to a closed loopback port is refused there only after about two seconds, so every attempt ran into
    the stream's two-second connect bound, and the subscription gave up with "did not connect within 2
    seconds", which reads like a slow server. On .NET 5 and later the SDK's own transport now
    connects loopback targets without SYN retransmission, as upstream's runtime does, and the give-up
    says "The opencode server could not be reached." with the refusal inside; on .NET Framework the
    connect keeps its retransmissions and reports through the "did not answer" text.
  • A NUL in a launcher command, environment entry or working directory is refused before the
    command is resolved.
    OpenCodeServer.StartAsync refuses a NUL in an
    OpenCodeServerOptions.Command or OpenCodeServerOptions.Environment entry, or in
    OpenCodeServerOptions.WorkingDirectory, with ArgumentException before it looks the command
    up. A bare command name no longer reports first that it was not found on PATH, a working
    directory is no longer cut short at the NUL, and the exception's ParamName is options, the
    public parameter, instead of an internal name.
  • A standalone start's failure message keeps at most 8,192 characters of stderr. The stderr
    tail in an OpenCodeServerException from OpenCodeServer.StartAsync was bounded only to its
    last 40 lines, so one very long line went into the message whole. The tail now also keeps at most
    the last 8,192 characters of text, so its size is bounded, as the background-service start's
    already is.
  • The background-service door refuses a NUL in a command entry. OpenCodeServer.EnsureAsync
    refused a NUL in an OpenCodeServerEnsureOptions.Environment entry but not in a Command entry,
    so a command entry with a NUL could reach the contender's spawn and be cut short there. It now
    refuses it with ArgumentException for options before the registration is read or anything is
    spawned, as it does for the environment.
  • On Windows, a background service's environment now resolves a key that differs only in case as
    upstream does.
    The first spelling in ordinal order wins, whichever side set it. Before, a
    saved or caller entry always replaced the host's value, so a saved xdg_state_home moved the
    registration away from clients looking under the host's root. A caller's PATH still replaces
    the host's Path.
  • A saved XDG_STATE_HOME no longer moves a background service. EnsureAsync used to pass the
    channel's saved value to the service it spawned, which moved the registration away from every
    client looking for it. A value saved under that exact spelling is now ignored, as the CLI ignores
    it; a caller's own Environment entry still applies.
  • A persistent PTY's bad Cwd is now refused. A given Cwd whose path doesn't exist or isn't a
    directory used to start the terminal in the home directory. The server now answers 400 with an
    InvalidRequestError whose Kind is invalid_cwd, and no terminal starts. The SDK's code didn't
    change.

📚 Documentation

  • What an unread terminal costs. The terminals guide now says that a queued frame of either
    terminal family keeps about 1 byte per byte of output, that an unread session through a verbose
    build grows by about 15 MB a minute, and that the queue is unbounded as upstream's is.
  • The guides cover more. Connection modes gain exit kinds, the Windows shim's linger, fixed
    endpoints, cancelled starts and what a server shares or a private launch inherits. New sections cover
    handing events off from a slow handler, what a shell exit does to a normal PTY read, choosing a
    model, scoping session lists, and replaying sessions with fork, revert and export.
  • The requests guide and README are corrected. The requests guide fixes four claims: what an
    unmatched permission rule evaluates to, a worktree's Directory, the collision refusal text, and
    PersistentPtyHandoff.ExpiresAt. The README now says bodies of 1-16 MiB are pooled on net472 and
    netstandard2.0.