#17624: Fix memory flush YYYY-MM-DD placeholder resolution
cli
agents
stale
size: S
Cluster:
Memory Management Enhancements
Fixes #17603.
Memory flush prompts include a literal `YYYY-MM-DD` placeholder (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 `formatUserDateYmd` and a unit test.
Notes:
- I did not run the full test suite locally (node_modules not installed in this environment); changes are small and covered by a new unit test file.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR bundles three independent fixes:
1. **Memory flush YYYY-MM-DD placeholder resolution** (`agent-runner-memory.ts`, `date-time.ts`, `date-time.test.ts`): Resolves the literal `YYYY-MM-DD` placeholder in memory flush prompts before invoking the embedded agent, using the user's configured timezone. Adds a well-tested `formatUserDateYmd` helper that uses `Intl.DateTimeFormat` with `en-CA` locale for reliable YYYY-MM-DD output. This is the core fix for #17603.
2. **Systemd user bus early guard** (`lifecycle.ts`): Adds early `isSystemdUserServiceAvailable()` checks in `runDaemonStart`, `runDaemonStop`, and `runDaemonRestart` to prevent `service.isLoaded()` from throwing on Linux systems without a systemd user bus. Returns gracefully with hints instead.
3. **`.venv` in skills watcher ignore list** (`refresh.ts`): Prevents Python virtual environments from triggering unnecessary skill reloads.
- The memory flush fix is clean and follows existing codebase patterns for timezone resolution.
- The `runDaemonStop` systemd guard computes `hints` but doesn't include them in the JSON emit (unlike `start`/`restart`) — minor inconsistency flagged.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk; the core date placeholder fix is correct and well-tested.
- The memory flush YYYY-MM-DD fix is clean, well-tested, and follows existing codebase patterns. The systemd early guard and .venv ignore are low-risk additions. One minor inconsistency: `runDaemonStop` doesn'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.
- Pay close attention to `src/cli/daemon-cli/lifecycle.ts` for the `runDaemonStop` hints inconsistency with `runDaemonStart` and `runDaemonRestart`.
<sub>Last reviewed commit: 07d661a</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
77.2%
#15945: fix(memory-flush): only write memoryFlushCompactionCount when compa...
by aldoeliacim · 2026-02-14
75.3%
#12760: fix(memory-flush): fire on every compaction cycle instead of skippi...
by lailoo · 2026-02-09
75.1%
#10644: feat: add runDuringHeartbeats option for memory flush (AI Assisted)
by tripphillips · 2026-02-06
74.9%
#2884: fix: Create memory directory and symlink identity files during work...
by webdevtodayjason · 2026-01-27
74.8%
#22131: fix: clear seqByRun entries in clearAgentRunContext to prevent memo...
by alanwilhelm · 2026-02-20
74.4%
#4878: fix: string/type handling and API fixes (#4537, #4380, #4373, #4547...
by lailoo · 2026-01-30
74.2%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
74.2%
#22480: fix: memory leak, silent WS failures, and connection error handling
by Chase-Xuu · 2026-02-21
74.2%
#8900: fix: improve default memory flush prompts with urgency and specifics
by joetomasone · 2026-02-04
74.1%