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.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
from ish import MemoryStore
mem = MemoryStore()
mem.store("deployment_review", "Check migrations before rollout", scope="agent")
print(mem.get("deployment_review", scope="agent"))
import { IshClient, MemoryStore } from "ish-harness";
const client = new IshClient();
const mem = new MemoryStore(client);
mem.store("deployment_review", "Check migrations before rollout", "agent");
console.log(mem.get("deployment_review", "agent"));
mem.close();
client.close();
use ish_harness::MemoryStore;
let mem = MemoryStore::new();
mem.store("agent", "deployment_review", "Check migrations before rollout");
if let Some(value) = mem.get("deployment_review", Some("agent")) {
println!("{value}");
}
package main
import (
"fmt"
"github.com/ish-harness/ish-harness/sdks/go"
)
func main() {
client, err := ish.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
mem, err := ish.NewMemoryStore(client, "")
if err != nil {
panic(err)
}
defer mem.Close()
if err := mem.Store("deployment_review", "Check migrations before rollout", "agent"); err != nil {
panic(err)
}
if value, err := mem.Get("deployment_review", "agent"); err == nil && value != nil {
fmt.Println(*value)
}
}
using Ish.Harness;
using var client = new IshClient();
using var mem = new MemoryStore(client);
mem.Store("deployment_review", "Check migrations before rollout", "agent");
Console.WriteLine(mem.Get("deployment_review", "agent"));
import io.github.ishharness.IshClient;
import io.github.ishharness.MemoryStore;
import java.nio.file.Path;
try (var client = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")));
var mem = new MemoryStore(client)) {
mem.store("deployment_review", "Check migrations before rollout", "agent");
System.out.println(mem.get("deployment_review", "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.
| SDK | Durable constructor |
|---|---|
| Python | MemoryStore(persistence=store, namespace="deployment-reviewer", scope="agent") |
| TypeScript | new MemoryStore(client, "agent", { persistence: store, namespace: "deployment-reviewer" }) |
| Go | NewMemoryStoreWithPersistence(client, "agent", store, "deployment-reviewer") |
| C# | new MemoryStore(client, store, "deployment-reviewer", defaultScope: "agent") |
| Java | new MemoryStore(client, store, "deployment-reviewer", "agent") |
| Rust core | Use 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.
MemoryStorekeeps 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.AgentsMdMemoryloads repository guidance from anAGENTS.mdfile.append_pitfallwrites 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:
| Need | Use | What it contains | Current persistence |
|---|---|---|---|
| Continue short-term dialogue | Session history (session_id + persistence store) | User, assistant, and tool messages | SQLite session_messages table or configured StorageConnector when both are supplied |
| Share working context | ContextStore | Blackboard values and indexed documents | In memory by default; optionally SQLite app_records / context_entries or the connector's equivalent collection |
| Recall long-term agent knowledge | MemoryStore | Searchable notes by scope and key | In memory by default; optionally SQLite app_records / memory_entries or the connector's equivalent collection |
| Load project rules and record pitfalls | AgentsMdMemory | Repository instructions and pitfalls | AGENTS.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.mdinstructions 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.