Skip to content

fix(gateway): stop persisting passive chat greetings into the durable logbook - #129506

Merged
steipete merged 1 commit into
mainfrom
steipete/system-agent-greeting-dedupe
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/system-agent-greeting-dedupe

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

On a zero-history fresh profile, the first thing an operator sees after onboarding is the system-agent greeting duplicated: the live "Inference is ready" welcome plus an identical copy under an "EARLIER" divider, and another copy accumulates on every chat reconnect. Captured live during a macOS onboarding round (obt826, main 203024e):

Duplicate greeting under EARLIER on a fresh profile

Mechanism: the openclaw.chat session owner (system-agent.ts) seeds each new engine from the durable logbook tail, generates the welcome, then unconditionally persisted that welcome into the logbook (persistEngineHistory, unconditional since 8c7f09a). The embedded Control UI custodian loads openclaw.chat.history independently and labels the seeded tail "EARLIER", so the previous session's identical greeting renders below the fresh one.

Why This Change Was Made

Record facts where they happen: a passive greeting that produced no user interaction is not conversation history. The welcome is now persisted only when the initial request carries genuine user input, or when a caretaker welcome delivers the one-shot external-edit alert (facts.recentExternalEdit) — that alert's audit cursor advances on delivery, so it must remain recoverable in the logbook (contract from 629de99, preserved). Ordinary caretaker, onboarding, and new-agent welcome-only connections keep their greeting in live engine/model context without durable rows. Reset boundaries (reset: true keeps the logbook, clean model context) and real conversational persistence are untouched.

Alternatives rejected: filtering at seedHistory loses because the Control UI loads the unfiltered durable history itself; tagging greeting rows adds persisted/protocol surface for ephemeral state; dropping every greeting unconditionally would break the external-edit durability contract.

User Impact

Fresh installs and every subsequent app launch show one greeting, once. The durable logbook stops accumulating identical passive greetings; externally-edited-config alerts still survive delivery.

Evidence

Regression tests fail pre-fix for all three greeting variants (caretaker, onboarding, new-agent): two consecutive welcome-only connections must not replay the prior greeting (3 failed pre-fix, all pass post-fix). Focused gateway suites green: 43 tests across system-agent-greeting-welcome, system-agent, reset-boundary, and session-lifecycle. Full check-changed green. Autoreview clean ("patch is correct (0.99)"). Production delta +6 lines, justified by the external-edit durability boundary.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 25, 2026 17:54
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Note: this PR also carries a one-commit repair for currently-red main (8e302fe): #129282 rewrote SKILL_AUTHORING_STANDARDS_PROMPT and updated its own tests, but the cross-lane assertion in src/auto-reply/reply/commands-learn.test.ts still expected the deleted phrases, so it passed that PR's CI and now fails every full run (including this PR's first CI attempt, checks-node-compact-large-17). The test now asserts the current load-bearing phrases; verified locally.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 25, 2026, 3:58 PM ET / 19:58 UTC.

ClawSweeper review

What this changes

The branch makes welcome-only system-agent greetings ephemeral except for external-edit alerts, and updates one /learn prompt assertion to match the current standards text.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open: it prevents new passive welcome rows, but affected upgraded profiles retain their existing rows and still render the duplicate. Likely related people: steipete (high confidence).

Priority: P1
Reviewed head: 8e302fec44af163c2942461e6a07bb84b08c25c2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The future-write repair is focused and well-covered, but the unresolved upgrade behavior prevents a merge-ready rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body supplies pre-fix UI evidence, but a redacted after-fix Custodian reconnect trace would still strengthen the user-visible claim.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body supplies pre-fix UI evidence, but a redacted after-fix Custodian reconnect trace would still strengthen the user-visible claim.
Evidence reviewed 6 items Current-main persistence behavior: Current main unconditionally persists every generated welcome after recording its history start, so an existing passive greeting already in the logbook remains available after upgrade.
Legacy rows are replayed to the UI: The transcript store returns all non-reset assistant rows, and Custodian loads openclaw.chat.history before placing its Earlier divider; there is no legacy-row provenance that distinguishes passive greetings from conversation.
Branch only prevents future writes: The proposed guard skips persistEngineHistory for a new welcome-only request but does not inspect, migrate, or otherwise alter existing transcript rows.
Findings 1 actionable finding [P1] Handle legacy passive greetings on upgrade
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 99.45 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4189ms (slowest: built plugin control-plane loads 3416ms)

