Skip to main content

Memory

ISH has two memory horizons plus working context. Short-term memory is the conversation dialogue: user messages, assistant replies, and tool calls/results for one session_id. With a persistence store, that dialogue is saved in the database's session_messages table. Long-term memory is scoped knowledge an agent can recall across conversations through MemoryStore. ContextStore is different: it holds mutable working values and documents shared during a task. Context and long-term memory are in-memory by default; to keep them after process exit, pass a persistence store and namespace. AgentsMdMemory reads repository instructions from AGENTS.md and can write recorded pitfalls to that file.

from ish import MemoryStore

mem = MemoryStore()
mem.store("deployment_review", "Check migrations before rollout", scope="agent")
print(mem.get("deployment_review", scope="agent"))

Opt into durable memory​

To store memory in a SQLite database, create a persistence store with a database file path and pass that store to MemoryStore. For example, this writes memory to ./data/agent-state.sqlite3; the file and its parent directory are created by the SQLite persistence layer as needed:

import asyncio
from ish import MemoryStore, SQLiteLogger

async def main() -> None:
store = SQLiteLogger(db_path="./data/agent-state.sqlite3")
await store.initialize()
memory = MemoryStore(
persistence=store, namespace="deployment-reviewer", scope="agent"
)
try:
memory.store("deployment_review", "Check migrations before rollout")
finally:
memory.close()
await store.close()

asyncio.run(main())

On a later process start, open the same database file and recreate the memory store with the same namespace to load the saved entries. The SQLite table is app_records; memory records use collection memory_entries and are keyed by namespace, scope, and entry key. A StorageConnector writes the same logical collection and keys to the database table or key space implemented by your connector. Use a namespace to isolate an agent, project, or tenant; use scope to classify entries within that agent's memory. User IDs may be part of a namespace when the application needs per-user isolation, but user-scoped memory is not required by the store.

SDKDurable constructor
PythonMemoryStore(persistence=store, namespace="deployment-reviewer", scope="agent")
TypeScriptnew MemoryStore(client, "agent", { persistence: store, namespace: "deployment-reviewer" })
GoNewMemoryStoreWithPersistence(client, "agent", store, "deployment-reviewer")
C#new MemoryStore(client, store, "deployment-reviewer", defaultScope: "agent")
Javanew MemoryStore(client, store, "deployment-reviewer", "agent")
Rust coreUse SqliteWalLogger app-record methods and the shared memory.create operation with persistence_handle and namespace.

In-memory construction is still the default. Merely setting a namespace does not write to a database; a persistence store is required. Choose a namespace that matches the knowledge owner, such as one agent or project. Add a tenant or user boundary when your application requires that isolation.

Agent-managed memory​

When MemoryStore is attached to an agent, the runtime gives the agent a compact list of available memory keys plus tools to recall or save entries. Long-term memory is agent-managed during ordinary runs: the agent can recall relevant entries and proactively save useful, reusable knowledge through persist_memory, without the user calling MemoryStore.store() for every interaction. The application chooses the memory owner, namespace, persistence backend, and any applicable instructions or approval rules. This is an explicit memory-tool write, not silent transcript archiving: dialogue remains in short-term session history, while long-term entries are saved when the agent or application chooses to persist them. Whether the model saves a particular fact depends on its instructions and response; tool availability does not guarantee that every useful fact will be stored. See Agent Memory Tools.

  • MemoryStore keeps entries by scope and key. By default it is process-local; with a persistence store and namespace it reloads and saves entries through the shared Rust persistence engine. Scope separates kinds of knowledge within an agent's memory; the namespace separates agents, projects, or tenants.
  • AgentsMdMemory loads repository guidance from an AGENTS.md file. append_pitfall writes deduplicated lessons to that file; ordinary appended notes remain in memory for the lifetime of the store.

Choosing the Right Store​

Unlike ContextStore, which manages shared task state, rooted artifact files, and relevance-ranked document search, MemoryStore and AgentsMdMemory focus on cross-turn recall and repository conventions:

NeedUseWhat it containsCurrent persistence
Continue short-term dialogueSession history (session_id + persistence store)User, assistant, and tool messagesSQLite session_messages table or configured StorageConnector when both are supplied
Share working contextContextStoreBlackboard values and indexed documentsIn memory by default; optionally SQLite app_records / context_entries or the connector's equivalent collection
Recall long-term agent knowledgeMemoryStoreSearchable notes by scope and keyIn memory by default; optionally SQLite app_records / memory_entries or the connector's equivalent collection
Load project rules and record pitfallsAgentsMdMemoryRepository instructions and pitfallsAGENTS.md on disk; ordinary appended notes are process-local

Do not store raw credentials or secrets in MemoryStore or AGENTS.md, and treat recalled memories as hints that should be verified against current task inputs before mutating external systems.

Learn more​

  • Scoped memory explains scopes, search, and agent recall tools.
  • Repository memory explains how AGENTS.md instructions and recorded pitfalls are handled.

What is written to the database: With SQLite persistence configured, ISH saves run details and conversation messages. It also saves ContextStore and MemoryStore entries when you pass them the persistence store and a namespace. Those stores are in memory by default. Python Context can hold regular Python objects, which remain available only in the current process. With StorageConnector, ISH sends the same kinds of records to the database or record service you configure; ISH does not create or select that database for you.

For copyable database-backed setup examples, see Short-Term Dialogue, SQLite WAL, and Custom Storage Connectors.