fix(session): warn when system prompt changes on session resume (#2212)#2228
Conversation
…gine#2212) When REASONIX.md or a global memory file is edited between sessions, the system prompt is rebuilt on next launch and the resumed session gets a full cache miss with no explanation. This adds a one-time warning on resume when the system prompt fingerprint differs from what was saved. - session.ts: add hashSystemPrompt(); add systemFingerprint to SessionMeta - App.tsx: save fingerprint on every turn; compare on resume and warn - i18n/types.ts + EN + zh-CN: systemPromptChanged + systemPromptChangedDetail
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a552be4996
ℹ️ 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".
| if (!existing.workspace) patch.workspace = currentRootDir; | ||
| // Always refresh the system-prompt fingerprint so the next resume can | ||
| // detect REASONIX.md / memory changes that happened since this turn. | ||
| patch.systemFingerprint = hashSystemPrompt(system); |
There was a problem hiding this comment.
Hash the live rebuilt system prompt
When a user edits REASONIX.md or memory during an active process and follows the warning's /new advice, loop.clearLog() rebuilds loop.prefix.system from rebuildSystem(), but this metadata write still hashes the original system prop captured at startup. The next resume then compares the saved stale fingerprint to the current rebuilt prompt and warns again even though the prompt has not changed since the last turn; the same stale write can happen after other in-process prompt rebuilds. Persist loop.prefix.system (or another live prompt source) here so the fingerprint represents the system prompt actually used for the turn.
Useful? React with 👍 / 👎.
esengine
left a comment
There was a problem hiding this comment.
Nice cache-stability diagnostic — fingerprints the system prompt into session meta (hashSystemPrompt → systemFingerprint) and warns on resume if it changed (REASONIX.md / global-memory edits → a first-turn cache miss). On-mission for a cache-first agent, well-scoped, i18n in EN/zh-CN. CI green. Merging.
问题
关闭 #2212。用户编辑 REASONIX.md 或全局记忆文件后,下次 resume 会话时系统提示已变更,第一轮会产生完整缓存 miss,但没有任何提示——用户完全不知道为什么突然慢了。
方案
在 resume 时对比系统提示指纹(SHA-256[:16]),如果不一致就显示警告:
实现细节:
session.ts:新增hashSystemPrompt(),在SessionMeta加systemFingerprint字段App.tsx:每轮发送时刷新 fingerprint;resume 时比较,不同则pushWarningsystemPromptChanged+systemPromptChangedDetail)TranslationSchema同步更新不改变任何行为,仅加信息提示。用户仍可继续使用旧 session(只是有缓存 miss),或
/new开新会话。