Skip to content

In-Memory Workspace

The InMemoryWorkspace is the simplest workspace provider — files live in a JavaScript Map inside the executor process. No persistence, no I/O, no external dependencies.

When to use

  • Tests. Smoke tests for agents that touch the filesystem, where you don't want to manage tmpdirs or container state.
  • Dev loops. Quick iteration before deciding which real provider you'll deploy with.
  • Ephemeral agents. Agents that don't need files to outlive the session (e.g., a one-shot summarizer that writes a draft, finishes, and discards).

If you need anything to persist past the executor's lifetime, use one of the other providers.

Capabilities supported

CapabilitySupported
fs
shell
code
snapshot

The provider advertises only fs: true on its WorkspaceRef.capabilities. Declaring other capabilities in your agent config has no effect for this provider.

Provider config

typescript
interface InMemoryWorkspaceConfig {
  kind: 'in-memory';
}

No options. Discriminator only.

Wiring

typescript
import { defineAgent } from '@helix-agents/core';
import { JSAgentExecutor } from '@helix-agents/runtime-js';
import { InMemoryStateStore, InMemoryStreamManager } from '@helix-agents/store-memory';
import { InMemoryWorkspaceProvider } from '@helix-agents/workspace-memory';

const agent = defineAgent({
  name: 'my-agent',
  llmConfig: { model: yourModel },
  workspaces: {
    notes: {
      provider: { kind: 'in-memory' },
      capabilities: { fs: true },
    },
  },
});

const executor = new JSAgentExecutor(
  new InMemoryStateStore(),
  new InMemoryStreamManager(),
  yourLLMAdapter,
  {
    workspaceProviders: new Map([
      ['in-memory', new InMemoryWorkspaceProvider()],
    ]),
  }
);

The map key ('in-memory') must match the provider's providerId AND the discriminator kind you declared in the agent config.

Lifecycle

  • open() — creates a fresh InMemoryWorkspace with a new id (inmem-{counter}-{timestamp}). Cheap; no I/O.
  • resolve()throws. In-memory workspaces are ephemeral; their state is lost on process restart. Don't use this provider with runtimes that need to survive restarts (Cloudflare DOs, Temporal workflows). Use CloudflareFileStoreWorkspace or LocalBashWorkspace instead.
  • close() — releases the in-memory Map. The garbage collector reclaims it.

Auto-injected tools

Every fs tool is offered to the LLM. See the FileSystem module page for full schemas.

  • workspace__<name>__read_file(path)
  • workspace__<name>__write_file(path, content)
  • workspace__<name>__edit_file(path, oldText, newText)
  • workspace__<name>__ls(path)
  • workspace__<name>__glob(pattern)
  • workspace__<name>__grep(pattern, opts?)
  • workspace__<name>__stat(path)
  • workspace__<name>__mkdir(path, opts?)
  • workspace__<name>__rm(path, opts?)

Limitations + when to switch

You need...Switch to
File state to survive process restartLocal Bash (POSIX dev) or Cloudflare Filestore (CF prod)
Shell command executionLocal Bash (POSIX dev) or Cloudflare Sandbox (CF prod)
Code interpreterCloudflare Sandbox
Snapshot / branchCloudflare Sandbox
Files visible across multiple agent instancesNone of the v1 providers — workspaces are session-scoped

Source

Released under the MIT License.