OpenClaw 2026.8.1 (8e302fe) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile ‹name›     Use a named profile (isol
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Gateway chat sessions seed an engine from the durable system-agent transcript, generate a welcome, and expose the transcript separately to the Custodian UI. The UI renders that loaded transcript as earlier conversation before appending the live welcome.

flowchart LR
  A[Durable transcript] --> B[Gateway chat session]
  B --> C[Engine seeds prior history]
  C --> D[Welcome generated]
  D --> E{User input or external edit?}
  E -->|Yes| F[Persist transcript]
  E -->|No| G[Ephemeral welcome]
  A --> H[Custodian earlier history]
  G --> H
Loading

Decision needed

Question Recommendation
Should this PR include an approved recovery path for existing passive greeting rows, or be explicitly limited to preventing future rows? Add safe legacy recovery: Approve a recovery or migration only if it preserves genuine conversation and proves upgraded profiles no longer show the duplicate.

Why: The durable records contain only role, text, and time, so choosing a migration or deletion rule can discard real conversation and materially changes persisted-state semantics.

Before merge

  • Handle legacy passive greetings on upgrade (P1) - This guard only stops a new persistEngineHistory call. Passive assistant rows written by current main remain in the durable logbook, and openclaw.chat.history still returns them to Custodian before it renders the new welcome, so an affected upgraded profile still shows the duplicate. Add a retention-safe recovery path or explicitly limit the PR to future sessions; do not infer legacy rows from greeting text alone.
  • Resolve merge risk (P1) - Existing profiles retain anonymous assistant rows written by current main, so the user-visible duplicate remains after upgrade even though future welcome-only connections stop adding rows.
  • Resolve merge risk (P1) - The bug fix adds six net production lines; that conditional is presently justified because only the session initializer has both input emptiness and external-edit facts, but it should not replace an explicit legacy-state decision.
  • Complete next step (P2) - A maintainer must choose the safe upgrade behavior for pre-existing durable transcript rows before an automated repair can proceed.

Findings

  • [P1] Handle legacy passive greetings on upgrade — src/gateway/server-methods/system-agent.ts:643-645
Agent review details

Security

None.

PR surface

Source +6, Tests +37. Total +43 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 1 +6
Tests 3 50 13 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 57 14 +43

Review metrics

Metric Value Why it matters
Production versus test delta production +7/-1 (net +6); tests +50/-13 (net +37) The small runtime increase implements the external-edit durability branch; the larger test change covers future welcome-only reconnects but not upgraded retained state.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/system-agent.test.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A redacted Custodian chat transcript before and after reconnect would directly demonstrate the claimed web UI chat effect. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that reconnecting a fresh Custodian session shows one welcome and no duplicate under Earlier.

Merge-risk options

Maintainer options:

  1. Resolve legacy transcript semantics (recommended)
    Add a maintainer-approved recovery path with upgrade coverage that preserves real transcript turns and removes the duplicate for affected profiles.
  2. Accept a forward-only scope
    If no safe legacy classification exists, narrow the PR’s stated behavior to new sessions and leave existing retained history untouched.

Technical review

Best possible solution:

Keep the producer-side guard and add a maintainer-approved, retention-safe recovery for legacy rows; if their origin cannot be established safely, scope the change to future sessions and offer explicit operator recovery rather than deleting rows by greeting text.

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

Yes—current main persists a passive welcome, the transcript reader returns it unchanged, and Custodian loads that history before rendering the next live welcome. The review did not execute the UI flow because this is read-only inspection.

Is this the best way to solve the issue?

No—the new producer guard is the right prevention point for future rows, but it does not solve the retained-state half of the reported behavior for upgraded profiles.

Full review comments:

  • [P1] Handle legacy passive greetings on upgrade — src/gateway/server-methods/system-agent.ts:643-645
    This guard only stops a new persistEngineHistory call. Passive assistant rows written by current main remain in the durable logbook, and openclaw.chat.history still returns them to Custodian before it renders the new welcome, so an affected upgraded profile still shows the duplicate. Add a retention-safe recovery path or explicitly limit the PR to future sessions; do not infer legacy rows from greeting text alone.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 66bfdeffb9b4.

Labels

Label justifications:

  • P1: Affected users continue to see duplicated prior greetings after upgrade, while the PR targets a default Custodian chat path.
  • merge-risk: 🚨 session-state: The branch changes which system-agent turns enter durable transcript state and what later sessions and the UI replay.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body supplies pre-fix UI evidence, but a redacted after-fix Custodian reconnect trace would still strengthen the user-visible claim.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the transcript persistence and read boundary to Peter Steinberger, and this PR continues that same owner-boundary work. (role: recent gateway and transcript owner; confidence: high; commits: 6ad7915c056e, 8e302fec44af; files: src/gateway/server-methods/system-agent.ts, src/system-agent/transcript-store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Choose and prove a retention-safe legacy-state outcome, or narrow the claimed scope to future rows.
  • Attach a redacted after-fix Custodian reconnect trace showing the Earlier section has no duplicate passive greeting.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T19:15:16.422Z sha 8e302fe :: found issues before merge. :: [P1] Retire pre-existing passive greeting rows on upgrade

… logbook

Every fresh system-agent chat session persisted its generated welcome into
the durable logbook, and the next session seeded that tail back as
history. On a zero-history profile the embedded Control UI custodian
(which loads openclaw.chat.history separately) rendered the identical
'Inference is ready' greeting twice — live plus under an EARLIER divider —
and greetings accumulated on every reconnect.

Persist a newly generated welcome only when the request carries genuine
user input, or when a caretaker welcome delivers a one-shot external-edit
alert (facts.recentExternalEdit) whose audit cursor advances on delivery
and therefore must stay recoverable. Ordinary caretaker, onboarding, and
new-agent welcome-only connections keep the greeting in live engine
context without creating durable transcript rows. Reset boundaries and
real conversation persistence are unchanged.

Regression tests fail pre-fix for all three greeting variants: two
consecutive welcome-only connects must not replay the prior greeting.
@steipete
steipete force-pushed the steipete/system-agent-greeting-dedupe branch from 8e302fe to 5258ed2 Compare August 25, 2026 22:18
@steipete
steipete merged commit 7c116ba into main Aug 25, 2026
196 checks passed
@steipete
steipete deleted the steipete/system-agent-greeting-dedupe branch August 25, 2026 22:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
… logbook (openclaw#129506)

Every fresh system-agent chat session persisted its generated welcome into
the durable logbook, and the next session seeded that tail back as
history. On a zero-history profile the embedded Control UI custodian
(which loads openclaw.chat.history separately) rendered the identical
'Inference is ready' greeting twice — live plus under an EARLIER divider —
and greetings accumulated on every reconnect.

Persist a newly generated welcome only when the request carries genuine
user input, or when a caretaker welcome delivers a one-shot external-edit
alert (facts.recentExternalEdit) whose audit cursor advances on delivery
and therefore must stay recoverable. Ordinary caretaker, onboarding, and
new-agent welcome-only connections keep the greeting in live engine
context without creating durable transcript rows. Reset boundaries and
real conversation persistence are unchanged.

Regression tests fail pre-fix for all three greeting variants: two
consecutive welcome-only connects must not replay the prior greeting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant