When examining Tools and Endpoints in plugins individually, it’s not difficult to see that in most cases, they can only complete single-round interactions: request, return data, and the task ends.

If there is data that needs to be stored long-term, such as implementing persistent memory, the plugin needs to have persistent storage capabilities. The persistent storage mechanism allows plugins to have the ability to persistently store data within the same Workspace. Currently, a KV database is provided to meet storage needs, and more flexible and powerful storage interfaces may be introduced in the future based on actual usage.

Storing Keys

Entry Point

    self.session.storage

Interface

    def set(self, key: str, val: bytes) -> None:
        pass

Note that what is passed in is bytes, so you can actually store files in it.

Getting Keys

Entry Point

    self.session.storage

Interface

    def get(self, key: str) -> bytes:
        pass

Deleting Keys

Entry Point

    self.session.storage

Interface

    def delete(self, key: str) -> None:
        pass