mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
Distinguish turn-start thread persistence (#37926)
## What changed - Add `PersistContext` to the thread-store persistence contract so stores can identify persistence requested immediately before model sampling. A `TurnStart` request may be enqueued in the background when later flush and shutdown operations fence it and report any failure; all other persistence remains synchronous. - Use the turn-start context only for the initial input of a regular turn, while admission acknowledgments, steered input, and other persistence paths keep the standard durability behavior. - Flush pending metadata before turn-start persistence and ensure shutdown is still attempted if that metadata update fails. ## Testing - Verify that developer instructions and user input are persisted before the model request completes for a default paginated-history thread. GitOrigin-RevId: 162f0ec796a61aebe66ca0b909fbcccec3047b85
This commit is contained in:
@@ -36,6 +36,7 @@ use codex_rollout::RolloutItem;
|
||||
use codex_rollout::is_persisted_rollout_item;
|
||||
use codex_thread_store::AppendThreadItemsParams;
|
||||
use codex_thread_store::CreateThreadParams;
|
||||
use codex_thread_store::PersistContext;
|
||||
use codex_thread_store::ThreadMetadataPatch;
|
||||
use codex_thread_store::ThreadPersistenceMetadata;
|
||||
use codex_thread_store::ThreadStore;
|
||||
@@ -576,7 +577,7 @@ impl ExternalAgentSessionImporter {
|
||||
)
|
||||
})?;
|
||||
self.thread_store
|
||||
.persist_thread(thread_id)
|
||||
.persist_thread(thread_id, PersistContext::Standard)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
SessionImportStepFailure::new(
|
||||
|
||||
@@ -16,6 +16,7 @@ use codex_protocol::mcp::ClientMcpExtensions;
|
||||
use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_DANGER_FULL_ACCESS;
|
||||
use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_WORKSPACE;
|
||||
use codex_protocol::protocol::ThreadHistoryMode;
|
||||
use codex_thread_store::PersistContext;
|
||||
|
||||
pub(super) const THREAD_LIST_DEFAULT_LIMIT: usize = 25;
|
||||
pub(super) const THREAD_LIST_MAX_LIMIT: usize = 100;
|
||||
@@ -2526,7 +2527,7 @@ impl ThreadRequestProcessor {
|
||||
codex_app_server_protocol::ThreadHistoryMode::Paginated
|
||||
) {
|
||||
self.thread_store
|
||||
.persist_thread(thread_id)
|
||||
.persist_thread(thread_id, PersistContext::Standard)
|
||||
.await
|
||||
.map_err(|err| thread_read_history_load_error(thread_id, err))?;
|
||||
thread.turns = self
|
||||
@@ -3322,7 +3323,7 @@ impl ThreadRequestProcessor {
|
||||
if paginated_resume
|
||||
&& let Err(error) = self
|
||||
.thread_store
|
||||
.persist_thread(thread_id)
|
||||
.persist_thread(thread_id, PersistContext::Standard)
|
||||
.await
|
||||
.map_err(thread_store_resume_read_error)
|
||||
{
|
||||
@@ -3671,7 +3672,7 @@ impl ThreadRequestProcessor {
|
||||
}
|
||||
if paginated_resume && (include_turns || params.initial_turns_page.is_some()) {
|
||||
self.thread_store
|
||||
.persist_thread(existing_thread_id)
|
||||
.persist_thread(existing_thread_id, PersistContext::Standard)
|
||||
.await
|
||||
.map_err(thread_store_resume_read_error)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user