Repository navigation
feat(system-agent): agentic cached caretaker greeting with quick actions - #111615
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 20, 2026, 12:15 AM ET / 04:15 UTC. Summary 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.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest 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 changesLabel justifications:
Evidence reviewedPR surface: Source +785, Tests +1275, Other +3. Total +2063 across 16 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (3 earlier review cycles) |
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 Move 1 — initial caretaker welcome and quick actions
{
"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: {"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 {"event":"config.external","detectedBy":"watch","previousHash":"469c75a5…","nextHash":"68caf68e…","valid":true,"changedPaths":["logging"]}The next welcome ( {
"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 Move 2 — restart cache reuse without a new greeting model callKilled the gateway, relaunched it on the same scratch state, and opened a fresh session ( {"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 Product acceptanceThe 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. |
…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
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.
src/system-agent/greeting.ts: caretaker greeting resolver with a single-slot cache in the state DB (scopesystem-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.SYSTEM_AGENT_EXTERNAL_EDIT_ALERTis appended at delivery, never entrusted to the model, and deliberately excluded from the facts hash so it does not churn the cache.buildSystemAgentGreetingQuestion) derived from overview + facts: setup, doctor, update, degraded-channel triage, audit history, talk-to-agent.welcomeAuditSequenceon 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.statusnow returnsupdateAvailablefrom the startup snapshot, and the greeting reads the same snapshot instead of doing its own network probe.overview.tsfor 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 doctorneeds 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.