Fix memory flush YYYY-MM-DD placeholder resolution#17624
Fix memory flush YYYY-MM-DD placeholder resolution#17624grunt3714-lgtm wants to merge 2 commits intoopenclaw:mainfrom
Conversation
|
Thanks! I’ll align with CONTRIBUTING.md.
(For transparency: AI-assisted for wording + minor code review; I wrote/verified the change and added the unit test.) |
|
Follow-up (my last comment got mangled by shell quoting):
AI-assistance transparency: used AI for wording + a light code review; I wrote/verified the change and added the unit test. |
|
outdated, can be discarded |
| if (process.platform === "linux") { | ||
| const systemdAvailable = await isSystemdUserServiceAvailable().catch(() => false); | ||
| if (!systemdAvailable) { | ||
| const hints = [ | ||
| ...renderGatewayServiceStartHints(), | ||
| ...renderSystemdUnavailableHints({ wsl: await isWSL() }), | ||
| ]; | ||
| emit({ | ||
| ok: true, | ||
| result: "not-loaded", | ||
| message: `Gateway service ${service.notLoadedText}.`, | ||
| service: buildDaemonServiceSnapshot(service, false), | ||
| }); | ||
| if (!json) { | ||
| defaultRuntime.log(`Gateway service ${service.notLoadedText}.`); | ||
| for (const hint of hints) { | ||
| defaultRuntime.log(`Start with: ${hint}`); | ||
| } | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
Missing hints in JSON emit for stop action
In runDaemonStart (line 121-127) and runDaemonRestart (line 318-326), the hints array is included in the emit() call so JSON consumers can see them. Here in runDaemonStop, hints is computed and logged to the terminal but not passed to emit() — and the emit payload type doesn't include hints. This means JSON consumers of openclaw daemon stop won't see the systemd hints, unlike start and restart.
If this is intentional, it's fine. If not, you'd need to add hints?: string[] to the emit payload type and pass hints in the emit call.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/daemon-cli/lifecycle.ts
Line: 218:238
Comment:
**Missing `hints` in JSON emit for stop action**
In `runDaemonStart` (line 121-127) and `runDaemonRestart` (line 318-326), the `hints` array is included in the `emit()` call so JSON consumers can see them. Here in `runDaemonStop`, `hints` is computed and logged to the terminal but not passed to `emit()` — and the `emit` payload type doesn't include `hints`. This means JSON consumers of `openclaw daemon stop` won't see the systemd hints, unlike `start` and `restart`.
If this is intentional, it's fine. If not, you'd need to add `hints?: string[]` to the `emit` payload type and pass `hints` in the emit call.
How can I resolve this? If you propose a fix, please make it concise.
Fixes #17603.
Memory flush prompts include a literal
YYYY-MM-DDplaceholder (e.g.memory/YYYY-MM-DD.md). Without a reliable date in context, models can guess the wrong year.This PR resolves the placeholder before invoking the embedded agent, using the configured user timezone (falling back to UTC). It also adds a small helper
formatUserDateYmdand a unit test.Notes:
Greptile Summary
This PR bundles three independent fixes:
Memory flush YYYY-MM-DD placeholder resolution (
agent-runner-memory.ts,date-time.ts,date-time.test.ts): Resolves the literalYYYY-MM-DDplaceholder in memory flush prompts before invoking the embedded agent, using the user's configured timezone. Adds a well-testedformatUserDateYmdhelper that usesIntl.DateTimeFormatwithen-CAlocale for reliable YYYY-MM-DD output. This is the core fix for Memory flush writes files with wrong year — buildTimeSection drops userTime from system prompt #17603.Systemd user bus early guard (
lifecycle.ts): Adds earlyisSystemdUserServiceAvailable()checks inrunDaemonStart,runDaemonStop, andrunDaemonRestartto preventservice.isLoaded()from throwing on Linux systems without a systemd user bus. Returns gracefully with hints instead..venvin skills watcher ignore list (refresh.ts): Prevents Python virtual environments from triggering unnecessary skill reloads.runDaemonStopsystemd guard computeshintsbut doesn't include them in the JSON emit (unlikestart/restart) — minor inconsistency flagged.Confidence Score: 4/5
runDaemonStopdoesn't pass hints to the JSON emit unlike the other two lifecycle functions. Score is 4 rather than 5 because the PR bundles three unrelated changes (per CLAUDE.md: "Group related changes; avoid bundling unrelated refactors") and the author notes they did not run the full test suite locally.src/cli/daemon-cli/lifecycle.tsfor therunDaemonStophints inconsistency withrunDaemonStartandrunDaemonRestart.Last reviewed commit: 07d661a