v0.2.26

moorcheh-ai/memantov0.2.26Oct 2, 2026by het0814

Upgrading?

AI Summary

Introduces a public in-process Python client and a permanent way to delete agent memories across all SDKs and CLI.

Key Highlights

  • New Memanto class for in-process usage without a server.
  • Explicit delete_memories option for agent deletion.
  • Session reuse and recovery logic improvements.
  • Bug fix preventing silent memory retention during agent deletion.

New Features

  • Public Python client (from memanto import Memanto).
  • delete_memories parameter for delete_agent across Python, TypeScript, and CLI.
  • Namespace logging improvements (moved to logger).
  • Concurrent agent creation tolerance.

Full Release Notes

# Release Notes for v0.2.26

This release adds a public in-process Python client (`from memanto import Memanto`) that needs no server, and an explicit, retry-safe way to permanently delete an agent's memories in Moorcheh across the REST API, CLI, Python SDK clients and TypeScript SDK.

## New Features
- **Public Python client** (`memanto/client.py`, `memanto/__init__.py`)
  - New `Memanto` class bound to a single agent, importable as `from memanto import Memanto`. It runs in-process over `SdkClient`, so there is no server to start.
  - Wraps `remember`, `batch_remember`, `update_memory`, `delete_memory`, `delete_agent`, `recall`, `recall_as_of`, `recall_changed_since`, `recall_recent` and `answer`. Each returns the same dict shape as the matching REST endpoint. Anything not wrapped is available through `Memanto.client`.
  - Credentials are resolved from the `api_key=` argument, then `MOORCHEH_API_KEY`, then the key saved by `memanto` setup. The on-prem backend needs no key.
  - With `auto_create=True` (the default), the agent is created on first use with a configurable `pattern` (`tool`, `support`, `project`). A concurrent create by another client is tolerated.
  - The client reuses the agent's live session when its token verifies and only activates a new one when there is none, so creating a client does not sign out the CLI or other processes. If a session expires or is replaced, the client re-establishes it and retries the call once. Other errors are not retried.
  - The `type` and `tags` filters accept a single value or a list. `title` defaults to the start of `content`.
  - An explicit `api_key` fills the global key only when none is configured, so it never replaces the key other clients in the same process resolve.
  - `import memanto` stays fast: `Memanto` is loaded lazily, so CLI startup is unaffected.
  - Ships `memanto/py.typed` so type checkers pick up the client's annotations.
- **Option to permanently delete agent memories** (`memanto/app/services/agent_service.py`, `memanto/cli/commands/agent.py`)
  - New `AgentService.delete_agent_memories()` deletes the agent's Moorcheh namespace. A namespace that is already gone counts as deleted, on both cloud and on-prem.
  - CLI: `memanto agent delete` gains `--delete-memories/--keep-memories`, which skips the keep/purge prompt (e.g. `memanto agent delete my-agent --force --delete-memories`).
  - Python: `SdkClient.delete_agent()`, `DirectClient.delete_agent()` and `Memanto.delete_agent()` take `delete_memories=` (default `False`). The response now includes `memories_deleted`.
  - TypeScript SDK: `deleteAgent({ deleteMemories: true })` sends `?delete-backup-too=true` (`sdks/typescript/src/index.ts`).

## Improvements
- **Namespace logging** (`memanto/app/services/agent_service.py`)
  - The "namespace created" and "namespace already exists" messages now go through `logger.info` instead of `print`, so they no longer appear on stdout in library and SDK use.

## Bug Fixes
- **Agent delete silently left memories behind** (`memanto/app/routes/sessions.py`, `memanto/cli/commands/agent.py`)
  - `DELETE /api/v2/agents/{agent_id}?delete-backup-too=true` used to swallow any namespace-deletion error and still delete the agent's local metadata. The agent then looked fully deleted while its memories stayed in Moorcheh.
  - The CLI deleted the agent first and purged the namespace afterwards, so a purge failure left an orphaned namespace with no agent to retry from.
  - Memories are now deleted first. If that fails, nothing is deleted: the API returns the `NamespaceError`, and the CLI says the agent was not deleted and the command can be run again.
  - Deleting a missing agent now raises `AgentNotFoundError` before any session or namespace is touched.

## Tests
- `tests/test_python_client.py`: new suite covering the top-level import, agent auto-create and concurrent create, session reuse versus activation, lost-session recovery with a single retry, API key resolution and isolation, filter wrapping, and the `delete_agent` memory choice.
- `tests/test_delete_agent_memories.py`: namespace deletion, treating an already-gone namespace as success, failure raising, unsafe-id rejection, and client delete ordering (memories first, agent kept on failure, missing agent touches nothing).
- `tests/test_api.py`: a failed backup delete keeps the agent.
- `tests/test_cli.py`: `--delete-memories` skips the prompt, and a memory-deletion failure reports that the agent was kept.
- `sdks/typescript/test/memanto.test.ts`: `deleteAgent` deletes cloud memories only when asked.

## Full Changelog
Full Changelog: https://github.com/moorcheh-ai/memanto/compare/v0.2.25...v0.2.26

Related Repositories