Skip to content

About

Permanent memory for Vis agents, based on OptMem by Victor Taelin.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

vis-optmem

Give Vis agents permanent personal or team memory. The extension is based on OptMem by Victor Taelin.

Install

Use a Vis build that supports extension contracts. For the Python runtime, install Python 3.12 or newer.

vis-agent extension install 'blockether/vis-optmem' --global --trust

The first tool call creates the memory folder. You do not need to call memo.init() for personal memory.

Runtimes

Use vis-agent set runtime python or vis-agent set runtime babashka to set the runtime for new sessions. Use --runtime python or --runtime babashka when you start a session to change its runtime. Vis installs and loads only the implementation for that runtime. In Babashka, call the tools as functions, for example (memo/wake {}).

Both runtimes can use the same local folder or HTTP store. The Babashka implementation does not use Python. On macOS and Linux, put perl on PATH to let Babashka lock a local store with the same lock as Python. On Windows, both use a byte-range lock. For other custom stores, use the Python runtime. If the HTTP store reads a token from an environment variable, use MEMORY_STORE_TOKEN with Babashka.

For local regular expression searches, Babashka uses Java regular expressions. Most common Python expressions work in both runtimes.

Use

Ask the agent in chat to remember a decision or find a fact from an earlier session. Its tools return typed records with a text field.

Tool Result
memo.init Create a memory folder or store.
memo.wake Read new memories in full and older memories as summaries.
memo.note Save one fact in one line, up to 340 bytes by default.
memo.nap Save a summary that a result requests.
memo.recall Find original memories by regular expression or related words.
memo.zoom Open a summary into its two halves.
memo.forget Drop an incorrect summary so the agent can write it again.
memo.config Show or change size limits.
memo.import_memories Add lines in YYYY-MM-DD text format.

Tools use scope="personal" by default. Use scope="team" for shared facts. memo.recall also accepts scope="all" to search both memories. See the memory guide for summary rules or the search reference for examples.

From your code

py3 calls the tools as await memo.wake(). The SDK calls are synchronous and work inside a Vis extension callback:

from blockether import vis


class ProjectNotes:
    """Keep the notes of one project in the personal memory."""

    def remember(self, line: str) -> str:
        """Save one fact about the project. Returns what the memory saved."""
        return vis.tools.memo.note(line).text

    def recall(self, about: str) -> str:
        """Read what the memory knows about `about`."""
        return vis.tools.memo.recall(about=about).text


ext = vis.Extension("project-notes", description="Project notes in the Vis memory.")
ext.expose(ProjectNotes(), name="project_notes")

vis.tools.memo raises vis.errors.NoCall in code that Vis does not call, and vis.errors.NotBound outside Vis.

Configuration

Setting Purpose
MEMORY_DIR Personal memory folder. The default is ~/.optmem/memory.
MEMORY_TEAM_DIR Shared team memory folder. There is no default team store.
MEMORY_LANGUAGE, MEMORY_TEAM_LANGUAGE Language allowed in personal or team memory.
MEMORY_STORE, MEMORY_STORE_CONFIG Personal store and its options.
MEMORY_TEAM_STORE, MEMORY_TEAM_STORE_CONFIG Team store and its options.
MEMORY_STORE_TOKEN Token for a remote store.

Use memo.config to set WAKE_LINES, ENTRY_CHARS, PART_CHARS, or PART_LINES. See Custom stores to use a database or an HTTP service instead of a folder.

Development

uv run --group dev pytest tests -q
(cd babashka && bb test)

Set VIS_CONTRACT_SCHEMAS to the packages/vis-contract/resources/vis-contract/schema folder in a Vis checkout to check the contract against the Vis schema. Install bb to run the Python tests that compare the two runtimes.

About

Permanent memory for Vis agents, based on OptMem by Victor Taelin.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages