mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Add experimental thread memory summary reads (#56465)
## What changed
Add `thread/memory/read` to return `{summary}` for a thread that has been started or resumed. Read `memory_summary.md` from the thread's resolved memory version, honoring thread-specific configuration overrides without falling back to another version.
Return `null` when memory use is disabled or the selected summary is missing, unreadable, or blank.
## Testing
Extend app-server integration coverage to check explicit and automatic memory version selection, disabled memory use, and missing summaries without fallback.
GitOrigin-RevId: b218f31e379c69ccbacb444bb9d6ee920cd4882b
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
//! Reads memory context from the loaded thread's resolved version, without fallback.
|
||||
|
||||
use super::*;
|
||||
use codex_app_server_protocol::ThreadMemoryReadParams;
|
||||
use codex_app_server_protocol::ThreadMemoryReadResponse;
|
||||
|
||||
impl ThreadRequestProcessor {
|
||||
pub(crate) async fn thread_memory_read(
|
||||
&self,
|
||||
params: ThreadMemoryReadParams,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
let (_, thread) = self.load_thread(¶ms.thread_id).await?;
|
||||
let config = thread.config().await;
|
||||
let summary =
|
||||
if config.features.enabled(Feature::MemoryTool) && config.memories.use_memories {
|
||||
tokio::fs::read_to_string(
|
||||
config
|
||||
.codex_home
|
||||
.join(config.memories.version.directory_name())
|
||||
.join("memory_summary.md"),
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
.filter(|summary| !summary.trim().is_empty())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Ok(Some(ThreadMemoryReadResponse { summary }.into()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user