Every archive path—including summary, raw fallback, idle compaction, and /new archival—must propagate the originating session_key into history entries. Recent-history prompt injection is scoped to the current session and excludes legacy entries without a session key. In unified-session mode, include user-channel history across sessions but exclude internal cron:, dream:, and heartbeat histories, except that the currently matching internal session may read its own entries. Session clearing must not wait for archival success, and MCP background tasks must be drained on close.
Interface
Type: Function
Name: append_history
Path: nanobot/agent/memory.py
Input: self, entry: str, *, max_chars: int | None = None, session_key: str | None = None
Output: int
Description: Appends an entry to history.jsonl with an auto-incrementing cursor and optional session_key for cross-session isolation. Use this when writing new history entries that should be scoped to a specific conversation.
Type: Function
Name: archive
Path: nanobot/agent/memory.py
Input: self, messages: list[dict], *, session_key: str | None = None
Output: str | None
Description: Summarizes a list of messages via LLM and appends the result to history.jsonl with the given session_key. Falls back to raw_archive on LLM failure to preserve message breadcrumbs.
Type: Function
Name: raw_archive
Path: nanobot/agent/memory.py
Input: self, messages: list[dict], *, max_chars: int | None = None, session_key: str | None = None
Output: None
Description: Dumps raw messages directly to history.jsonl without LLM summarization, tagged with an optional session_key. Used as a fallback when the LLM call in archive() fails.
Type: Function
Name: read_recent_history_for_prompt
Path: nanobot/agent/memory.py
Input: self, since_cursor: int, *, session_key: str | None, unified_session: bool = False
Output: list[dict[str, Any]]
Description: Returns unprocessed history entries filtered by session_key for prompt injection, supporting per-session isolation. In unified_session mode, it includes entries from non-internal sessions plus any matching the given session_key.