mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:28:11 +00:00
Allow metadata updates without materializing threads (#38413)
## Why Thread stores may filter a metadata patch to a no-op. Requiring every successful update to return a `StoredThread` forces those implementations to materialize a thread even when the caller does not need one. ## What changed - Let `ThreadStore::update_thread_metadata` return `None` after a successful update that did not materialize a thread. - Preserve the materialized-thread contract of `LiveThread` and `ThreadManager` metadata updates by reading the thread when the store returns `None`. - Keep completion-only metadata updates from issuing that fallback read. ## Testing Cover materialized in-memory updates and verify that fallback reads occur only for callers that require the updated thread. GitOrigin-RevId: 3059efc9d5b69e0b46e35fb5b5aa9638086654f2
This commit is contained in:
1 parent
d167a3604c
commit
42bb50d502
7 files changed
+256
-32
No files matched your search
@@ -336,19 +336,31 @@ impl LiveThread {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Updates metadata while preserving this API's materialized-thread contract.
|
||||
///
|
||||
/// Stores may successfully return no thread for a no-op update, so this reads the thread as a
|
||||
/// fallback in that case.
|
||||
pub async fn update_metadata(
|
||||
&self,
|
||||
patch: ThreadMetadataPatch,
|
||||
include_archived: bool,
|
||||
) -> ThreadStoreResult<StoredThread> {
|
||||
self.flush_pending_metadata_update().await?;
|
||||
self.thread_store
|
||||
let updated = self
|
||||
.thread_store
|
||||
.update_thread_metadata(UpdateThreadMetadataParams {
|
||||
thread_id: self.thread_id,
|
||||
patch,
|
||||
include_archived,
|
||||
})
|
||||
.await
|
||||
.await?;
|
||||
match updated {
|
||||
Some(thread) => Ok(thread),
|
||||
None => {
|
||||
self.read_thread(include_archived, /*include_history*/ false)
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the live local rollout path for legacy local-only callers.
|
||||
|
||||
Reference in new issue
Block a user