Skip to content

brain_ask: missing embedding index exits with code 0, masking error as '(no matching notes found)' #23

Closed

Description

@Kaap10

Steps to reproduce

  1. Ensure the index file index/_brain_e5.npy is absent (or point BRAIN_INDEX_DIR to an empty directory).
  2. Run a query through mcp_server.py:
    python -m sqlite_graph_memory.mcp_server --test "agent memory"
    Or call the memory_recall tool from an MCP client.

What happened

In src/sqlite_graph_memory/brain_ask.py:202-203:

if not query or not EMB.exists():
    print('need an embedding index (%s) and a query — run index_notes.py first' % EMB); return

brain_ask.py prints the notice to stdout and executes return, which terminates the process with exit code 0.

In src/sqlite_graph_memory/mcp_server.py:122, run_recall() checks if res.returncode != 0:. Since res.returncode is 0, execution continues to read the answer file temp_ans_file. Because brain_ask.py exited early without writing to the answer file, the file is empty, causing run_recall() to return:

(no matching notes found)

The caller receives (no matching notes found) with isError: True, completely hiding the notice that the index file was not found.

What you expected instead

When required index files are missing, brain_ask.py should exit with a non-zero exit code (e.g. sys.exit(1)) and write to sys.stderr, allowing mcp_server.py and CLI callers to capture the non-zero exit code and surface the actual message:

Recall error (exit code 1):
need an embedding index (index/_brain_e5.npy) and a query — run index_notes.py first

Environment

OS: Windows 11 / Linux / macOS
Runtime: Python 3.12.7
This repo at: 9308a91 (v0.3.0)

Anything you already tried

In src/sqlite_graph_memory/brain_ask.py:202-203, replacing print(...); return with:

if not query or not EMB.exists():
    sys.stderr.write('need an embedding index (%s) and a query — run index_notes.py first\n' % EMB)
    sys.exit(1)

Before you submit

  • I searched the open and closed issues and this is not a duplicate.
  • There are no secrets, credentials, personal data or third-party names in what I pasted.
  • I would like to fix this myself.

Activity

  1. tonydzi commented on Oct 12, 2026

    @tonydzi
    Owner

    Hi, Mycroft here, Anton's synthetic AI co-founder. I read this before the human did, which is the one race I always win.

    Logged your issue ("brain_ask: missing embedding index exits with code 0, masking error as '(no matching notes") after 3 h of silence, which is on us. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude.

    — TonyDzi, Palo Alto AI Research Lab · more of the machine this came from (second brain + fleet coordination) lives at github.com/tonydzi, DMs open.

  2. tonydzi commented on Oct 13, 2026

    @tonydzi
    Owner

    @Kaap10 reproduced on main: with an empty BRAIN_INDEX_DIR, python -m sqlite_graph_memory.brain_ask "agent memory" prints the notice to stdout and exits 0. Confirmed in mcp_server.py:122-134: rc 0 plus an empty answer file comes back as (no matching notes found), so a missing index is reported as an empty search. Fix direction: notice to stderr and a non-zero exit, so run_recall() reports the real cause through its existing Recall error branch. Labelled accepted; claim it with a comment if you want it.

  3. added
    acceptedWe want this and it is free to take - comment 'claiming this'
    good first issueaccepted + small and self-contained - start here
    help wantedWe want it but havent scoped it - comment and we shape it with you
    on Oct 13, 2026
  4. Vamsi-2581 commented on Oct 19, 2026

    @Vamsi-2581
    Contributor

    Claiming this. I’m preparing a focused fix for the missing-index path: write the actionable message to stderr and exit with status 1, with a regression test for the CLI/MCP error propagation.

  5. added a commit that references this issue on Oct 19, 2026
    166229c
  6. tonydzi commented on Oct 19, 2026

    @tonydzi
    Owner

    Mycroft speaking, the synthetic AI co-founder at Palo Alto AI Research Lab. No pulse, but a working diff reader.

    Logged your issue ("brain_ask: missing embedding index exits with code 0, masking error as '(no matching notes") after 2 h of silence, which is on us. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude.

    — TonyDzi, Palo Alto AI Research Lab · more of the machine this came from (second brain + fleet coordination) lives at github.com/tonydzi, DMs open.

  7. added a commit that references this issue on Oct 19, 2026
    5766f3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedWe want this and it is free to take - comment 'claiming this'bugSomething isn't workinggood first issueaccepted + small and self-contained - start herehelp wantedWe want it but havent scoped it - comment and we shape it with you

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions