Skip to content

Commit ba54960

Browse files
Add memory overlay status diagnostics
Return explicit memory_stage_update feedback with staged content, reason, overlay revision, and ad-hoc note path. Expose memory/overlay/status and /memory-overlay so loaded session overlays and global ad-hoc staged notes can be checked against durable memory exact matches. Verification: just fmt; just write-app-server-schema; cargo test -p codex-app-server-protocol; cargo test -p codex-app-server ad_hoc_memory_notes_report_exact_durable_matches; cargo test -p codex-core memory_overlay_update_keeps_prompt_cache_key_and_injects_once; cargo test -p codex-tui slash_memory_overlay_requests_global_status; just fix -p codex-app-server-protocol -p codex-app-server -p codex-core -p codex-tui. Co-authored-by: Open Codex <hff582580@gmail.com>
1 parent fd069c8 commit ba54960

25 files changed

Lines changed: 648 additions & 11 deletions

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ The earlier fork-only memory subsystem has been removed so the fork stays aligne
9090

9191
- **Session Memory Overlay** — Staged entries are injected as a bounded developer-context overlay for the current session, so newly saved information can affect the next turn without waiting for a new session or background consolidation. The overlay is emitted only when its revision changes.
9292

93+
- **Explicit staging feedback**`memory_stage_update` now returns the staged content, optional reason, overlay revision, and ad-hoc note path, so the model can tell the user exactly what was staged and where the durable consolidation input was written.
94+
95+
- **Global overlay diagnostics**`/memory-overlay` shows all loaded session overlay entries plus global ad-hoc staged notes, and reports exact matches already present in durable memory files. It is a diagnostic view, not a semantic-proof system: unmatched entries may still be pending consolidation or may have been paraphrased by the consolidation agent.
96+
9397
- **Removed conflicting fork behavior** — The old direct durable write tools, notepad file, topic frontmatter priority system, merge-write path, and custom AGENTS.md hierarchy are no longer part of the memory implementation.
9498

9599
This addresses the active-update gap while keeping durable memory storage and consolidation compatible with upstream.
@@ -381,6 +385,10 @@ Codex CLI 是开源的,但上游仓库当前对外部代码贡献采用 invita
381385

382386
- **Session Memory Overlay** — staged entries 会作为有预算上限的 developer-context overlay 注入当前 session,让新保存的信息不用等新 session 或后台 consolidation 就能影响下一轮。overlay 只在 revision 变化时发出。
383387

388+
- **明确的 staging 反馈**`memory_stage_update` 现在会返回 staged content、可选 reason、overlay revision 和 ad-hoc note path,因此模型可以明确告诉用户本次写入了什么、为什么写入、以及 durable consolidation input 写到了哪里。
389+
390+
- **全局 overlay 诊断**`/memory-overlay` 会展示所有 loaded session overlay entries 和全局 ad-hoc staged notes,并标出哪些内容已经在 durable memory 文件中出现 exact match。这是诊断视图,不是语义证明系统:未匹配的条目可能仍在等待 consolidation,也可能已经被 consolidation agent 改写表达。
391+
384392
- **已移除冲突 fork 行为** — 旧的直接 durable write tools、notepad 文件、topic frontmatter priority、merge-write 路径、自定义 AGENTS.md hierarchy 都不再属于当前 memory 实现。
385393

386394
这补上了主动更新缺口,同时保持 durable memory 存储和 consolidation 与 upstream 兼容。

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/typescript/v2/AdHocMemoryNoteStatus.ts

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/typescript/v2/MemoryOverlayEntryStatus.ts

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/typescript/v2/ThreadMemoryOverlayStatus.ts

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/typescript/v2/index.ts

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/src/protocol/common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@ client_request_definitions! {
535535
serialization: global("memory"),
536536
response: v2::MemoryResetResponse,
537537
},
538+
#[experimental("memory/overlay/status")]
539+
MemoryOverlayStatus => "memory/overlay/status" {
540+
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
541+
serialization: global("memory"),
542+
response: v2::MemoryOverlayStatusResponse,
543+
},
538544
ThreadUnarchive => "thread/unarchive" {
539545
params: v2::ThreadUnarchiveParams,
540546
serialization: thread_id(params.thread_id),

codex-rs/app-server-protocol/src/protocol/v2/thread.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,43 @@ pub struct ThreadMemoryModeSetResponse {}
745745
#[ts(export_to = "v2/")]
746746
pub struct MemoryResetResponse {}
747747

748+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
749+
#[serde(rename_all = "camelCase")]
750+
#[ts(export_to = "v2/")]
751+
pub struct MemoryOverlayStatusResponse {
752+
pub threads: Vec<ThreadMemoryOverlayStatus>,
753+
pub ad_hoc_notes: Vec<AdHocMemoryNoteStatus>,
754+
}
755+
756+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
757+
#[serde(rename_all = "camelCase")]
758+
#[ts(export_to = "v2/")]
759+
pub struct ThreadMemoryOverlayStatus {
760+
pub thread_id: String,
761+
pub session_id: String,
762+
pub entries: Vec<MemoryOverlayEntryStatus>,
763+
}
764+
765+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
766+
#[serde(rename_all = "camelCase")]
767+
#[ts(export_to = "v2/")]
768+
pub struct MemoryOverlayEntryStatus {
769+
pub content: String,
770+
pub reason: Option<String>,
771+
pub created_at_unix_ms: i64,
772+
pub durable_matches: Vec<String>,
773+
}
774+
775+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
776+
#[serde(rename_all = "camelCase")]
777+
#[ts(export_to = "v2/")]
778+
pub struct AdHocMemoryNoteStatus {
779+
pub path: String,
780+
pub content: String,
781+
pub reason: Option<String>,
782+
pub durable_matches: Vec<String>,
783+
}
784+
748785
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
749786
#[serde(rename_all = "camelCase")]
750787
#[ts(export_to = "v2/")]

codex-rs/app-server/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Example with notification opt-out:
133133
- `thread/metadata/update` — patch stored thread metadata in sqlite; currently supports updating persisted `gitInfo` fields and returns the refreshed `thread`.
134134
- `thread/memoryMode/set` — experimental; set a thread’s persisted memory eligibility to `"enabled"` or `"disabled"` for either a loaded thread or a stored rollout; returns `{}` on success.
135135
- `memory/reset` — experimental; clear the current `CODEX_HOME/memories` directory and reset persisted memory stage data in sqlite while preserving existing thread memory modes; returns `{}` on success.
136+
- `memory/overlay/status` — experimental; list active session overlay entries for loaded threads, global ad-hoc staged memory notes, and exact durable-memory file matches for staged content.
136137
- `thread/goal/set` — create or update the single persisted goal for a materialized thread; returns the current goal and emits `thread/goal/updated`.
137138
- `thread/goal/get` — fetch the current persisted goal for a materialized thread; returns `goal: null` when no goal exists.
138139
- `thread/goal/clear` — clear the current persisted goal for a materialized thread; returns whether a goal was removed and emits `thread/goal/cleared` when state changes.
@@ -479,6 +480,30 @@ Experimental: use `memory/reset` to clear local memory artifacts and sqlite-back
479480
{ "id": 27, "result": {} }
480481
```
481482

483+
Experimental: use `memory/overlay/status` to inspect staged memory visibility. The response includes loaded session overlay entries and ad-hoc staged notes under `CODEX_HOME/memories/extensions/ad_hoc/notes`, with `durableMatches` listing exact matches found in durable memory files. Exact matches are diagnostic evidence only; absence of a match does not prove the consolidation agent has not paraphrased the entry.
484+
485+
```json
486+
{ "method": "memory/overlay/status", "id": 28 }
487+
{ "id": 28, "result": {
488+
"threads": [{
489+
"threadId": "thr_123",
490+
"sessionId": "sess_123",
491+
"entries": [{
492+
"content": "Prefer release-fast for local Open Codex publish builds.",
493+
"reason": "release workflow",
494+
"createdAtUnixMs": 1770000000000,
495+
"durableMatches": ["MEMORY.md"]
496+
}]
497+
}],
498+
"adHocNotes": [{
499+
"path": "extensions/ad_hoc/notes/2026-05-14T10-00-00-session-memory-update.md",
500+
"content": "Prefer release-fast for local Open Codex publish builds.",
501+
"reason": "release workflow",
502+
"durableMatches": ["MEMORY.md"]
503+
}]
504+
} }
505+
```
506+
482507
### Example: Set and update a thread goal
483508

484509
Use `thread/goal/set` to create or update the current goal for a materialized thread. Clients can set `budgetLimited` when they stop because a token budget is exhausted or nearly exhausted; the system also sets it when accounting crosses a configured token budget.

0 commit comments

Comments
 (0)