Skip to content

CLI tool commands hang after displaying output #461

@divideby0

Description

@divideby0

Bug Description

CLI commands like basic-memory tool --help and basic-memory status hang indefinitely after displaying output, requiring Ctrl+C to exit.

Reproduction Steps

  1. Run uvx basic-memory tool --help
  2. Observe: help text displays but process never exits
  3. Must Ctrl+C to terminate

Also affects:

  • basic-memory tool write-note --help
  • basic-memory tool read-note --help
  • basic-memory tool search-notes --help
  • basic-memory status

Expected Behavior

Command should exit with code 0 after displaying output.

Root Cause

ensure_initialization() and CLI commands create database connections via asyncio.run() that are never cleaned up. The global database engine holds async connections that prevent the process from exiting.

Environment

  • basic-memory version: 0.16.x
  • Python: 3.12+
  • Platform: macOS/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions