mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
Preserve paginated history for spawned subagents (#33432)
## What changed - Inherit paginated history mode when spawning or forking a subagent from a paginated parent. - Load the parent's model context when forking and persist it as an inherited rollout prefix, while excluding that prefix from the child's projected turns, items, and metadata. - Record the boundary between inherited context and child history, and reject partially initialized paginated subagent rollouts on resume. - Resume paginated subagents from their stored model context instead of legacy rollout history. ## Testing Added coverage for fresh and forked paginated subagents, compacted-history forks, model-context resume, inherited-prefix projection, metadata isolation, and incomplete-prefix detection. GitOrigin-RevId: e57dc37c29aa4aaaf57b052b991be591d730e5ba
This commit is contained in:
1 parent
cb79b3cdf9
commit
2be648ba4a
36 files changed
+954
-73
No files matched your search
@@ -2,6 +2,7 @@ use std::io::SeekFrom;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::DateTime;
|
||||
use codex_app_server_protocol::ThreadHistoryChangeSet;
|
||||
use codex_app_server_protocol::project_rollout_line;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::RolloutLine;
|
||||
@@ -23,6 +24,11 @@ pub(super) async fn materialize_to_sqlite(
|
||||
if lines.is_empty() && start_offset == next_offset {
|
||||
return Ok(());
|
||||
}
|
||||
let subagent_history_start_ordinal = codex_rollout::read_session_meta_line(rollout_path)
|
||||
.await
|
||||
.map_err(thread_store_io_error)?
|
||||
.meta
|
||||
.subagent_history_start_ordinal;
|
||||
|
||||
let projections = lines
|
||||
.iter()
|
||||
@@ -30,7 +36,14 @@ pub(super) async fn materialize_to_sqlite(
|
||||
let created_at_ms = DateTime::parse_from_rfc3339(line.timestamp.as_str())
|
||||
.map(|timestamp| timestamp.timestamp_millis())
|
||||
.map_err(thread_history_error)?;
|
||||
Ok((line.ordinal, created_at_ms, project_rollout_line(line)))
|
||||
let changes = if line.ordinal.is_some_and(|ordinal| {
|
||||
subagent_history_start_ordinal.is_some_and(|start| ordinal < start)
|
||||
}) {
|
||||
ThreadHistoryChangeSet::default()
|
||||
} else {
|
||||
project_rollout_line(line)
|
||||
};
|
||||
Ok((line.ordinal, created_at_ms, changes))
|
||||
})
|
||||
.collect::<ThreadStoreResult<Vec<_>>>()?;
|
||||
super::thread_history::apply_projection(
|
||||
|
||||
Reference in new issue
Block a user