Skip to main content

Scratchpad Storage

Use different storage tools for different kinds of task data: shared facts, collaborative notes, large binary values, and workspace files. Each has a different lifetime and access pattern.

from ish import ContextStore

context = ContextStore(
initial_data={"project": "Revenue Forecast"},
storage_dir="./artifacts",
)

context.set("q3_revenue", 4_200_000, author="analyst")
print(context.get("q3_revenue"))

context.write_file("summary.txt", "Q3 revenue: 4.2 million\n")
print(context.read_file("summary.txt"))
  • Shared values and rooted files (ContextStore): Share values up to 10 MiB per key. An optional version check rejects an update if the value changed since it was read. File access can be confined to a chosen directory.
  • Worker update store (LwwScratchpad / SharedScratchpad): A small in-memory store for exchanging updates. If two workers change the same key, the most recent update wins; ties use a stable source name. Your application is responsible for sending updates between instances.
  • Large content storage (BlobTable / ObjectTable): Keep large or binary results outside the conversation and pass a short reference to the stored value. Storage can use disk with a bounded memory cache.
  • Objects kept in the current application process (HostObjectTable / set_host_value): Keep values such as database connections that cannot be represented as JSON. They are available only to that running application and are lost when it exits.

Choose where to put a value​

UseGood fit forShared withSurvives restart?
ContextStoreNamed JSON values and searchable documentsApplication, agent, and subagentsIn memory by default; durable with a persistence store and namespace. storage_dir still stores files, not these values
SharedScratchpadSmall values updated by concurrent workersWorkers using the same scratchpadIn memory; export or synchronize state explicitly
Blob referencesLarge text or binary tool resultsTools that receive the referenceCan use disk-backed blob storage
Host object storageNon-JSON objects such as connection poolsCode in the same host processNo; the object is process-local

Context values, rooted files​

When constructed with storage_dir, ContextStore canonicalizes the root via context_create_storage_dir and enforces Rust-owned lexical and symlink path confinement (context_check_storage_path) on every write_file / writeFile / WriteFile and read_file / readFile / ReadFile call. Absolute paths, .. traversal segments, and symlinks resolving outside storage_dir fail with "Access outside storage_dir is denied.".

All six SDKs expose ContextStore through the shared Rust context operations; method signatures and return shapes vary by language (Context remains a backward-compatible alias in Python). The five host SDKs also provide language-specific, process-local fallbacks for non-JSON host objects. In Rust, ContextStore manages JSON entries while ish_harness::context_create_storage_dir and ish_harness::protocols::{context_write_file, context_read_file} expose the same rooted file routines.

Exchange worker updates​

Use SharedScratchpad (Python) or LwwScratchpad (TypeScript, Rust, Go, C#, Java) when your application exchanges small updates among agents or workers. Each instance keeps its own local copy; your application sends updates between instances and asks each copy to merge them. The update with the later timestamp wins. If timestamps match, a stable source name breaks the tie. Invalid JSON values are rejected before they can change the saved state.

from ish import SharedScratchpad

node_a = SharedScratchpad(node_id="node-a")
node_b = SharedScratchpad(node_id="node-b")

node_a.set("phase", "build", timestamp=100.0)
node_b.set("phase", "test", timestamp=105.0)

node_a.merge(node_b.export())
print(node_a.get("phase")) # "test"

Store large values as blobs​

Large binary values can be kept outside the prompt and passed as short references. ISH checks that a retrieved value matches the saved value. Configure storage_dir when files must survive process restarts; see the Context API reference for limits and methods.

Cross-SDK behavior​

NeedShared capabilitySDK notes
Shared values and document searchAvailable in all six SDKsPython also accepts the older name Context
Workspace filesContextStore can read and write files under its configured rootPath checks prevent escaping that root
Host objectsKept in process-local host memoryNot shared across processes
Collaborative notesSharedScratchpad merges updates by timestampAvailable across all six SDKs
Large valuesStored separately and passed between tools as short referencesAvailable across all six SDKs

Keep values shared between processes in JSON format; language objects such as connections stay local to the process. Attaching a ContextStore with storage_dir to an agent mounts artifact tools (write_artifact, read_artifact, list_artifacts), but does not inject file bodies into model prompts automatically. See the Context API reference for full signatures.