Skip to content

fix(memory): memory search no longer pages Sentry while the index is still building - #288

Merged
william-antoline-boon merged 2 commits into
boonfrom
fix/eng-21227-memory-index-missing-not-error
Oct 14, 2026
Merged

william-antoline-boon merged 2 commits into
boonfrom
fix/eng-21227-memory-index-missing-not-error

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where the agent's memory_search tool would tell users memory recall was unavailable — with an inaccurate "built with a different embedding provider" explanation — during the first moments of a new session, before its memory index had finished building for the first time. The same condition paged OPENCLAW-FLEET-X4 to Sentry as an unhandled exception on every occurrence: 166 events across 7 customer hosts over 44 days (dominated by the busiest host, which hit it repeatedly, not just once).

Why This Change Was Made

resolvePausedMemoryIndexIdentityReason treated a "missing" index identity (no catalog built yet — the ordinary, self-healing state right after a new session starts) identically to a "mismatched" one (a real, operator-actionable case: an index built against a since-changed provider/model/scope). Both returned the same hard disabled/error tool result. That bare error field alone was enough for the host's generic tool-result classifier to flag it as a real exception — the same class of noisy-but-not-broken tool result already fixed for web_fetch 403/404/429 in #282 — with no equivalent carve-out yet for this case.

This change narrows the pause to "mismatched" only. "missing" now falls through to the ordinary search flow, which also means it reaches tools.ts's own forced-retry-sync block — previously unreachable for this case, since the old code returned before ever getting there — giving it a real chance to self-heal within the same call, not just via the independent session-start background sync.

Scope / known follow-ups (not blocking): this fixes the memory_search agent tool specifically. The deeper root cause — manager.search()'s cold-start self-heal checks "does any content exist," not "is the index identity valid" — is untouched, and cli.runtime.ts's direct manager.search() call (the openclaw memory search CLI command) has no equivalent gating before or after this change. Tracking as a separate, lower-risk-budget follow-up rather than widening this PR. Also noting a narrow residual case found in review: the now-reachable forced retry-sync can throw a cross-process lock-contention error (manager-reindex-lock.ts) if something else (e.g. a concurrent CLI reindex) holds the reindex lock at the same moment — a different, much lower-frequency trigger of the same "unavailable" result shape than the one being fixed here.

User Impact

Agents no longer tell customers memory is "paused" with an incorrect reason during normal cold-start timing. On-call no longer gets paged for this non-issue.

Evidence

  • New test: extensions/memory-core/src/tools.test.ts — "treats a missing index identity as an ordinary empty result, not a paused error" — asserts no disabled/error fields, and that the forced-retry-sync is now reached (previously unreachable for this status).
  • Existing "mismatched" test ("returns unavailable metadata when the index identity is paused") passes unchanged — confirms that path is untouched.
  • Full extensions/memory-core suite: 943/943 passing, 63 files, no regressions.
  • Root cause traced end-to-end through the actual code (manager-reindex-state.ts → manager.ts → tools.ts → tool-result-error.ts → embedded-agent-subscribe.tools.ts → sentry-monitor/captures.ts → dispatch.ts) and verified empirically: constructed the real, unmodified manager.search() method against a "content exists, catalog missing" state and confirmed its cold-start self-heal is skipped in that exact condition (separate from this PR's fix, explains why "missing" occurs despite existing self-heal layers).

🤖 Generated with Claude Code


Summary by cubic

Fixes memory_search treating a not-yet-built memory index as a hard error, which paged Sentry on every cold start (166 events across 7 hosts over 44 days).

A "missing" index identity — the ordinary state in the first moments of a new session before the background sync finishes building the catalog — was collapsed with a genuinely actionable "mismatched" identity (index built for a different provider/model/scope). Both returned the same disabled/error tool result, and that bare error field was enough for the host's tool-result classifier to flag it as an unhandled exception. "missing" now falls through to the normal search flow, which also reaches the existing forced-retry-sync block — previously unreachable from this path — so the index gets a chance to self-heal within the same call. Searching now returns an ordinary empty result during cold start instead of a misleading "built with a different embedding provider" error.

Bug Fixes

  • Only "mismatched" index identities now pause memory_search; "missing" proceeds with normal search and retry-sync.
  • Added a test asserting "missing" yields an empty result with no disabled/error fields, and that retry-sync is now reached; the "mismatched" path's existing test passes unchanged.
  • Known narrower follow-up (not fixed here): the now-reachable forced retry-sync can throw a cross-process lock-contention error if a concurrent CLI reindex holds the reindex lock — a much lower-frequency trigger of the same result shape.

Written for commit 52a38f0. Summary will update on new commits.

View guided diff Turn on auto-fix

…still building

A "missing" index identity (no catalog built yet -- the ordinary state
for the first moments of a new session/workspace) was treated the same
as a "mismatched" one (a real, operator-actionable config drift):
resolvePausedMemoryIndexIdentityReason paused memory_search for both,
returning a disabled/error result with a misleading "built with a
different embedding provider" explanation.

That bare error field was enough for the host's generic tool-result
classifier to flag it as a real exception, with no sentry-monitor
carve-out catching it (the same noisy-tool-result class already fixed
for web_fetch 403/404/429 in #282) -- paging OPENCLAW-FLEET-X4 on every
cold-start race, 166 events across 7 customer hosts over 44 days.

Narrow resolvePausedMemoryIndexIdentityReason to only pause on
"mismatched". "missing" now falls through to the normal search flow,
where it also gets a real chance at tools.ts's own forced-retry-sync
block (previously unreachable for this case, since the early return
happened first).

Fixes: ENG-21227 / OPENCLAW-FLEET-X4

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@william-antoline-boon
william-antoline-boon requested a review from a team October 14, 2026 03:39

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread extensions/memory-core/src/tools.ts Resolved
Per cubic-dev-ai review feedback: keep the comment focused on the
missing-vs-mismatched behavior and its false-unavailable-result
consequence, not ticket/incident lore.

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: Approve

Approve covers 52a38f06e5607d49437a216bbff0901b55be1c8a specifically (cleanly rebased on origin/boon @ 15bfdb55058).

Evidence & Verification Summary

  1. Root Cause & Invariant Fix (extensions/memory-core/src/tools.ts):

    • resolvePausedMemoryIndexIdentityReason now pauses search strictly on "mismatched".
    • A "missing" index identity (normal cold-start state prior to initial catalog completion) no longer triggers early return with { disabled: true, error: ... } and the misleading "different embedding provider" message that previously flagged as an unhandled tool exception in Sentry (OPENCLAW-FLEET-X4 / ENG-21227).
    • The fallback error message is cleanly updated to "memory index identity is mismatched".
  2. Self-Healing Flow:

    • Allowing "missing" to proceed through search means it reaches the existing forced-retry-sync block (activeMemory.manager.sync({ reason: "search", force: true })) in tools.ts on empty results, giving cold starts an immediate in-band opportunity to self-heal.
    • If still empty, it returns clean results: [] without disabled or error metadata.
  3. Test Coverage (extensions/memory-core/src/tools.test.ts):

    • Added test "treats a missing index identity as an ordinary empty result, not a paused error" asserting:
      • details.results equals []
      • details.disabled is undefined
      • details.error is undefined
      • searchCalls === 2 and getMemorySyncMockCalls() === 1 (proving forced-retry-sync is reached)
    • Existing "mismatched" test remains intact and passes, verifying that mismatched embedding provider configs still pause cleanly.
  4. Review Threads:

    • Verified via GraphQL: 0 unresolved threads. The single feedback thread from cubic-dev-ai on source comment lore was addressed in 52a38f06.
  5. CI & Sanity:

    • All 75 GitHub Actions checks passing on head commit 52a38f06e5607d49437a216bbff0901b55be1c8a.

@william-antoline-boon
william-antoline-boon merged commit 1a33be6 into boon Oct 14, 2026
139 of 142 checks passed
@william-antoline-boon
william-antoline-boon deleted the fix/eng-21227-memory-index-missing-not-error branch October 14, 2026 07:01
@william-antoline-boon

Copy link
Copy Markdown
Collaborator Author

Post-merge e2e verification (no mocks on manager internals)

Ran against the actual merged code on boon (1a33be672f7): a real temp workspace, a real SQLite-backed MemoryIndexManager via the production getMemorySearchManager factory, and the real, unmodified memory_search tool end-to-end.

Steps:

  1. Built a genuinely valid index (real chunks + real catalog row) via manager.sync({force:true}).
  2. Deleted the catalog row directly from the real SQLite file — manufacturing the exact "content exists, catalog missing" state deterministically, rather than racing a timing window.
  3. Called the real tool end-to-end.
    • Result: no disabled/error/warning fields — a clean empty-result response.
    • Bonus: re-opened the SQLite file afterward and confirmed the catalog row had been rebuilt for real within that same call — the self-heal path (now reachable for "missing", per this fix) actually fired, on disk.
  4. A/B proof it's a meaningful test, not a tautology: temporarily reverted just the one-line condition back to the old "mismatched" || "missing" check and re-ran the identical test — it failed immediately, disabled: true reproducing exactly. Restored the fix, re-ran, green again.
  5. Full extensions/memory-core suite on merged boon: 944/944 passing.

Fix behaves as intended end-to-end, on real infrastructure. Scratch test file was not committed (throwaway worktree, removed after verification).

convyusboy added a commit that referenced this pull request Oct 15, 2026
Cut the fork release that ships the six commits on boon since
v2026.6.34-boon.7:

- #292 (ENG-21407): resolve relative media/PDF paths against the agent
  workspace in pdf, image_generate, video_generate, and music_generate,
  instead of the gateway process cwd; delete the image tool's duplicate
  inline resolution now that the loader owns it canonically.
- #289 (ENG-21228): let image, pdf, image_generate, video_generate, and
  music_generate read agent-rendered files outside the default roots
  (e.g. /tmp crops) when the agent is permitted host reads outside its
  workspace, matching the outbound MEDIA: path; a blocked path now
  returns a denied tool result instead of a raw error that paged Sentry.
- #293 (ENG-21406): raise the image tool's default vision timeout 60s ->
  150s (above boon-llm-gateway's 120s fallback-chain budget), share one
  deadline across setup and the provider request, and return a graceful
  timeout status instead of letting the raw error end the turn; mirrored
  in the Codex dynamic-tool watchdog; sentry-monitor downgrades image
  timeouts to a warning.
- #291: sentry-monitor no longer pages on ordinary non-zero exec exit
  codes; only shell lookup failures (126/127) stay exceptions, now
  fingerprinted per missing binary. Runtime Docker image adds unzip.
- #288 (ENG-21227): memory_search no longer pauses/pages Sentry while
  the index is still building ("missing" identity); only a real
  "mismatched" embedding provider pauses it.
- #294 (ENG-21405, test-only): regression coverage confirming the cron
  delivery-target guard already rejects a directory-less channel's
  unknown target end to end; root cause for the live Sentry errors was
  a stale anychat-boon-web plugin install, not a core gap.

Bump root package.json and npm-shrinkwrap.json, all 136 plugin
manifests, and the version field in every extension's
npm-shrinkwrap.json via pnpm plugins:sync, hand-patched the same way as
boon.7 (the npm-shrinkwrap generator still can't regenerate cleanly on
this fork: pre-existing, unrelated @sentry/node nested
@opentelemetry/resources / sdk-trace-base registry-resolution drift,
reproduced again on this base). Verified via
test/package-manager-config.test.ts (12/12) and the full
release-preflight check suite (plugin versions, inventory, base config
schema, bundled channel config metadata, config docs baseline, plugin
SDK exports/API baseline/surface budget, root dependency ownership) --
all green except the known shrinkwrap generator drift. Add the
2026.6.34-boon.8 CHANGELOG.md section and the generated
extensions/matrix/CHANGELOG.md entry.

No config schema, plugin-SDK surface, or plugin source/dependency
change in slack/msteams/diagnostics-prometheus; this is a gateway-only
roll (bundled-plugin source changes in codex, memory-core, and
sentry-monitor ship inside the gateway tarball). Targeted tests for all
three touched extensions plus the codex dynamic-tool-execution suite:
1075/1075 passing.

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants