Skip to content

fix(memory-core): surface empty narrative generation instead of silent fallback (#90781) - #90827

Closed
lonexreb wants to merge 3 commits into
openclaw:mainfrom
lonexreb:fix/90781-memory-narrative-empty-text
Closed

lonexreb wants to merge 3 commits into
openclaw:mainfrom
lonexreb:fix/90781-memory-narrative-empty-text

Conversation

@lonexreb

@lonexreb lonexreb commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a Dreaming narrative run produces no usable text, memory-core writes a
fallback diary entry and logs a bare narrative generation produced no text
warning — giving operators no signal about why (empty completion, tool-only
assistant turn, refusal, non-text parts, etc.). Issue #90781.

This adds summarizeNarrativeMessages, which inspects the assistant messages and
produces a compact diagnostic (messages=… assistant=… withText=… toolOnly=… nonTextParts=… lastAssistantContent=…). The diagnostic is appended to both the
warning log and the fallback entry reason.

Rebase note

Rebased onto current main. Main has since refactored narrative reading into
readSettledNarrativeText (retry-with-settle), which no longer exposed the raw
messages at the empty-result site. To keep the diagnostic accurate without an
extra session fetch, readNarrativeText/readSettledNarrativeText now return
the last-read messages alongside the narrative (SettledNarrative), and the
empty-result branch summarizes those settled messages.

Verification

  • node scripts/run-vitest.mjs extensions/memory-core/src/dreaming-narrative.test.ts → 63 passed.
  • pnpm tsgo:extensions → clean.
  • oxfmt --check / oxlint clean on changed files.

Closes #90781

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 6, 2026
@clawsweeper

clawsweeper Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 10, 2026, 8:48 PM ET / July 11, 2026, 00:48 UTC.

Summary
The PR preserves the final settled narrative-message snapshot, logs a compact classification when no usable assistant text is found, and visibly marks synthetic fallback entries in DREAMS.md.

PR surface: Source +99, Tests +70. Total +169 across 4 files.

Reproducibility: yes. at source level and through the linked live reports: after bounded settled reads yield no extractable assistant narrative, current main enters the fallback branch. The changed current-head warning and diary output have not yet been demonstrated in a real run.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/dreaming-narrative.test.ts, unknown-data-model-change: extensions/memory-core/src/dreaming-narrative.ts, vector/embedding metadata: extensions/memory-core/src/dreaming-narrative.ts, vector/embedding metadata: extensions/memory-core/src/dreaming-phases.test.ts, vector/embedding metadata: extensions/memory-core/src/dreaming.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #90781
Summary: This PR is the candidate fix for the canonical warning-diagnostic and fallback-visibility issue; delayed persistence and archived-session loss share symptoms but require distinct fixes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post redacted gateway warning output and the corresponding DREAMS.md fallback entry from a real run on the current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused tests and green CI are supplemental only; add redacted after-fix gateway output and the corresponding DREAMS.md fallback entry from a real run, with private data removed, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

Maintainer options:

  1. Decide the mitigation before merge
    Land the metadata-only diagnostic and cause-neutral fallback marker after a redacted real fallback run proves both the gateway warning and resulting DREAMS.md entry, while keeping archived-session recovery on its separate track.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining blocker is contributor-supplied real behavior proof rather than a concrete code defect suitable for automated repair.

Security
Cleared: The diff adds no dependency, permission, credential, external execution, or supply-chain surface, and its diagnostics are limited to counts and content-shape labels.

Review details

Best possible solution:

Land the metadata-only diagnostic and cause-neutral fallback marker after a redacted real fallback run proves both the gateway warning and resulting DREAMS.md entry, while keeping archived-session recovery on its separate track.

Do we have a high-confidence way to reproduce the issue?

Yes at source level and through the linked live reports: after bounded settled reads yield no extractable assistant narrative, current main enters the fallback branch. The changed current-head warning and diary output have not yet been demonstrated in a real run.

Is this the best way to solve the issue?

Yes for the canonical issue's observability scope: the patch reuses the final settled snapshot, avoids a competing recovery path, and keeps raw narrative content out of diagnostics. It is intentionally not the solution to archived-session narrative loss.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 249e6efe6351.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: The PR improves diagnosis and visibility of degraded background memory narratives without affecting core chat or gateway availability.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and green CI are supplemental only; add redacted after-fix gateway output and the corresponding DREAMS.md fallback entry from a real run, with private data removed, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +99, Tests +70. Total +169 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 113 14 +99
Tests 3 77 7 +70
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 190 21 +169

What I checked:

Likely related people:

  • vignesh07: Commit 61e61cc introduced the dreaming diary surface and original no-text warning path. (role: introduced behavior; confidence: high; commits: 61e61ccc182f; files: extensions/memory-core/src/dreaming-narrative.ts)
  • mbelinky: Multiple merged changes hardened narrative fallback, idempotency, and grounded backfill behavior in the same module. (role: recent area contributor; confidence: high; commits: 46f8c4dfd5f9, bed53c77aa2a, dbf5960bd96a; files: extensions/memory-core/src/dreaming-narrative.ts)
  • bennewell35: Authored the merged bounded message-read retry immediately preceding this PR's diagnostic fallback branch. (role: recent adjacent contributor; confidence: high; commits: cdb55b3edb37; files: extensions/memory-core/src/dreaming-narrative.ts, extensions/memory-core/src/dreaming-narrative.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (4 earlier review cycles)
  • reviewed 2026-06-22T02:47:46.608Z sha 6b68258a0e2512ae80fe41fe768cd76fc34eabcd :: needs real behavior proof before merge. :: [P2] Classify normalized toolCall blocks as tool-only | [P2] Mark the diary fallback content
  • reviewed 2026-06-30T21:15:39.151Z sha 6b68258a0e2512ae80fe41fe768cd76fc34eabcd :: needs real behavior proof before merge. :: [P2] Classify normalized toolCall blocks as tool-only | [P2] Mark the diary fallback content
  • reviewed 2026-07-10T23:52:49.033Z sha ccb58fd422b7c0b9e907e4c41342858b4222f778 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T00:16:24.516Z sha ccb58fd422b7c0b9e907e4c41342858b4222f778 :: needs real behavior proof before merge. :: [P2] Make the fallback marker match non-text failure causes

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 6, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jun 15, 2026
@lonexreb
lonexreb force-pushed the fix/90781-memory-narrative-empty-text branch from 16f00aa to 6b68258 Compare June 15, 2026 22:14
@lonexreb

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 19, 2026
@C-LaForest

Copy link
Copy Markdown

Real-behavior repro (OpenClaw 2026.6.5, ollama provider)

The silent fallback this PR replaces does fire in normal use — environment: OpenClaw 2026.6.5, Linux x86_64, provider ollama (qwen3.6:35b) via a think:false-injecting proxy. memory-core: narrative generation produced no text for <phase> phase; writing fallback diary entry shows up on most dreaming runs with no surfaced signal, so making it visible is a real improvement.

One caveat on the "empty" framing, in case it informs what gets surfaced: in our captured case the narrative was not actually empty. The model generated a full ~140-word narrative that was durably persisted (assistant turn, content:[{type:"text",...}], stopReason:"stop", ~136 output tokens) — yet the run logged "produced no text" and fell back. gateway sessions.get returns that turn in exactly the shape extractNarrativeText expects, so the text is fully recoverable after the fact. This matches the archive-vs-read race in #87182 / #90781: the read came back empty before the already-generated text was retrievable. So for these cases the surfaced "empty" is really "generated-but-lost-on-read" (recoverable via #87206) — might be worth distinguishing "truly empty" from "lost-on-read."

@lonexreb
lonexreb force-pushed the fix/90781-memory-narrative-empty-text branch from 6b68258 to ccb58fd Compare July 10, 2026 23:39
@lonexreb

Copy link
Copy Markdown
Contributor Author

Addressed both P2 findings in ccb58fd422b and rebased onto current main:

  • [P2] Classify normalized toolCall blocks as tool-only — the summarizer now recognizes the canonical OpenClaw normalized shape (toolCall) plus the camel/snake provider-native variants (toolUse, tool_use, tool_call, functionCall, function_call), matching the part-type list core already uses in embedded-agent-subscribe.tool-text-diagnostics.ts. New regression: a normalized toolCall-only assistant turn reports toolOnly=1 nonTextParts=0 instead of a misleading non-text-parts diagnostic.
  • [P2] Mark the diary fallback content — the DREAMS.md fallback entry now reads (Fallback entry: narrative generation produced no usable text for this run.) … so the diary-visible degraded state is identifiable at a glance while still leaking no staging content.

node scripts/run-vitest.mjs run on dreaming-narrative/dreaming-phases/dreaming suites — 168/168 pass; tsgo:extensions + oxfmt clean.

After-fix runtime/log proof of the no-text diagnostic path remains outstanding — flagged to the PR author.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 10, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jul 10, 2026
@lonexreb

Copy link
Copy Markdown
Contributor Author

The previous re-review run failed mid-flight (progress state: Failed) — the P2 fixes for both findings are on head ccb58fd422b (normalized toolCall/toolUse/functionCall classification + marked (Fallback entry: …) diary content), see the comment above for details.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jul 11, 2026
@lonexreb

Copy link
Copy Markdown
Contributor Author

Addressed the new P2 (Make the fallback marker match non-text failure causes) and rebased onto current main:

  • The DREAMS.md fallback marker is now cause-neutral: (Fallback entry: this run could not generate a diary narrative.) — accurate for all three paths that write it (no-text completion, unsuccessful run terminal status, request-scoped subagent runtime unavailability). The specific cause stays in the gateway log line (used fallback … because <reason>), never in the diary, per the no-staging-content rule.

node scripts/run-vitest.mjs run on the three dreaming suites — 168/168 pass; tsgo:extensions + oxfmt clean.

Redacted after-fix gateway warning + DREAMS.md artifact from a real fallback run remains the outstanding gate (flagged to the PR author).

@clawsweeper re-review

@lonexreb
lonexreb force-pushed the fix/90781-memory-narrative-empty-text branch from ccb58fd to 57ea097 Compare July 11, 2026 00:27
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 11, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(memory-core): surface empty narrative generation instead of silent fallback (#90781) This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict stalled_unproven_pr (decision packet 2026-07-26T00:16:20.261Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-core narrative generation silently produces no text and writes fallback diary entries (light/rem/deep phases)

3 participants