Repository navigation
0.9.0-preview.15
Pre-releaseThe 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,OnStartandOptional<T>
entries are the SDK's own. - The session log moves to
ExperimentalClient.ReadSessionLogAsync. Upstream serves it as
experimental.session.log, soSessionClient.ReadLogAsyncis gone andSessionLogRequestis
ExperimentalSessionLogRequest, with the sameAfterandFollow. Migrate
client.Sessions.GetSessionClient(id).ReadLogAsync(new SessionLogRequest { … })to
client.Experimental.ReadSessionLogAsync(id, new ExperimentalSessionLogRequest { … }). The
session-log types now carryOPENCODE001, the experimental client's diagnostic, andOPENCODE003
is retired: a suppression ofOPENCODE003becomes one ofOPENCODE001. ExperimentalClient.SetVoiceSessionInstructionsAsyncis removed, with
ExperimentalVoiceInstructionsRequestandExperimentalVoiceInstructionsResponse: upstream
removed the operation.EventsClient.SubscribeAsynctakes an optionalEventSubscribeRequestfirst. ItsTypes
limits the stream to the listed event types. A call that passedrequestOptionsby position
names it instead:SubscribeAsync(requestOptions: options).- Model variants have their own settings type.
ModelVariant.Settingsis
ModelVariantSettings?andConfigModelVariants.SettingsisConfigModelVariantSettings?, as
upstream separates a variant's settings from a model's. VoiceModel.Integration,VoiceModel.WorkspaceandExperimentalVoiceSessionData.Session
are removed, withVoiceSessionReference: upstream no longer declares them.ConfigInfoCompaction.BufferisConfigInfoCompactionBuffer?, notlong?. Upstream now
accepts a share of the context window such as"20%"besides a token count, so the value is a
carrier:Kindsays which arm it holds,Textthe percentage andWholeNumberthe token count.
Migrateconfig.Compaction.Buffertobuffer.WholeNumberafter checking
buffer.Kind == ConfigInfoCompactionBufferKind.WholeNumber, and set it with
ConfigInfoCompactionBuffer.FromWholeNumber(...)orFromText("20%").PersistentPtyInfo.UserTitleis required. It is the title a user gave the terminal, or
nullwhen 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 aPersistentPtyInfomust set it.PersistentPtyUpdateRequest.Sizeis 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.ReasoningFieldandProviderCompatibility.ReasoningField
areModelReasoningField?,TuiCommandExecuteData.CommandisTuiCommandName,
ConfigWebSearchInfo.ProviderisWebSearchProviderChoice, and
SessionInstructionsUpdatedData.Delta's values areSessionInstructionChange.
Migrate a comparison withModelReasoningField.ReasoningContent(or the type'sValuesstrings),
and read the text withToString(); nothing on the wire changes. IMcpis nowIMcpServerConfig, andUnknownMcpis nowUnknownMcpServerConfig.
The union represents one MCP server's configuration, the value type ofConfigInfoMcp.Servers
and ofExperimentalMcpAddRequest.Config. Migrate by renaming type references;IMcpTimeout
keeps its name, and nothing on the wire changes.PermissionsClient.UpdateSavedAsynctakessavedPermissionId. Its route value was a bare
id; it now matchesRemoveSavedAsync. Only calls that name the argument (id: …) need to
change; nothing on the wire changes.OpenCodeServerEnsureOptions.OnStartnow takes anOpenCodeServerEnsureStartContext.
Action<OpenCodeServerEnsureReason, string?>becomesAction<OpenCodeServerEnsureStartContext>.
Migrate(reason, previous) => …tostart => … start.Reason … start.PreviousVersion.Optional<T>.Valueis annotated[MaybeNull].
Reading anOptional<string>(non-nullableT) may produce a new nullable warning.
Migrate a receivingstringlocal tostring?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 (HttpClientalone 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
JsonElementdictionary 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
PtySessionframe keeps the UTF-8 it was received as.PtyOutputFrame.Textdecodes 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. SetTitleto 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.
ExperimentalClientgainsWatchFileAsync,
UnwatchFileAsync,GenerateDecisionsAsync,GenerateImagesAsync,GetMediaAsync,
GetUsageLimitsAsync, and the schedule operationsCreateScheduleAsync,GetScheduleAsync,
ListSchedulesAsync,PauseScheduleAsync,ResumeScheduleAsyncandDeleteScheduleAsync;
PluginsClientgainsGetGuiAsync.event.subscribetakes atypesfilter ofEventType
values, andmodel.listtakes atypesfilter. 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 themSessionInfoTime.Busy, aCachesetting on models
and providers,ConfigInfo.TimezoneandVcsDiffRequest.Untracked, and a local plugin's
PluginSourceLocal.Pathis now the path it was configured with.
ExperimentalClientalso gains the artifacts operations
ListArtifactsAsync,GetArtifactAsync,CreateArtifactAsync,UpdateArtifactAsync,
DeleteArtifactAsync,ListArtifactProvidersAsyncandGetArtifactFileAsync; they need
experimental.artifactsin the location's config. The event stream gainsArtifactUpdatedand
PersistentPtyUpdated, the error family gainsArtifactNotFoundErrorand
PtyFeatureUnsupportedError,ConfigInfoExperimentalgainsArtifacts, and policy actions
gainintegration.connect,mcp.use,skill.useandplugin.use. A schedule's condition is a
shell check or a Code Mode script:ScheduleInfo.IfandUntilareIScheduleCondition?, and
ScheduleConditionInputis built withFromScheduleConditionInputRunor
FromScheduleConditionInputCode. Other new members includeConfigInfoExperimental.Schedules,
MediaBlobandImageGenerate,PromptInputFileAttachment.Source,ModelCompatibility.MediaInput,
ModelInfo.Type,ServerInfo.Hostname,FileDiffInfo.More,McpServer.Titleand
PluginFeatures.Gui. - Clearer IntelliSense documentation.
EnumerateSessionsAsyncandEnumerateMessagesAsync
link their page methods and carry those methods' summaries;server.connectedrenders as code in
SubscribeAsync's remarks. - Known stream tags can now arrive as the unknown arm. On
event.subscribeand the session log,
a frame whose normal decoding fails arrives asUnknownEventorUnknownSessionLogItemwhen
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 withis EventServerConnected
or a replay boundary withis EventLogSyncedshould matchTypeagainst"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'sEndsTurnandSessionOfhelpers 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
JsonElementdictionary no longer compare equal by default.
Repeatedtrue,falseandnullvalues no longer compare equal underJsonElement's default
equality; compare JSON values withJsonElement.DeepEquals, as System.Text.Json recommends.
🐛 Fixes
- Response envelope logging keeps the page cursor and resolved location.
ToString()now
includesCursorandLocationwhen the response has them, so a logged page such as
SessionListResponsekeeps 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.StartAsyncrefuses a NUL in an
OpenCodeServerOptions.CommandorOpenCodeServerOptions.Environmententry, or in
OpenCodeServerOptions.WorkingDirectory, withArgumentExceptionbefore 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'sParamNameisoptions, 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 anOpenCodeServerExceptionfromOpenCodeServer.StartAsyncwas 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 anOpenCodeServerEnsureOptions.Environmententry but not in aCommandentry,
so a command entry with a NUL could reach the contender's spawn and be cut short there. It now
refuses it withArgumentExceptionforoptionsbefore 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 savedxdg_state_homemoved the
registration away from clients looking under the host's root. A caller'sPATHstill replaces
the host'sPath. - A saved
XDG_STATE_HOMEno longer moves a background service.EnsureAsyncused 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 ownEnvironmententry still applies. - A persistent PTY's bad
Cwdis now refused. A givenCwdwhose 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
InvalidRequestErrorwhoseKindisinvalid_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'sDirectory, the collision refusal text, and
PersistentPtyHandoff.ExpiresAt. The README now says bodies of 1-16 MiB are pooled on net472 and
netstandard2.0.