Skip to content

feat(system-agent): agentic cached caretaker greeting with quick actions - #111615

Merged
steipete merged 6 commits into
mainfrom
claude/system-agent-greeting-110896
Jul 20, 2026
Merged

steipete merged 6 commits into
mainfrom
claude/system-agent-greeting-110896

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The system agent ("Ask OpenClaw" custodian) greeted operators with a static template on every session. It had no identity, never surfaced pending updates, degraded channels, or manual config edits, and re-ran the same boilerplate regardless of system state. Part of the system-agent overhaul program (#110896, PR E).

Why This Change Was Made

The custodian should feel like the OpenClaw system itself: a caretaker that opens with a short, grounded status ("all systems nominal", "an update is ready") and quick-action chips, without burning tokens on every open.

  • New src/system-agent/greeting.ts: caretaker greeting resolver with a single-slot cache in the state DB (scope system-agent-greeting). Facts (update availability, channel health, external-edit flag, audit watermark) are hashed; the model is consulted only when the fact hash changes and inference is available, with single-flight, a 20s timeout, and a 60s failure backoff. Otherwise the cached or deterministic template text is served.
  • Grounding is positive-presence-only: model output must actually mention the update version and degraded channels it was told about, or it falls back to the template. Headings, fenced code, and JSON-shaped output are rejected.
  • The external-edit alert is host-owned: SYSTEM_AGENT_EXTERNAL_EDIT_ALERT is appended at delivery, never entrusted to the model, and deliberately excluded from the facts hash so it does not churn the cache.
  • Deterministic quick-action chips (buildSystemAgentGreetingQuestion) derived from overview + facts: setup, doctor, update, degraded-channel triage, audit history, talk-to-agent.
  • Delivery-safe audit acknowledgement: the audit cursor is captured with the pending welcome (welcomeAuditSequence on the gateway session) and acknowledged only after the response is actually sent, so a dropped socket re-surfaces the manual-edit notice on retry.
  • update.check-adjacent snapshot sharing: update.status now returns updateAvailable from the startup snapshot, and the greeting reads the same snapshot instead of doing its own network probe.
  • Welcome-only inference gating: creating a session with a first message never spends a model call on the greeting (template path), keeping first-turn latency for the actual question.
  • Compact deterministic fallback startup message in overview.ts for the no-inference path.

User Impact

Opening the custodian chat now shows a short caretaker status with its own identity — update available, degraded channels, "config was edited outside OpenClaw" — plus quick-action chips, while staying token-efficient (model consulted only when system facts change). No config surface, protocol method, or schema changes; openclaw doctor needs no migration.

Evidence

  • node scripts/run-vitest.mjs src/system-agent/greeting.test.ts — 38 tests green (cache hit/miss, watermark paging/races, grounding rejection, host-alert delivery scoping, chips matrix incl. missing-model handoff suppression, degraded predicates).
  • node scripts/run-vitest.mjs src/gateway/server-methods/system-agent.test.ts src/gateway/server-methods/system-agent-session-ownership.test.ts — green post-rebase onto the session-ownership refactor (fix(gateway): prevent cross-client system-agent session takeover #111565); ownership suite now pins the greeting so identity stays the only variable.
  • node scripts/run-vitest.mjs src/system-agent/overview.test.ts src/gateway/server-methods/update.test.ts ui/src/pages/custodian — green.
  • Live dev-gateway verification (scratch state dir, real Anthropic probe): welcome renders caretaker status + chips; restart re-serves cached greeting without a model call; failed delivery re-surfaces the external-edit alert.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Jul 20, 2026
@steipete
steipete marked this pull request as ready for review July 20, 2026 02:39
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 20, 2026, 12:15 AM ET / 04:15 UTC.

Summary
The branch adds a cached model-phrased system-agent caretaker greeting, fact-derived quick actions, update/channel status grounding, and delivery-gated acknowledgement of external configuration edits.

PR surface: Source +785, Tests +1275, Other +3. Total +2063 across 16 files.

Reproducibility: not applicable. This PR adds a new welcome experience rather than reporting a broken existing behavior. The relevant validation is an after-fix runtime demonstration of the new interaction and retry semantics.

Review metrics: 1 noteworthy metric.

  • Persistent greeting state: 1 single-slot cache plus 1 delivery acknowledgement cursor. The change introduces stateful welcome caching and acknowledgement sequencing in a gateway/session path, so runtime retry proof matters before merge.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/system-agent/assistant-prompts.ts, migration/backfill/repair: src/system-agent/overview.ts, serialized state: src/system-agent/assistant-prompts.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
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:

  • Attach redacted live gateway proof for the welcome, cache-hit restart, and failed-delivery retry path.
  • Obtain explicit maintainer sponsorship for making this model-phrased greeting the core system-agent default.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR describes a real dev-gateway run but supplies no inspectable redacted artifact proving the visible welcome, cache behavior after restart, or failed-delivery retry; add a terminal transcript, runtime log, or recording and redact private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A redacted Control UI chat interaction can materially demonstrate the visible caretaker welcome and quick-action behavior, complementing the required runtime proof. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify and capture the caretaker welcome with quick-action chips in the Control UI, using redacted evidence.

Risk before merge

  • [P1] Merging changes the first system-agent interaction from a stable static welcome to model-phrased, cached content; maintainers need to confirm that this product behavior belongs in the core rescue/setup path.
  • [P1] The new cached greeting and delayed audit acknowledgement share gateway session state, so delivery and retry semantics need inspectable runtime proof beyond mocks and focused tests.

Maintainer options:

  1. Add proof before merge (recommended)
    Provide a redacted live gateway transcript, terminal output, or recording that visibly demonstrates the caretaker welcome, restart cache hit, and failed-delivery alert retry.
  2. Accept the new welcome contract
    A maintainer may explicitly accept the model-phrased welcome as the core system-agent default after reviewing the interaction and upgrade implications.
  3. Pause the greeting phase
    Defer this feature if core should not make the rescue/setup path depend on an optional model-generated presentation layer.

Next step before merge

  • [P1] A protected maintainer-area product decision and contributor-supplied real behavior proof are required; there is no narrow mechanical repair lane to queue.

Maintainer decision needed

  • Question: Should the core system-agent rescue/setup flow adopt a model-phrased cached caretaker greeting and quick-action chips as its default welcome behavior?
  • Rationale: This is a new user-facing identity and inference behavior in the protected system-agent surface; tests can validate mechanics but cannot establish whether this is the intended long-term product boundary for the core setup path.
  • Likely owner: steipete — The related overhaul proposal and merged session-ownership work make this the strongest available routing signal for the intended system-agent direction.
  • Options:
    • Sponsor and require runtime proof (recommended): Keep the feature in core, after adding inspectable redacted proof for rendering, cache reuse, and delivery-gated retry behavior.
    • Keep the deterministic welcome: Decline the model-generated greeting direction and retain a concise deterministic welcome with only existing setup guidance.
    • Narrow the scope: Accept deterministic quick actions and status facts while deferring model phrasing until the system-agent product direction is settled.

Security
Cleared: The reviewed patch surface adds no dependency, workflow, permission, secret-handling, package-resolution, or supply-chain change; no concrete security regression is identified.

Review details

Best possible solution:

Sponsor the caretaker-greeting direction only if the core system-agent should own model-generated welcome copy, then retain the deterministic fallback and land with a redacted live proof covering welcome rendering, cache reuse, and retry after a failed delivery.

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

Not applicable: this PR adds a new welcome experience rather than reporting a broken existing behavior. The relevant validation is an after-fix runtime demonstration of the new interaction and retry semantics.

Is this the best way to solve the issue?

Unclear: the branch is a coherent implementation of the proposed design, but whether model-generated greeting text belongs in the core system-agent rescue path requires explicit product direction rather than an engineering-only verdict.

AGENTS.md: unclear because the file could not be read completely.

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

Label changes

Label justifications:

  • P3: This is a proposed system-agent UX and identity enhancement rather than an urgent regression.
  • merge-risk: 🚨 compatibility: Existing users will receive a different default system-agent welcome with model-phrased content and quick actions.
  • merge-risk: 🚨 session-state: The patch stores a pending audit sequence on gateway sessions and clears it only after the welcome delivery path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes a real dev-gateway run but supplies no inspectable redacted artifact proving the visible welcome, cache behavior after restart, or failed-delivery retry; add a terminal transcript, runtime log, or recording and redact private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +785, Tests +1275, Other +3. Total +2063 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 8 836 51 +785
Tests 7 1282 7 +1275
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 16 2121 58 +2063

What I checked:

  • Current patch surface: The branch adds the greeting cache/facts implementation and its focused test suite, including deterministic fallback, channel/update facts, and audit cursor handling. (src/system-agent/greeting.ts:1, 2d7ba9203240)
  • Delivery-state boundary: The gateway session gains a pending welcome audit sequence and a helper that acknowledges it only after the welcome response path completes, making this a session-state-sensitive change. (src/gateway/server-methods/system-agent.ts:84, 2d7ba9203240)
  • Related merged prerequisite: The related session-ownership work was merged as commit 3c0f55b; this PR’s body identifies the greeting tests as rebased onto that ownership boundary, but it remains an unmerged feature branch. (src/gateway/server-methods/system-agent-session-ownership.test.ts:23, 3c0f55b58f3c)
  • Proof gap: The PR body reports a live dev-gateway verification but provides no inspectable redacted transcript, terminal output, recording, runtime log, or linked artifact for the rendered welcome, cache reuse after restart, and failed-delivery retry. (2d7ba9203240)
  • Repository-policy check: A read-only attempt to inspect the on-disk repository policy failed before command execution because the sandbox could not establish loopback networking; the supplied repository policy was applied where visible, including the protected maintainer-label and real-proof gates. (AGENTS.md, bc76bb893379)

Likely related people:

  • steipete: Authored the related merged system-agent session-ownership repair and the broader system-agent-overhaul proposal that identifies this greeting work as a discrete phase. (role: recent system-agent and gateway contributor; confidence: medium; commits: 3c0f55b58f3c, 1449bf2183ea; files: src/gateway/server-methods/system-agent.ts, src/gateway/server-methods/system-agent-session-ownership.test.ts, src/system-agent/greeting.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 (3 earlier review cycles)
  • reviewed 2026-07-20T02:44:13.140Z sha 6b1b7b0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:18:58.328Z sha 0769794 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:32:31.120Z sha 2d7ba92 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Live runtime proof (Rank-up moves)

Ran the full caretaker-welcome flow live on PR head 2d7ba92, on an idle Mac (megaclaw) with a fresh shallow clone of this branch, a scratch OPENCLAW_STATE_DIR, loopback token-auth gateway on a free port, and a real Anthropic API key supplied via env. One disclosed local accommodation, unrelated to this PR's surface: DEFAULT_MODEL_RUNTIME_BUILD_TIMEOUT_MS in src/agents/prepared-model-runtime.ts raised 30s→300s for the run, because current main times out fresh-state gateway startup ("prepared model runtime publication timed out", regression window includes #111173's model-discovery lifecycle refactor; it reproduces on clean main with no PR-E code involved and is being investigated separately). Setup used the live RPCs: openclaw.setup.detect → openclaw.setup.activate {"kind":"anthropic-api-key"} (real probe; persisted anthropic/claude-opus-4-8).

Move 1 — initial caretaker welcome and quick actions

openclaw.chat {"sessionId":"proof-welcome-1"} on the freshly activated gateway returned a model-phrased caretaker status with deterministic chips:

{
  "sessionId": "proof-welcome-1",
  "reply": "All systems nominal — config valid, gateway reachable at 127.0.0.1.\nChannels healthy, no degradation.\nStanding by.",
  "action": "none",
  "question": {
    "id": "system-agent-quick-actions",
    "header": "Quick actions",
    "question": "What would you like me to do?",
    "options": [
      { "label": "Talk to my agent", "reply": "talk to agent", "recommended": true },
      { "label": "Show recent changes", "reply": "audit" }
    ]
  }
}

Gateway log for this turn shows the real model call: [model-fetch] response provider=anthropic api=anthropic-messages model=claude-opus-4-8 status=200. The greeting cache slot after this welcome (scope system-agent-greeting in the state DB):

{"lastSeenAuditSequence":1,"factsHash":"6bbdd4b6c1b4af22…","text":"All systems nominal — config valid, gateway reachable at 127.0.0.1.\nChannels healthy, no degradation.\nStanding by.","modelRef":"anthropic/claude-opus-4-8","at":1784534413783}

Move 3 — external-edit notice on the next welcome (and delivery-gated acknowledgement)

Edited openclaw.json on disk while the gateway ran (added logging.level). The watcher journaled it — config-audit scope, newest record:

{"event":"config.external","detectedBy":"watch","previousHash":"469c75a5…","nextHash":"68caf68e…","valid":true,"changedPaths":["logging"]}

The next welcome (proof-welcome-2) served the cached greeting text with the host-owned alert appended at delivery, and the chips flipped to review mode (recommended:false, audit chip relabeled):

{
  "reply": "All systems nominal — config valid, gateway reachable at 127.0.0.1.\nChannels healthy, no degradation.\nStanding by.\nHeads up: the config was edited outside OpenClaw while I was away — open History to review it.",
  "question": { "options": [
    { "label": "Talk to my agent", "reply": "talk to agent", "recommended": false },
    { "label": "Review recent changes", "reply": "audit" }
  ] }
}

The failed-delivery leg of this invariant (socket drop ⇒ no acknowledgement ⇒ alert re-served on retry) is pinned by the focused unit test src/gateway/server-methods/system-agent-greeting-welcome.test.ts › "does not acknowledge audit entries when greeting delivery fails": respond throws, acknowledgeSystemAgentGreetingDelivery is not called, welcomeAuditSequence stays 42, and the retry both re-serves the welcome and then acknowledges. The live run shows the successful-delivery half: acknowledgement happened only with the delivered proof-welcome-2 response (cache slot lastSeenAuditSequence advanced 1→2).

Move 2 — restart cache reuse without a new greeting model call

Killed the gateway, relaunched it on the same scratch state, and opened a fresh session (proof-welcome-3). The welcome text is identical, the alert is gone (already acknowledged), and the cache slot proves no re-planning: same factsHash, same text, and an unchanged at timestamp — the slot was written once, at the first welcome:

{"lastSeenAuditSequence":2,"factsHash":"6bbdd4b6c1b4af22…","text":"All systems nominal — config valid, gateway reachable at 127.0.0.1.\nChannels healthy, no degradation.\nStanding by.","modelRef":"anthropic/claude-opus-4-8","at":1784534413783}

The restart run's log contains model-fetch lines only for the session-create inference verification probe; the greeting itself came from the cache (that's what the unchanged at pins down).

Product acceptance

The model-backed cached caretaker welcome is the deliberate product direction of the system-agent overhaul program (#110896, maintainer-driven); token cost is bounded by the fact-hash cache (model consulted only when system facts change), welcome-only inference gating, and the deterministic template fallback for degraded states.

@steipete
steipete merged commit 629de99 into main Jul 20, 2026
120 checks passed
@steipete
steipete deleted the claude/system-agent-greeting-110896 branch July 20, 2026 08:21
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 21, 2026
…ons (openclaw#111615)

* feat(system-agent): agentic cached caretaker greeting with quick actions

* test(gateway): pin caretaker greeting in session-ownership tests

* fix(system-agent): offer agent handoff chip only when a model is available

* fix(ci): typecheck narrowing, lint, and knip gates for greeting module

* fix(system-agent): reject structured greeting output on every retained line

* test(gateway): split caretaker welcome tests under the max-lines gate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant