mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Enable paginated thread history in app-server (#33364)
## What changed - Allow `thread/start` to select experimental `historyMode: "paginated"` when the thread store supports turn and item pagination. - Resume paginated threads with bounded model context and require `excludeTurns: true` instead of loading full history. - Return `turnsBackwardsCursor` and `itemsBackwardsCursor` from `thread/resume` so clients can hydrate durable history through `thread/turns/list` and `thread/items/list` while newer records arrive through live notifications. - Reject operations that still require full history, including `initialTurnsPage`, `thread/read` with `includeTurns: true`, `thread/rollback`, and detached review. - Make item cursors independent of the optional `turnId` filter. ## Testing - Cover paginated thread start, cold and live resume, backwards cursor hydration, metadata reads, unsupported operations, and stores without pagination support. GitOrigin-RevId: c42f9b268e29d049843330f474fa3ecde12f5b8a
This commit is contained in:
1 parent
1bbdb32789
commit
da61f7d8e1
26 files changed
+758
-138
No files matched your search
@@ -39,7 +39,6 @@ use crate::ThreadStoreFuture;
|
||||
use crate::ThreadStoreResult;
|
||||
use crate::UpdateThreadMetadataParams;
|
||||
use crate::error::reject_paginated_history_mode;
|
||||
use crate::types::canonical_history_mode_from_rollout_items;
|
||||
|
||||
static IN_MEMORY_THREAD_STORES: OnceLock<Mutex<HashMap<String, Arc<InMemoryThreadStore>>>> =
|
||||
OnceLock::new();
|
||||
@@ -200,7 +199,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn paginated_threads_allow_metadata_reads_and_reject_legacy_history_paths() {
|
||||
async fn paginated_threads_allow_metadata_reads_and_resume_but_reject_legacy_history_paths() {
|
||||
let store = InMemoryThreadStore::default();
|
||||
let thread_id = ThreadId::default();
|
||||
let rollout_path = PathBuf::from("/tmp/paginated-thread.jsonl");
|
||||
@@ -287,18 +286,16 @@ mod tests {
|
||||
.await
|
||||
.expect_err("history load should fail"),
|
||||
);
|
||||
assert_paginated_threads_unsupported(
|
||||
store
|
||||
.resume_thread(ResumeThreadParams {
|
||||
thread_id,
|
||||
rollout_path: None,
|
||||
history: None,
|
||||
include_archived: false,
|
||||
metadata: thread_metadata(),
|
||||
})
|
||||
.await
|
||||
.expect_err("resume should fail"),
|
||||
);
|
||||
store
|
||||
.resume_thread(ResumeThreadParams {
|
||||
thread_id,
|
||||
rollout_path: None,
|
||||
history: None,
|
||||
include_archived: false,
|
||||
metadata: thread_metadata(),
|
||||
})
|
||||
.await
|
||||
.expect("resume should succeed");
|
||||
assert_paginated_threads_unsupported(
|
||||
store
|
||||
.create_thread(create_thread_params(
|
||||
@@ -463,13 +460,6 @@ impl InMemoryThreadStore {
|
||||
async fn resume_thread(&self, params: ResumeThreadParams) -> ThreadStoreResult<()> {
|
||||
let mut state = self.state.lock().await;
|
||||
state.calls.resume_thread += 1;
|
||||
let history_mode = params
|
||||
.history
|
||||
.as_deref()
|
||||
.map(Vec::as_slice)
|
||||
.map(canonical_history_mode_from_rollout_items)
|
||||
.unwrap_or_else(|| history_mode_from_state(&state, params.thread_id));
|
||||
reject_paginated_history_mode(history_mode)?;
|
||||
if let Some(history) = params.history {
|
||||
state
|
||||
.histories
|
||||
|
||||
Reference in new issue
Block a user