Skip to content

Upgrade: session-scoped workspaces ​

This page covers the session-scoped workspace releases, from @helix-agents/core 15.0.0 through the d5 release (core 25.0.0): the steps of the session-scoped workspaces design (spec). Each release has its own section: what to do, then what changed.

What to do, by release ​

  1. Phase 1 (core 15.0.0): delete a session's workspace from your own session deletion (executor.destroyWorkspace(sessionId)), schedule provider.reap({ olderThan }), route a session to one replica for a host-bound provider, handle workspace_unavailable, and add 'unavailable' to exhaustive switches over WorkspaceEntryStateKind.
  2. d1: the workspace binding: upgrade the stores and runtimes with core; a custom state store implements updateWorkspaceBinding; a hand-built DefaultWorkspaceRegistry takes initialBinding; remove adoptWorkspaceRefWrites / WorkspaceRefWrite; choose WorkspaceConfig.onUnavailable.
  3. d2: provider durability and destroy: pass the Cloudflare sandbox's required scope, remove destroyOnClose, route each session to the host that opened its workspace (set hostId where needed), schedule docker's reap, add durability and destroy to a custom provider and listContainers to a custom DockerEngine, and read the per-session id and behaviour changes for the Cloudflare providers.
  4. d3: workspace scope: remove workspaceLifetime, handle end_pending, and set reusesSessionIds on a custom provider that names the same resource for every open of a session; scope: 'turn' and onWorkspaceDestroy are optional.
  5. d4: Durable Object operations and companion ends: the CF Durable Object gains destroyWorkspace / resetWorkspace and workspaceEndWaitMs; an agent resolver that switches exhaustively on the lookup reason handles 'workspace_hook'.
  6. d5: operations on every executor and agent-server: a custom AgentExecutor adds destroyWorkspace / resetWorkspace; callers handle the returned outcome; agent-server's new routes go through authorize; code that names describeWorkspace's no-registry or switches over HostOperation is updated.

Phase 1 (core 15.0.0) ​

@helix-agents/core 15.0.0 (major), with minors of the workspace providers, @helix-agents/runtime-js, @helix-agents/agent-server and @helix-agents/tracing-langfuse: a run's end keeps the workspace; deleting it is your call.

@helix-agents/core 15.0.0 changes what happens to a session's workspace when a run ends. Before, every run's end deleted the workspace's files on local-bash, local-sandbox and docker, including every suspension (a client tool, an approval, waiting on sub-agents) and every completed turn. The session's next run then silently got an empty workspace. Now a run's end only releases the workspace, and its data stays until you delete it.

The release also bumps the workspace providers, @helix-agents/runtime-js, @helix-agents/agent-server and @helix-agents/tracing-langfuse (minors). Deploy them together, in one release.

What to do ​

  1. Delete workspaces when you delete sessions. Call executor.destroyWorkspace(sessionId) from your own session deletion. Without it, local-bash / local-sandbox / docker files and in-memory workspaces stay until you reap them.
  2. Reap abandoned workspaces on a schedule. For local-bash and local-sandbox, call provider.reap({ olderThan }) from a cron or alarm. Pick olderThan longer than your longest run plus how long a session's workspace should be kept when idle.
  3. Route a session to one replica when a host-bound provider (local-bash, local-sandbox, docker) serves it. Another replica can't see that host's files, and a misrouted request now fails typed instead of silently starting empty.
  4. Handle workspace_unavailable. When a stored workspace can't be reattached, workspace tools fail with it. Call executor.resetWorkspace(sessionId) to start the session over with a fresh workspace (see below).
  5. Update exhaustive switches over WorkspaceEntryStateKind / EntrySnapshot.state to include 'unavailable'.

What changed ​

A run's end releases; destroy is explicit ​

  • local-bash and local-sandbox: close() keeps the tmpdir.
  • docker: close() stops and removes the container but keeps the host tmpdir. resolve() recreates a container over it.
  • New, optional provider methods:
    • WorkspaceProvider.destroy?(ref) deletes one workspace. It validates the ref exactly as resolve() does, and refuses (deleting nothing) a ref outside the provider's own storage.
    • WorkspaceProvider.reap?({ olderThan }) removes the provider's own abandoned workspaces, by last use. It never follows a link.
    • local-bash, local-sandbox, docker and in-memory implement destroy; local-bash and local-sandbox implement reap. The Cloudflare providers have neither yet, and keep their behaviour. (A later release made destroy required and gave the Cloudflare providers one: see d2.)
  • runtime-js keeps one workspace registry per session. A run takes a hold on it and releases the hold at its end. An inheriting child (inheritWorkspace: true) holds its parent's workspace until it ends, so a non-blocking companion still running after its parent's run keeps working on the same files.
  • Children end their own. A sub-agent or a companion consult with its own workspace keeps it across its own suspensions. When it ends (completed, failed or interrupted), the framework clears its stored ref and destroys the workspace, so a companion's next consult starts fresh. This is skipped for a provider without destroy. (A later release made destroy required, so no provider is skipped: see d2.)

