Track window and fork positions in turn metadata (#40987)

## What changed

- Add the zero-based `window_number` to Responses turn metadata and include it in prewarm requests.
- Persist `forked_from_ordinal_exclusive` separately from the physical history base so fork lineage remains accurate after reverts and cold resumes.
- Report context-inheriting subagents through `parent_thread_id` without also emitting fork lineage.
- Reserve the new metadata keys while accepting and filtering previously valid configured values so Codex-owned values take precedence.

## Testing

- Cover window numbering across compaction, resume, and fork operations.
- Cover fork cutoff persistence across direct forks, legacy rollouts, reverts into inherited history, and cold resumes.

GitOrigin-RevId: 288f6cd632254814c1f166668b33828082d799a1
This commit is contained in:
Brandon Zhang authored and copyberry committed 2026-08-26 22:37:59 +00:00
1 parent 102ae5e2e6
commit 0d654e6536
33 files changed
+562 -44

No files matched your search

+6 -2
View File
@@ -3888,12 +3888,16 @@ impl Session {
self.current_window().await.0
}
pub(crate) async fn current_window(&self) -> (String, Uuid) {
pub(crate) async fn current_window(&self) -> (String, u64, Uuid) {
let state = self.state.lock().await;
let thread_id = self.thread_id;
let window_number = state.auto_compact_window_number();
let context_window_id = state.auto_compact_window_ids().window_id;
(format!("{thread_id}:{window_number}"), context_window_id)
(
format!("{thread_id}:{window_number}"),
window_number,
context_window_id,
)
}
pub(crate) async fn advance_auto_compact_window(&self) -> (u64, AutoCompactWindowIds) {