Skip to content

fix(session): warn when system prompt changes on session resume (#2212)#2228

Merged
esengine merged 1 commit into
esengine:mainfrom
nianyi778:feat/session-system-hash-warn
May 29, 2026
Merged

fix(session): warn when system prompt changes on session resume (#2212)#2228
esengine merged 1 commit into
esengine:mainfrom
nianyi778:feat/session-system-hash-warn

Conversation

@nianyi778

Copy link
Copy Markdown

问题

关闭 #2212。用户编辑 REASONIX.md 或全局记忆文件后,下次 resume 会话时系统提示已变更,第一轮会产生完整缓存 miss,但没有任何提示——用户完全不知道为什么突然慢了。

方案

在 resume 时对比系统提示指纹(SHA-256[:16]),如果不一致就显示警告:

▸ system prompt changed since last session
  REASONIX.md or a memory file changed — the first turn will be a full
  cache miss. Use /new to start fresh with the updated context.

实现细节:

  • session.ts:新增 hashSystemPrompt(),在 SessionMetasystemFingerprint 字段
  • App.tsx:每轮发送时刷新 fingerprint;resume 时比较,不同则 pushWarning
  • i18n:EN + zh-CN 各新增 2 个 key(systemPromptChanged + systemPromptChangedDetail
  • TranslationSchema 同步更新

不改变任何行为,仅加信息提示。用户仍可继续使用旧 session(只是有缓存 miss),或 /new 开新会话。

…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
@nianyi778

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/cli/ui/App.tsx
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cache-stability diagnostic — fingerprints the system prompt into session meta (hashSystemPromptsystemFingerprint) 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.

@esengine esengine merged commit 4811857 into esengine:main May 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants