Files
codex/codex-rs/app-server/src/request_processors/thread_memory.rs
T
jif b559e6a398 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
2026-10-23 12:35:58 +00:00

31 lines
1.1 KiB
Rust

//! 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(&params.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()))
}
}