ViteHub is still experimental. Expect bugs and breaking changes.

Memory

Add scoped durable memory records to an Agent.

memory() adds scoped durable records that an Agent can search, read, remember, or delete through configured Memory Stores. Memory is explicit Agent behavior and is not the same as Chat History.

The Capability exposes memory_search and memory_read, plus remember and delete tools when a store opts into tool writes. Each store owns its adapter, scope, allowed kinds, read behavior, and write policy.

Configure memory

Configure at least one store with an explicit scope. The workspace JSONL helper stores records inside the Agent Workspace.

server/agents/support.ts
import { defineAgent } from 'vite-hub/agent'
import { memory, workspaceJsonlMemoryStore } from 'vite-hub/agent/capabilities'

export default defineAgent({
  driver: { model },
  workspace,
  capabilities: [
    memory({
      stores: {
        agent: {
          adapter: workspaceJsonlMemoryStore(),
          scope: { agent: 'support' },
        },
      },
    }),
  ],
})

How memory works

During resolve, memory() creates read tools for stores that allow reading and write tools for stores that opt into tool writes.

Write tools add provenance from the current Agent Invocation and allow writes by default after a store opts into write.mode: 'tool'. Set the store policy to require-approval or deny when writes need an additional gate.

Requirements

memory() requires a store map. Each store requires an adapter and an explicit non-empty scope.

workspaceJsonlMemoryStore() requires a Workspace. It requires writable Workspace access when the Agent creates, supersedes, or deletes memory records.

Driver support

Agent DriverSupport
Model-backedReceives the configured memory tools.
Provider-backedReceives the configured memory tools through the provider MCP bridge.
Custom-run-backedReceives prepared context and can call store adapters from custom code when the application exposes them.

Verify memory

Inspect Agent inspection metadata for the configured memory stores. Inspect the tool list and confirm write tools appear only for stores with write.mode: 'tool'.

For the workspace JSONL store, inspect the configured Workspace file and verify records include scope and provenance.

Options

OptionTypeDefaultDescription
storesRecord<string, MemoryStoreOptions>requiredNamed Memory Stores available to the Agent.
stores.*.adapterMemoryStoreAdapter | MemoryStoreFactoryrequiredStore implementation.
stores.*.scopeMemoryScope | functionrequiredScope attached to all operations for that store.
stores.*.allowKindsMemoryKind[]all kindsAllowed memory kinds for the store.
stores.*.read.tools.searchbooleantrueExpose memory search.
stores.*.read.tools.readbooleantrueExpose exact memory read.
stores.*.write.mode"off" | "tool""off"Expose remember/delete tools when set to "tool".
stores.*.write.policyAgentToolPolicyDecision"allow"Policy for write tools.

Workspace JSONL store

workspaceJsonlMemoryStore() persists records as append-only JSONL inside the Agent Workspace.

OptionTypeDefaultDescription
pathstring"memory/memory.jsonl"Workspace-relative JSONL file path.

Cover Memory usage guidance in Agent Driver Instructions with explicit Capability coverage blocks. Keep memory tool descriptions with the tool definitions because they are structured tool contracts.