feat: auto-reload persona on file change#77
Conversation
Persona files are cached but automatically reloaded when the agent edits them. Uses cheap stat() mtime check on each turn (~0.1ms). No restart needed after agent updates user.md or soul.md. 393 tests green.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e10f499577
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else { | ||
| // Cheap mtime check — auto-reload if agent edited the files | ||
| const currentMtime = getMaxMtime(); | ||
| if (currentMtime > lastMtime) { |
There was a problem hiding this comment.
Reload persona when mtime decreases or file is deleted
The invalidation check only reloads when currentMtime > lastMtime, so deletions or replacements that reduce the max mtime are missed. In this file, removing user.md/soul.md (or restoring an older copy) can change persona content, but injectPersonaSection will keep serving stale cachedPersona indefinitely because the new max mtime is lower and the reload path is skipped. This breaks the advertised “auto-reload on file change” behavior for a common edit flow (rm/rollback).
Useful? React with 👍 / 👎.
1. Escape </persona> in persona content (XML injection prevention) 2. mtime check uses !== instead of > (catches deletions/replacements) 3. mkdirSync before writeSettings (handles fresh installs) 4. /later@BotName suffix stripped in group chats All from Codex PR review comments on #75, #77, #66, #67. 393 tests green. Co-authored-by: Loki FastStart <loki@faststart.internal>
Persona files auto-reload when modified. Uses mtime stat check (~0.1ms per turn). No restart needed after agent edits user.md/soul.md. 393 tests green.