Skip to content

bug(pi): mem_search fails with 'could not reach' for queries with underscores/hyphens returning 0 results #672

Description

@killo3967

Bug Description

mem_search from Pi (gentle-engram v0.1.10 + engram v1.20.0) reports "gentle-engram could not reach the Engram HTTP server" for specific queries — but Engram is actually running and healthy. The failure is deterministic by query pattern, not intermittent.

Environment

  • gentle-engram: 0.1.10
  • engram: 1.20.0
  • OS: Windows 11
  • Agent: Pi (el Gentleman)
  • Shell: Git Bash

Steps to Reproduce

// These work:
mem_search(query: "a", project: "epub-repair")        // ✅
mem_search(query: "nailgun", project: "epub-repair")   // ✅

// These FAIL with "could not reach":
mem_search(query: "lowercase_tags", project: "epub-repair")          // ❌
mem_search(query: "empty_lang extender", project: "epub-repair")     // ❌
mem_search(query: "rsc032_fallback BMP", project: "epub-repair")     // ❌
mem_search(query: "PKG-008 fixer ADR-0005", project: "epub-repair")  // ❌

Expected Behavior

Return "No memories found" (empty result) like the CLI does.

Actual Behavior

gentle-engram could not reach the Engram HTTP server at http://127.0.0.1:7437.
The Pi-native mem_* tools are registered, but the native memory provider is not
currently responding. Run mem_doctor or restart Engram.

Diagnostic Evidence

Engram CLI — works perfectly

$ engram search "lowercase_tags" --project epub-repair
→ No memories found for: "lowercase_tags"    (instant)

$ engram search "PKG-008 fixer ADR-0005" --project epub-repair
→ No memories found for: "PKG-008 fixer ADR-0005"    (instant)

HTTP API — works perfectly

$ curl "http://127.0.0.1:7437/search?q=lowercase_tags&project=epub-repair&limit=5"
→ HTTP 200 | 26ms | body: "null"

Health check — always OK

$ curl http://127.0.0.1:7437/health → 200
$ mem_doctor → 4/4 checks OK
$ mem_context → works always
$ mem_save → works always

Root Cause Hypothesis

The bug is in the gentle-engram Pi plugin layer (bridge between Pi mem_search tool and Engram HTTP API), not in Engram core. The plugin appears to mishandle HTTP responses for queries that:

  1. Return zero results (empty/null response)
  2. AND contain special characters (_, -)

The plugin interprets a valid empty response as a connection failure and reports "could not reach" instead of returning empty results.

Pattern Analysis

Query Has special chars? Returns results? mem_search
"a" No Yes
"nailgun" No Yes
"lowercase_tags" Yes (_) No
"PKG-008 fixer..." Yes (-) No

This was discovered while investigating intermittent Engram failures during an epub-repair session. The user initially suspected parallelism (multiple mem_search calls in one <invoke> block), but systematic testing proved the bug is query-dependent, not concurrency-dependent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions