Skip to content

fix(memory): fall back to keyword search when embeddings cannot start - #115397

Merged
steipete merged 7 commits into
mainfrom
fix/memory-search-bootstrap-fallback
Jul 29, 2026
Merged

steipete merged 7 commits into
mainfrom
fix/memory-search-bootstrap-fallback

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where the first memory_search on an empty index returned an ordinary empty result when an optional embedding provider could not start, such as OpenAI auth being absent under provider: "auto".

In production this silent path made provider misconfiguration indistinguishable from a genuine no-match result. Agents could then invent explanations instead of reporting that semantic recall had degraded. The existing request-time keyword fallback did not cover provider construction or the first document-embedding request during search bootstrap, even though the memory-search docs promised keyword-only recall for unset/auto providers without usable embedding auth.

Before, a zero-hit tool result exposed no reason:

{
  "results": [],
  "debug": {
    "backend": "builtin",
    "hits": 0
  }
}

After, the same result retains a redacted, actionable degradation reason:

{
  "results": [],
  "debug": {
    "backend": "builtin",
    "hits": 0,
    "embeddingBootstrap": {
      "ok": false,
      "provider": "openai",
      "reason": "MissingProviderAuthError: No API key resolved for provider \"openai\" (auth mode: api-key, checked: OPENAI_API_KEY).",
      "degradedTo": "keyword-only"
    }
  }
}

Why This Change Was Made

Optional-provider bootstrap failures now reuse the existing FTS-only sync generation and finalizeKeywordOnlyResults path. Text and FTS rows are indexed without vectors; required explicit providers remain fail-closed. The existing 30-second embedding availability cache owns retry cadence, ordinary degraded syncs keep the keyword index fresh, and semantic mode resumes only after a successful embedding confirmation and semantic rebuild.

The additive public MemorySearchRuntimeDebug.embeddingBootstrap field is redacted before reaching tool output. No config, storage schema, protocol version, surface budget, or baseline changed.

User Impact

Users with unset/auto/local optional embedding providers retain keyword memory recall when embedding setup or the first bootstrap embedding request fails. Empty keyword results now explain the degradation instead of looking like authoritative proof that memory contains no matches. Explicitly configured remote providers still fail closed.

AI-assisted: implementation and review used Codex; the final full-branch autoreview reported no accepted/actionable findings.

Main-Side CI Follow-up

The temporary per-file timeout mitigation was dropped during current-main replay because #115428 landed the root-cause fix for startup-log shard hangs.

Evidence

  • node scripts/run-vitest.mjs extensions/memory-core/src/memory/manager.fts-only-reindex.test.ts — 17/17 passed. Covers constructor failure, first embedding-request failure, keyword hits, zero-provider caching, existing semantic indexes, concurrent waiters/retries, degraded watch syncs, semantic recovery, failed recovery, redaction, and required-provider fail-closed behavior.
  • node scripts/run-vitest.mjs extensions/memory-core/src/tools.test.ts — 45/45 passed. Covers zero-hit tool JSON and proves no force-sync retry hides debug.embeddingBootstrap.
  • pnpm plugin-sdk:surface:check — passed; 320 entrypoints, 7,508 exports, 0 forbidden package subpaths.
  • pnpm docs:check-mdx — 758 files passed.
  • node scripts/check-changed.mjs -- <8 touched files> — passed on Blacksmith Testbox in https://github.com/openclaw/openclaw/actions/runs/30395124769: all typechecks, changed-file lint, SDK/boundary, dead-export, database-first, schema, and import-cycle guards green.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean; no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: L maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete steipete self-assigned this Jul 28, 2026
@steipete
steipete marked this pull request as ready for review July 28, 2026 20:29
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jul 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete force-pushed the fix/memory-search-bootstrap-fallback branch from a2fae1e to 0efb3ae Compare July 29, 2026 00:48
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Jul 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper review skipped at operator direction due to publication-queue backlog; autoreview (Codex) clean + exact-head CI green served as the pre-land gates.

@steipete
steipete merged commit 5922dd4 into main Jul 29, 2026
128 of 131 checks passed
@steipete
steipete deleted the fix/memory-search-bootstrap-fallback branch July 29, 2026 01:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 29, 2026
* origin/main: (57 commits)
  docs: document gateway and memory chat wizards (#115487)
  fix(agents): restore subagent completion delivery on CLI runtimes (#115422)
  fix(sandbox): stop provisioning failures from exhausting fallbacks (#115481)
  refactor: remove duplicate runtime and plugin paths (#115483)
  fix(ui): canonicalize agent model identity (#115480)
  fix(ui): preview model picker interactions live (#115477)
  fix(ui): match disabled microphone picker background (#115472)
  refactor(code-mode): split focused runtime stress suites (#115462)
  fix(gateway): preserve restart intent across coalesced config writes (#110397)
  fix: scope subagent handoff to direct tools (#115466)
  docs: explain native subagent handoff
  fix: clarify native subagent completion handoff
  fix(config): respect agent directory filesystem case (#105402)
  refactor(code-mode): unify safe OpenAI tool filtering (#115460)
  refactor(code-mode): prepare MCP namespaces once per run (#115459)
  fix(ollama): preserve selected model capabilities during onboarding (#115467)
  refactor(chat): remove duplicate session projection paths (#115461)
  refactor(code-mode): make tool catalogs run-owned (#115458)
  fix(cli): preserve mid-turn text in durable replies (#115455)
  fix(memory): fall back to keyword search when embeddings cannot start (#115397)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…openclaw#115397)

* fix(memory): degrade bootstrap failures to keyword search

* docs(memory): clarify recovery status projection

* fix(memory): handle bootstrap embedding failures

* fix(memory): trust resolved provider diagnostics

* fix(memory): keep degraded syncs keyword-only

* fix(memory): confirm embedding recovery before semantic mode

* fix(memory): restore semantic readiness after recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant