mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
core: persist initial context window metadata
Record the initial AutoCompactWindowIds window_id in session_meta.context_window so JSONL tailers can observe the first context window before any compaction item exists. Thread creation now requires an initial_window_id string, while rollout JSONL keeps that value under the context_window namespace without writing derived chain fields for the initial window. Rollout reconstruction derives window 0 state from that initial_window_id when no compaction window metadata exists. Forks intentionally use the same reconstruction path; consumers that need to distinguish copied initial-window metadata can use thread_id. Legacy compactions without window_number continue to use compaction-count fallback accounting. Verification: - just test -p codex-protocol - just test -p codex-rollout recorder_materializes_on_flush_with_pending_items - just test -p codex-core reconstruct_history_restores_initial_window_from_session_meta - just test -p codex-core reconstruct_history_prefers_compacted_window_over_session_meta - just test -p codex-core reconstruct_history_preserves_legacy_compaction_count_with_session_meta_window - just test -p codex-core reconstruct_history - just test -p codex-core record_initial_history_reconstructs_forked_transcript - just test -p codex-thread-store - just test -p codex-state - just test -p codex-app-server thread_read_returns_summary_without_turns - just test -p codex-rollout persistence_metrics - just fix -p codex-protocol -p codex-rollout -p codex-thread-store -p codex-core -p codex-app-server - just fix -p codex-core -p codex-rollout - just fix -p codex-core
This commit is contained in:
@@ -202,6 +202,7 @@ fn create_fake_rollout_with_source_and_parent_thread_id(
|
||||
dynamic_tools: None,
|
||||
memory_mode: None,
|
||||
multi_agent_version: None,
|
||||
context_window: None,
|
||||
};
|
||||
let payload = serde_json::to_value(SessionMetaLine {
|
||||
meta,
|
||||
@@ -289,6 +290,7 @@ pub fn create_fake_rollout_with_text_elements(
|
||||
dynamic_tools: None,
|
||||
memory_mode: None,
|
||||
multi_agent_version: None,
|
||||
context_window: None,
|
||||
};
|
||||
let payload = serde_json::to_value(SessionMetaLine {
|
||||
meta,
|
||||
|
||||
@@ -131,6 +131,7 @@ async fn get_conversation_summary_by_thread_id_reads_pathless_store_thread() ->
|
||||
base_instructions: BaseInstructions::default(),
|
||||
dynamic_tools: Vec::new(),
|
||||
multi_agent_version: None,
|
||||
initial_window_id: Uuid::now_v7().to_string(),
|
||||
metadata: ThreadPersistenceMetadata {
|
||||
cwd: None,
|
||||
model_provider: "test-provider".to_string(),
|
||||
|
||||
@@ -157,6 +157,7 @@ async fn thread_delete_with_non_local_thread_store_does_not_create_local_persist
|
||||
base_instructions: BaseInstructions::default(),
|
||||
dynamic_tools: Vec::new(),
|
||||
multi_agent_version: None,
|
||||
initial_window_id: Uuid::now_v7().to_string(),
|
||||
metadata: ThreadPersistenceMetadata {
|
||||
cwd: Some(codex_home.path().to_path_buf()),
|
||||
model_provider: "mock_provider".to_string(),
|
||||
|
||||
@@ -1367,6 +1367,7 @@ async fn seed_pathless_store_thread(
|
||||
base_instructions: BaseInstructions::default(),
|
||||
dynamic_tools: Vec::new(),
|
||||
multi_agent_version: None,
|
||||
initial_window_id: Uuid::now_v7().to_string(),
|
||||
metadata: ThreadPersistenceMetadata {
|
||||
cwd: None,
|
||||
model_provider: "test-provider".to_string(),
|
||||
|
||||
@@ -2072,6 +2072,7 @@ stream_max_retries = 0
|
||||
dynamic_tools: None,
|
||||
memory_mode: None,
|
||||
multi_agent_version: None,
|
||||
context_window: None,
|
||||
};
|
||||
std::fs::write(
|
||||
&rollout_path,
|
||||
|
||||
@@ -218,6 +218,7 @@ async fn thread_unarchive_preserves_pathless_store_metadata() -> Result<()> {
|
||||
base_instructions: BaseInstructions::default(),
|
||||
dynamic_tools: Vec::new(),
|
||||
multi_agent_version: None,
|
||||
initial_window_id: Uuid::now_v7().to_string(),
|
||||
metadata: ThreadPersistenceMetadata {
|
||||
cwd: None,
|
||||
model_provider: "test-provider".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user