destroyWorkspace / resetWorkspace ​

typescript
// From your own session deletion:
await executor.destroyWorkspace(sessionId);

// After a workspace_unavailable loss, or to start over:
await executor.resetWorkspace(sessionId);
  • What they do: both clear the session's stored workspace ref under the idle fence, then call the provider's destroy(ref). The session's next run opens a fresh workspace. In this release resetWorkspace is the same as destroyWorkspace.
  • A session with no stored workspace is a no-op.
  • Refused with AgentAlreadyRunningError, changing nothing:
    • while the session has a live run;
    • while a run or an inheriting child in this process still holds the workspace.
  • A provider without destroy (or one not registered on this executor) is refused with framework_not_supported. (A later release made destroy required; only an unregistered provider is refused now: see d2.)
  • If the provider's own delete fails, the error is rethrown after the ref is cleared. Nothing reattaches the workspace, and the provider's reap removes the leftover.
  • Later releases: d4 adds these operations to the CF Durable Object, and d5 makes them return an outcome and bounds their wait on runtime-js.

A lost workspace is typed: workspace_unavailable ​

  • When: a stored ref whose resolve() reports the workspace gone makes the registry entry 'unavailable'. Every workspace tool then fails with WorkspaceUnavailableError:

    • code: 'workspace_unavailable';
    • reason: 'not_found' | 'process_restarted';
    • non-retryable.

    Nothing is opened in its place. Before, the registry silently opened a fresh, empty workspace.

  • Typical causes:

    • the files were removed (a reap, a host wipe);
    • the request reached another replica (not_found);
    • an in-memory workspace's process restarted (process_restarted).
  • Signals:

    • onWorkspaceUnavailable (agent hook) and WorkspaceHooks.onUnavailable fire;
    • tracing-langfuse records an ERROR span.
  • Recovery: executor.resetWorkspace(sessionId).

  • onEvictionRetry / onWorkspaceEvictionRetry:

    • 'recovered' now always means the same workspace was reattached, never a fresh one;
    • 'exhausted' also fires when the retry finds the workspace gone (a WorkspaceUnavailableError), not only on a second eviction.

WorkspaceEntryStateKind gains 'unavailable' (the major) ​

The registry state union, also EntrySnapshot.state, has a new member. Code that switches over it exhaustively needs the new case:

typescript
// EntrySnapshot.state is WorkspaceEntryStateKind minus 'unknown' (peekState's no-entry sentinel).
switch (snapshot.state) {
  case 'configured':
  case 'opening':
  case 'open':
  case 'closing':
  case 'closed':
  case 'failed':
  case 'evicted':
    // …
    break;
  case 'unavailable':
    // New: the workspace is gone; tools fail with workspace_unavailable until resetWorkspace.
    break;
}

In-memory provider: a provider-level map ​

  • Reattaching: InMemoryWorkspaceProvider now keeps its workspaces in a provider-level map, so a session's workspace reattaches within the provider's process. Its ref is schema version 3 and carries the instance's nonce.
  • Restarts: after a restart, or on a new CF Durable Object instance, the ref is workspace_unavailable (process_restarted).
  • The map grows until destroy(ref), and the provider has no reap. A long-lived process calls destroyWorkspace(sessionId) for the sessions it's done with.
  • Peer dependency: the provider now declares zod as a peer dependency (core already requires it).

One replica per session for host-bound providers ​

local-bash, local-sandbox and docker store a workspace on one host. Serve a session's requests from the replica that holds its workspace (sticky routing by session id). A request that reaches another replica now fails with workspace_unavailable (not_found) instead of silently starting an empty workspace.

agent-server: expired sessions' workspaces are destroyed ​

  • What it does: for an expired session (expiresAt in the past) that is not completed or failed, expiredSessionCleanup now clears its stored ref under the idle fence, then destroys the workspace. The result's new workspacesDestroyed counts them.
  • What it skips:
    • a session with a live run is not touched, and counts in errors;
    • a provider without destroy is skipped (a later release made destroy required: see d2);
    • completed and failed sessions are not handled here: their workspaces need your destroyWorkspace or the provider's reap.

d1: the workspace binding ​

@helix-agents/core 21.0.0 and @helix-agents/runtime-js 40.0.0 (majors), with minors of the state stores: the session's workspace binding, one writer, and a typed loss.

This release makes the workspace binding the one persisted record of a session's workspace, and gives it a store op, updateWorkspaceBinding, that every writer of it goes through. A workspace that cannot be reattached is a typed, configurable loss. It is steps d1a and d1b of the session-scoped workspaces design (spec §2.1, §3.1, §3.3, §6).

It is a major release of @helix-agents/core and @helix-agents/runtime-js:

  • every state store must implement the new method, and runtime-js's construction-time store guard requires it;
  • R38's exports are removed, and the registry's initialRef dependency is now initialBinding.

What to do ​

  • You use the SDK's stores and runtimes: upgrade them together with core. No migration: the binding reuses the existing workspace_ref column.
  • @helix-agents/runtime-js 40.0.0 (major): JSAgentExecutor's construction-time store guard now requires updateWorkspaceBinding (WORKSPACE_BINDING_STORE_METHODS). A store without it is refused when the executor is built, not at a run's first workspace write. The CF Durable Object runs this executor, so the same applies there.
  • You wrote a custom state store: implement updateWorkspaceBinding, keep the column out of every full-state write (below), and run the contract suite.
  • You built a DefaultWorkspaceRegistry yourself: pass initialBinding (the session's SessionState.workspaceBinding) instead of initialRef, and optionally endBinding (below).
  • You used adoptWorkspaceRefWrites / WorkspaceRefWrite: remove them. Persisting a ref no longer moves the session's version, so nothing needs adopting.
  • Choose what a lost workspace does: set WorkspaceConfig.onUnavailable (below). The default is unchanged: it fails typed.

What changed ​

  • SessionState.workspaceBinding (read-only) is the session's workspace record as stored:

    • { state: 'bound', ref, turnId?, openedAt? }: the workspace and its ref (the same as workspaceRef);
    • { state: 'ended', reason, at, providerId }: a tombstone, the workspace ended on purpose (destroyed, reset, expired, child_ended, …);
    • absent: the session never opened a workspace. AgentState.workspaceBinding carries it into a run.
  • Only the op writes the column. Full-state writes (saveState, the step and suspension commits, the terminal commitState) keep the stored binding, whatever workspaceRef the state they write carries. So a tombstone is never resurrected by a full-state write.

  • The framework's writers use the op:

    • a workspace the registry opens is persisted with a compare-and-set over the binding the run last saw, fenced on the run (core persistWorkspaceRef). It retries once over another open; it never writes over an ended tombstone it did not see (it logs and leaves the tombstone);
    • a child's or a companion consult's end writes ended / child_ended before its terminal commit;
    • destroyWorkspace, resetWorkspace and agent-server's expiredSessionCleanup write ended with destroyed, reset or expired. They are refused while a run is live.
  • The column holds only a binding. readStoredWorkspaceBinding is its one reader. A value that is not a binding reads as none, logged at error (state_corrupt_row, ids only). readStoredWorkspaceRef and workspaceRefColumn are removed; use readStoredWorkspaceBinding / workspaceBindingColumn and boundWorkspaceRef.

  • The registry reads the binding. An ended tombstone opens a fresh workspace. A bound one is resolved, then verified: Workspace.verify?() (new, optional) runs after every resolve, and on a run's first get() of a workspace an earlier run left open.

  • A lost workspace (a resolve that throws WorkspaceEvictedError, or a failed verify) follows WorkspaceConfig.onUnavailable:

    • 'fail' (default): the workspace is unavailable; workspace tools fail with WorkspaceUnavailableError until the app calls resetWorkspace(sessionId). Nothing is opened.
    • 'reset': the run destroys the lost workspace (best effort), ends the binding reset, opens a fresh one, and fires onWorkspaceReset.

    WorkspaceUnavailableReason gains wrong_host and content_reset (a verify failure). Update exhaustive switches.

  • Hooks: onWorkspaceReset is new (WorkspaceResetPayload). Langfuse records it as a workspace:reset span.

Custom state stores ​

Implement updateWorkspaceBinding(sessionId, change, opts?) as one atomic step that touches only the workspace_ref column (or your store's equivalent):

  1. A missing session throws state_session_not_found (core sessionNotFoundError).

  2. Check the fences in the same atomic step, the same rules as saveState's:

    • opts.fenceRunId: the run is the session's current, live run;
    • opts.fenceIdle.runId: that run is still the session's current run and has ended (null: the session has no run).

    Either failing throws RunSupersededError with nothing written. Core's assertRunIsCurrentLive / assertRunIsCurrentIdle implement both checks.

  3. Read the stored column with readStoredWorkspaceBinding, and decide with core applyWorkspaceBindingChange(stored, change). It validates change.next (a malformed binding throws a non-retryable validation_error, nothing written) and compares the stored binding with change.expect.

  4. When it answers write: true, write workspaceBindingColumn(next) to the column. Move no version, write no checkpoint, bump nothing else. Return its result: { written: true, binding }, or, on a mismatch, { written: false, actual } with nothing written.

  5. If your store bounds state size (maxStateBytes), measure the column you write and refuse an oversized one with StateSizeExceededError (operation state), nothing written.

  6. If your compare-and-set can lose a race (a read followed by a conditional write), retry it WORKSPACE_BINDING_ATTEMPTS times, then throw core workspaceBindingContendedError(sessionId) (a retryable state_concurrency_conflict).

  7. loadState fills both workspaceBinding and workspaceRef (the bound binding's ref) from the column.

  8. Every full-state write keeps the column: saveState, saveStateAndPromoteStaging, commitState and any other write of a whole SessionState must not write it, whatever workspaceRef / workspaceBinding the state carries.

Run the contract. stateStoreContractTests from @helix-agents/core/testing includes the workspace-binding scenarios (workspaceBindingOperationTests, WSB-1..8). WSB-6 (the size cap) is in the size-limit suite. WSB-5 (a value that is not a binding reads as none) needs the runner hook rawHooks.writeWorkspaceColumnRaw(sessionId, raw) that writes your raw column; without it, WSB-5 is skipped. A store that passes them implements the method as the SDK's stores do.

d2: provider durability and destroy ​

@helix-agents/core 23.0.0, @helix-agents/runtime-cloudflare 29.0.0 and @helix-agents/workspace-docker 2.0.0 (majors), with minors of runtime-js and the other workspace providers: every provider says where its refs resolve and can delete what it opened.

This release makes every workspace provider say where its refs resolve and lets every provider delete what it opened. It is the workspace providers step (d2) of the session-scoped workspaces design (spec §3.2, §3.3, §7).

It is a major release of @helix-agents/core, @helix-agents/runtime-cloudflare and @helix-agents/workspace-docker, with minors of @helix-agents/runtime-js, @helix-agents/workspace-posix-core, @helix-agents/workspace-local-bash, @helix-agents/workspace-local-sandbox and @helix-agents/workspace-memory.

Who is affected:

  • apps that use the Cloudflare sandbox's destroyOnClose;
  • apps that use a per-session Cloudflare sandbox or filestore, or set an explicit sandbox id or filestore namespace (see Per-session ids);
  • apps whose sub-agents or companions declare their own Cloudflare filestore or sandbox workspace (see Behaviour changes);
  • multi-host Node deployments of local-bash, local-sandbox or docker;
  • anyone who wrote a custom WorkspaceProvider or a custom DockerEngine.

What to do ​

  • You use the SDK's providers and runtimes: upgrade them together with core, in one release.

  • You construct a CloudflareSandboxWorkspaceProvider: pass the new required scope option, what owns the session store the provider serves. On the CF Durable Object, use the agent DO's own id; the workspaceProviders factory receives (env, ctx):

    ts
    workspaceProviders: (env, ctx) =>
      new Map([
        [
          'cloudflare-sandbox',
          new CloudflareSandboxWorkspaceProvider({
            namespace: env.Sandbox,
            scope: ctx.id.toString(),
          }),
        ],
      ]);

    On another host, pass a value that uniquely names the store the sessions' state lives in, the same on every call. A missing or empty scope is a typed WorkspaceFailedError at construction.

  • You set destroyOnClose on a Cloudflare sandbox: remove it. It no longer exists. A run's end is a release and never destroys the container. Delete a session's container when it is no longer needed. An executor that hosts the provider does it with destroyWorkspace(sessionId) (the provider's destroy, which calls sandbox.destroy()).

    • On the CF Durable Object, until its own workspace operation ships (it shipped in d4): the DO exposed no destroyWorkspace to the app yet. A child's or consult's container is still destroyed at its end, but a root session's container is the app's to delete, in one line (a per-session container's sandbox id is cloudflareSandboxIdForSession(scope, sessionId), with the provider's scope: the DO's ctx.id.toString()):

      ts
      import { getSandbox } from '@cloudflare/sandbox';
      import { cloudflareSandboxIdForSession } from '@helix-agents/runtime-cloudflare/sandbox';
      
      await getSandbox(env.Sandbox, await cloudflareSandboxIdForSession(scope, sessionId)).destroy();

      The DO step of the design (d4) adds the DO's own workspace operation, which replaces this call (see d4). Until then a lost sandbox workspace is reset by default (the provider's defaultOnUnavailable is 'reset'), so a container whose disk was reset is replaced without an app call; see Behaviour changes.

  • You run local-bash, local-sandbox or docker on more than one host: route every request of a session to the host that opened its workspace (sticky routing). A ref from another host is now refused typed (wrong_host). Set the provider's hostId option when several hosts (containers) share a hostname but not a filesystem. The default hostId is the hostname, which changes when a container or pod is recreated: when tmpdirRoot is on a persistent volume, set hostId to a stable value, or the recreated host refuses its own workspaces wrong_host. A wrong_host loss is never reset, whatever onUnavailable says: the workspace still exists on the host that opened it.

  • You use docker: schedule provider.reap({ olderThan }) on every host, as for local-bash and local-sandbox. Pick olderThan longer than your longest run plus the idle time a session's workspace should be kept.

  • You wrote a custom WorkspaceProvider: add the two required members, durability and destroy(ref), to the contract below. See Building a provider.

  • You wrote a custom DockerEngine: implement listContainers(label): every container (running or not) carrying the label key=value, with all its labels.

  • Your sub-agents or companions keep files in their own Cloudflare workspace: read Behaviour changes. Those files are now deleted at the child's end.

  • You use a Cloudflare sandbox or filestore: read Per-session ids. A per-session workspace has a new id, and an explicit id / namespace now always needs shareAcrossSessions: true.

Per-session ids ​

Session and shared Cloudflare workspaces use separate ids, and per-session workspace ids are scoped to the owning Durable Object (or the configured scope).

  • Per-session sandbox (no id): the container's sandbox id is cloudflareSandboxIdForSession(scope, sessionId), helix-session- plus 24 hex characters of SHA-256 of the scope and the session id (lowercase, 38 characters). It is no longer the session id. cloudflareSandboxIdForSession and SESSION_SANDBOX_ID_PREFIX are exported from @helix-agents/runtime-cloudflare/sandbox.
  • Per-session filestore (no namespace): the namespace is cloudflareFileStoreNamespaceForSession(doId, sessionId), helix_session_ plus 32 hex characters of SHA-256 of the Durable Object's id and the session id. It replaces "the session id when valid, else s_<hex>". Its R2 spill keys are scoped to the Durable Object too (<doId>/<namespace>/<path>). cloudflareFileStoreNamespaceForSession and SESSION_FILESTORE_NAMESPACE_PREFIX are exported from @helix-agents/runtime-cloudflare/filestore.
  • An explicit id / namespace is always a shared workspace. It requires shareAcrossSessions: true, also when it equals the session id, and it may not start with helix-session- / helix_session_ (case-insensitive). Either violation is a typed WorkspaceFailedError at open. If you set id: sessionId (or namespace: sessionId) to get a per-session workspace, omit id / namespace instead.
  • Workspaces created before this release are not reattached. A per-session sandbox or filestore namespace created before this release was named by the session id (or s_<hex> for a filestore session id that is not a valid namespace), so the new release opens a fresh one. There is no migration. Remove the old ones with platform tools:
    • sandbox: await getSandbox(env.Sandbox, oldSessionId).destroy();
    • filestore: drop the old namespace's cf_workspace_<old namespace> tables from the Durable Object's storage, and delete its R2 spill objects (keys under <old namespace>/<old namespace>/).

The provider contract ​

  • durability: WorkspaceDurability (required): one of
    • 'process': the ref resolves only in the process that opened it;
    • 'host': on the host that opened it, while its files exist; a multi-replica Node deployment needs sticky routing;
    • 'global': wherever the provider's bindings reach.
  • destroy(ref) (required; was optional) deletes the workspace's data and resources:
    • it works without a live handle;
    • it is idempotent: a missing workspace is already destroyed;
    • it never re-creates anything, and afterwards resolve(ref) throws WorkspaceEvictedError;
    • it validates the ref as resolve() does, and refuses a ref it cannot validate with WorkspaceFailedError, deleting nothing;
    • a 'host' provider refuses a ref from another host with WorkspaceEvictedError reason: 'wrong_host', deleting nothing;
    • a provider with nothing to delete implements it as a no-op.
  • reap({ olderThan }) stays optional.
  • Workspace.verify() (optional): implement it when resolve can succeed against a reset resource. It throws WorkspaceEvictedError reason: 'content_reset' when the live workspace is no longer the one its ref names.
  • close() still releases and never deletes data.

@helix-agents/workspace-posix-core exports the shared host-binding helpers, resolveHostId(hostId?) and assertRefHost(refHost, hostId, providerId).

What changed ​

  • core:
    • WorkspaceProvider gains the required durability and destroy (above), and an optional defaultOnUnavailable?: 'fail' | 'reset': what a lost workspace does when its WorkspaceConfig.onUnavailable is unset (else 'fail'; an explicit onUnavailable always wins).
    • A wrong_host loss is never reset: the workspace stays unavailable, typed, whatever onUnavailable says.
    • executor.destroyWorkspace(sessionId) and resetWorkspace(sessionId) are refused with framework_not_supported only when the session's provider is not registered on the executor. Core destroySessionWorkspace answers unsupported only in that case.
  • local-bash, local-sandbox, docker (durability: 'host'):
    • each ref records the host that opened it: the provider's new hostId option, else os.hostname();
    • resolve or destroy of a ref from another host throws WorkspaceEvictedError with reason: 'wrong_host' and deletes nothing. The registry reports it as WorkspaceUnavailableError (workspace_unavailable) with reason wrong_host, instead of a missing tmpdir (not_found).
  • docker:
    • new reap({ olderThan }): it removes this provider's containers on this host whose tmpdir is gone or was last used at least olderThan ms ago, then its idle tmpdirs (the same rule as local-bash's reap). It never touches another host's containers, another tmpdirRoot's, one whose tmpdir is not one of the provider's own (helix-dk-…), or unlabelled ones;
    • containers carry the labels helix.workspace.provider=docker, helix.workspace.tmpdir and helix.workspace.host;
    • resolving and releasing a workspace mark its tmpdir used;
    • release (close()) still stops and removes the container and keeps the files;
    • DockerEngine gains listContainers(label).
  • workspace-memory: durability: 'process'.
  • Cloudflare filestore (durability: 'global'):
    • its ref carries the owning Durable Object's id, so resolve or destroy in another DO is refused wrong_host and never opens empty tables;
    • destroy deletes the namespace's files and their R2 spill objects; R2 spill keys are scoped to the Durable Object;
    • a marker table, helix_workspace_filestore, records each namespace's current opening, so a destroyed or replaced opening resolves not_found (a session's namespace is reused by its next workspace). A destroy removes the namespace's rows and its marker in one step (a newer opening of the namespace always starts empty), then deletes the spilled R2 objects, keeping any object a newer opening references again. The table also records whether the namespace is shared: an open whose sharing disagrees with it is refused, typed WorkspaceFailedError, and destroy never deletes a namespace marked shared.
  • Cloudflare sandbox (durability: 'global'):
    • destroyOnClose is removed. close() is a release and never destroys the container;
    • the new required scope option scopes per-session container ids to the owner of the session store (above);
    • open writes a marker file, <workspaceDir>/.helix/workspace-id, holding { "id": <opening id>, "shared": <bool> }. An open whose sharing disagrees with the container's marker is refused, typed WorkspaceFailedError, before any configuration call (sleepAfter, env vars, bucket mounts);
    • verify() reads it back (one file read per run). The registry calls it after every resolve, and on a run's first get of a workspace still open from an earlier run. A container whose disk was reset (a sleep past sleepAfter, a replacement) is reported content_reset, instead of a silently empty workspace. What follows is the workspace's onUnavailable setting: 'reset' (the sandbox's default, see below) destroys the old workspace and opens a fresh one; 'fail' fails workspace tools with workspace_unavailable until the app calls resetWorkspace (on the CF DO from d4);
    • destroy(ref) calls sandbox.destroy() on its own opening's per-session container: when the marker is its own, or missing (a reset disk). A container whose marker names another opening, or is shared, is left alone (logged at warn). A ref whose id does not match its sharing is refused, typed, and nothing is destroyed;
    • a snapshot restore or branch writes its own marker into the restored container; from a shared base the restored container is a per-session one, with an id of its own, so the session's destroy removes it;
    • an app that needs files to survive a sleep uses the Cloudflare Sandbox SDK's keepAlive or the snapshot tools.
  • Cloudflare script runner (durability: 'global'): destroy is a no-op (stateless isolates).

Behaviour changes ​

  • A child's workspace is destroyed at its end on every provider. A child session's (an ephemeral sub-agent's) or a companion consult's own workspace is ended and destroyed at the child's terminal exit on every provider, the Cloudflare filestore and sandbox included, on the CF Durable Object too. The child's workspace contents are gone after its terminal exit. Before, the Cloudflare providers had no destroy, so their child and companion workspaces were kept across consults. A root session's workspace is still kept until the app destroys it. An interrupted child counts as a terminal exit: a CF Durable Object child that is resumed afterwards starts with a fresh workspace. A new run of the session (the next consult, a resume, a retry) opens its workspace after the previous run's destroy has finished, waiting up to workspaceEndWaitMs (default 30 s; a Stop ends the wait): within one runtime-js executor through its session workspaces, and on the CF Durable Object across all its drives (they share the session workspace registries, and a drive's settle waits for the session's pending ends, bounded, before the next entry; hibernation or eviction drops that wait, and a destroy an eviction cut is the provider's reap()). Past workspaceEndWaitMs, a provider whose per-session resource repeats (A2A R0(d) d3, reusesSessionIds: the Cloudflare filestore and sandbox) gets no workspace for that run (its workspace tools are refused typed, end_pending); any other provider opens a fresh one. Across runtime-js processes the order is not guaranteed.
  • A lost Cloudflare sandbox workspace is reset by default. The sandbox provider's defaultOnUnavailable is 'reset': a container whose disk was reset (content_reset) or that is gone is destroyed and replaced by a fresh, empty workspace, firing onWorkspaceReset and logging a warning. Until the DO's own workspace operation (d4) gives the app a reset call, 'fail' would leave a root session's workspace unusable on the DO. Set onUnavailable: 'fail' explicitly to keep the old behaviour (for example to inspect a lost container). d4 revisits this default.
  • A shared workspace is never destroyed. A filestore with an explicit namespace and shareAcrossSessions: true, or a sandbox with an explicit id and shareAcrossSessions: true, is shared by every session that opens it. destroy never removes its data: it logs a warning (ids only) and returns. An app that wants that data gone removes it on purpose itself:
    • filestore: delete the files in that namespace, for example by opening it and removing its entries with ws.fs.rm (which also removes their R2 spill objects), or by dropping its tables from the DO's storage;
    • sandbox: call getSandbox(env.Sandbox, id).destroy() from @cloudflare/sandbox, with the shared id.
  • A ref written before this release fails validation. local-bash, local-sandbox and docker refs now carry the host, and filestore and sandbox refs carry their new ids. A ref written before this release fails payload validation with a typed WorkspaceFailedError. There is no legacy-ref handling.

d3: workspace scope ​

@helix-agents/core 24.0.0 (major) and @helix-agents/runtime-js 40.2.0 (minor): workspace scope, onWorkspaceDestroy, and workspaceLifetime removed.

A2A R0(d) d3, the runtime-js step of the session-scoped workspaces spec. @helix-agents/core is a major release (PersistentAgentConfig.workspaceLifetime is removed); @helix-agents/runtime-js is a minor.

What to do ​

  • Remove workspaceLifetime from every persistentAgents entry: the setting is removed, and a companion keeps a fresh workspace per consult.
  • Optional: scope: 'turn' on a root agent's workspace for a workspace per turn (destroyed when the turn ends). The default, 'session', is today's behaviour.
  • Optional: onWorkspaceDestroy in the agent's hooks, to learn when the framework destroyed a workspace (its reason, the session it belonged to). Under onUnavailable: 'reset' it fires before onWorkspaceReset.
  • Handle end_pending wherever you switch over WorkspaceUnavailableReason exhaustively (a new member is a type error there). An onWorkspaceUnavailable handler that calls resetWorkspace should skip reason: 'end_pending': that refusal is the run's own, and a later run opens fresh once the end has finished.
  • A custom provider whose open names the same resource for every open of a session sets reusesSessionIds: true, so a session's open follows the end of its previous workspace (the Cloudflare filestore and sandbox set it).

What changed ​

  • WorkspaceConfig.scope?: 'session' | 'turn' (core). A root's 'turn' workspace is kept across the turn's suspensions and continuations, and destroyed when the turn ends (a stop ends the turn wherever it lands); a workspace an earlier turn left bound is destroyed at a later run's entry; a crash between a turn's end and its destroy leaves the workspace to the provider's reap(), which the app schedules (user ruling 2026-11-19). A sub-agent's or a companion's own workspace follows the child lifetime whatever it says; a child declaring 'session' is logged once per agent type per executor.

  • AgentHooks.onWorkspaceDestroy (core, WorkspaceDestroyPayload, WorkspaceDestroyReason), and WorkspaceHooks.onDestroy for registry hook integrations. It fires for framework destroys only.

  • A companion's terminate and respawn end its workspace on runtime-js: a companion terminated while its consult is paused has its workspace destroyed once the stop is recorded, and a respawn destroys the old session's workspace before the session is replaced (core CompanionToolDispatchDeps.endChildWorkspace, which runtime-js supplies).

  • A session's open follows its previous end (runtime-js). A destroy the run stops waiting for (past the executor's workspaceEndWaitMs, default 30 s, or at a Stop) is still the session's pending end: the next run waits for it, and its success, when it comes, fires onWorkspaceDestroy once. On a provider whose per-session resource repeats (core WorkspaceProvider.reusesSessionIds, set by the Cloudflare filestore and sandbox), a run whose wait ends first opens no workspace: its workspace tools fail with WorkspaceUnavailableError (reason: 'end_pending') and onWorkspaceUnavailable fires, for that run only; a later run opens fresh once the end has finished. This includes a 'turn' workspace an inheriting companion still holds after its turn: the session's later turns wait for that companion to end. Any other provider opens a fresh workspace past the bound and logs the end, as before. On the CF Durable Object the runs of every drive wait for it: the DO's drives share one set of session workspace registries, and a drive's settle waits for the session's pending ends (at most workspaceEndWaitMs, never more than half of concurrentEntryTimeoutMs) before it admits the next entry. Hibernation or eviction drops that in-memory wait: the next drive rebuilds the registry from the stored binding, and a destroy an eviction cut is left to the provider's reap() (user ruling 2026-11-19).

Scope by runtime ​

  • runtime-js: all of the above.
  • CF Durable Object: scope, the turn end and the earlier-turn check, and onWorkspaceDestroy for them, through the runtime-js run loop it runs, across all its drives (above). Its workspace operations and a companion's end are in d4.
  • CF Workflows, Temporal and DBOS refuse workspace agents, unchanged.

There is no framework idle TTL or sweep, and no text for the model (user rulings 2026-11-13 and 2026-11-19): the app ends a root session's workspace (destroyWorkspace / resetWorkspace), schedules reap, and renders any context it wants the model to see.

d4: Durable Object operations and companion ends ​

@helix-agents/runtime-cloudflare 29.2.0, @helix-agents/runtime-js 40.3.0 and @helix-agents/core 24.1.0 (minors): the CF Durable Object's workspace operations and a companion's workspace end (A2A R0(d) d4).

  • Operations. DOFrontendExecutor.destroyWorkspace(sessionId) / resetWorkspace(sessionId) (POST /workspace/destroy / /workspace/reset through handle) end the session's workspace as runtime-js's executor does: refused state_already_running while a run is live or holds it, framework_not_supported for a provider the DO does not register. A destroy still running past workspaceEndWaitMs resolves the call (logged at warn): the binding has ended, and the session's next run waits for the destroy. The methods return void, as runtime-js's do. (d5 makes both return an outcome: see d5.) While the operation runs it holds the DO's producer claim, so another entry of the session is answered as against a running drive: one without a request key is refused state_already_running (409, nothing written), and a keyed one waits for the operation, up to concurrentEntryTimeoutMs. A session's identity is fixed at creation: the operations refuse a request whose verdict names another identity (validation_error), as entries do.
  • DurableObjectAgentConfig.workspaceEndWaitMs (default 30 000 ms): a run's wait for its session's previous end, and the bound of the operations' and a companion end's destroy. A drive's settle waits for the session's pending ends for at most this, and never more than half of concurrentEntryTimeoutMs.
  • Companions. A terminate or a respawn ends the companion's workspace in its own Durable Object. A destroy that finishes within the companion's workspaceEndWaitMs fires the parent's onWorkspaceDestroy with the companion's sessionId, as on runtime-js. One still running past it fires the companion agent's own onWorkspaceDestroy when it succeeds (on runtime-js the parent's fires then), and a respawn ends a workspace still bound when the companion's session is wiped, firing the companion agent's own hook. A hook fired outside a run reads the session's state; its updateState and emit do nothing and its addContext is refused typed. The companion's own late hook fires while its Durable Object instance stays live (hibernation or eviction drops it, as it drops the pending end), and a Stop of the parent during a companion's workspace end can leave its hook unfired; the destroy itself still completes.
  • An agent resolver that switches exhaustively on the lookup context's reason handles 'workspace_hook'.

d5: operations on every executor and agent-server ​

@helix-agents/core 25.0.0 and @helix-agents/agent-server 11.0.0 (majors), with minors of runtime-js, runtime-cloudflare, runtime-temporal and runtime-dbos: workspace operations on every executor, and on agent-server (A2A R0(d) d5).

  • Custom AgentExecutor implementations add destroyWorkspace(sessionId) and resetWorkspace(sessionId), both Promise<WorkspaceOperationOutcome>. An executor without workspaces rejects them framework_not_supported before doing anything (core workspaceOperationNotSupported({ runtimeName, sessionId, fallbackRuntimes }) builds the error); CF Workflows, Temporal and DBOS do this.
  • runtime-js: JSAgentExecutor.destroyWorkspace / resetWorkspace resolve to destroyed, none or still_running (they returned void), and wait for the provider's destroy for at most the executor's workspaceEndWaitMs (they waited without a bound). Past it the binding has ended and the destroy keeps running as the session's pending end in this process: the session's next run here waits for it, a run in another process does not.
  • CF Durable Object: DOFrontendExecutor.destroyWorkspace / resetWorkspace resolve to the DO's outcome (they returned void). The DO serves GET /workspace through handle: { binding, workspace }, a read with no identity check.
  • agent-server (major):
    • POST /workspace/destroy and POST /workspace/reset ({ sessionId } → { outcome }): authorize gets 'workspace.destroy' / 'workspace.reset'; not admitted, with no identity check (session ownership is the app's check). Gate them in authorize.
    • GET /workspace answers { binding, workspace } from the stored binding: a bound session between runs, or on another replica, is 200 (it was 404 WORKSPACES_NOT_FOUND), an unknown session is 404 NOT_FOUND, and the body's workspace key keeps the live snapshot (null without one). AgentServer.describeWorkspace returns { kind: 'ok', binding, snapshot }, { kind: 'not-found' }, or { kind: 'no-runtime-support' } for an executor without workspaces (the route answers 404 RUNTIME_NO_WORKSPACE_SUPPORT); no-registry is gone, so code that names it stops compiling.
    • A provider's destroy failure is answered after the binding ended: a typed error at its own status, anything else the generic 500 INTERNAL_ERROR.
  • HostOperation gains 'workspace.destroy' and 'workspace.reset': an exhaustive switch over it handles them.
  • Not built: createAgentHost (the A2A host) has no workspace operations yet (A2A R1).

See also ​

Released under the MIT License.