mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
## Why Codex needs rejected audio file IDs when reconstructing a session so later model requests can omit those attachments. Clients only need the turn error. ## What changed Store rejected audio file IDs as rollout metadata and restore them from that metadata when replaying history. Keep the existing JSONL layout under `error.rejected_audio_file_ids` so older versions can still read newly written rollouts. ## Testing Add a regression test that round-trips a legacy rollout entry and verifies that serializing the protocol event omits the rejected IDs. GitOrigin-RevId: 982dd85d0037cebee056caf61d70988762e42767
82 lines
3.7 KiB
Rust
82 lines
3.7 KiB
Rust
//! Defines resume metadata stored directly on a compaction.
|
|
|
|
use crate::RolloutItem;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::dynamic_tools::DynamicToolSpec;
|
|
use codex_protocol::protocol::MultiAgentVersion;
|
|
use codex_protocol::turn_input::CyberAccessProgram;
|
|
use codex_protocol::turn_input::TurnAttribution;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use std::collections::BTreeSet;
|
|
use std::sync::Arc;
|
|
|
|
/// Resume metadata that is not represented by the companion records after a compaction.
|
|
///
|
|
/// Presence distinguishes compactions that explicitly persisted these values from older
|
|
/// compactions that did not.
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
|
pub struct CompactionResumeMetadata {
|
|
/// Next ordinal in the producing thread's seeded item ID sequence at this checkpoint.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub next_item_ordinal: Option<u64>,
|
|
/// Immutable file references rejected before this checkpoint.
|
|
#[serde(default, skip_serializing_if = "BTreeSet::is_empty")]
|
|
pub rejected_audio_file_ids: Arc<BTreeSet<String>>,
|
|
/// Catalog owned by the producing thread; absent in older checkpoints.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub dynamic_tools: Option<Box<DynamicToolsSnapshot>>,
|
|
/// Thread clock floor retained when older history is omitted from resume context.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub observation_clock_floor_ms: Option<i64>,
|
|
/// Selected runtime, including when the companion turn context is absent.
|
|
pub multi_agent_version: Option<MultiAgentVersion>,
|
|
/// Turn identity used to admit continuations after cold resume.
|
|
pub last_started_turn_id: Option<String>,
|
|
/// Attribution of the latest regular turn, independent of continuation eligibility.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub turn_attribution: Option<TurnAttribution>,
|
|
pub previous_turn_settings: Option<PreviousTurnSettings>,
|
|
}
|
|
|
|
/// A thread's dynamic-tool catalog, including an empty catalog after a clear.
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
|
pub struct DynamicToolsSnapshot {
|
|
pub thread_id: ThreadId,
|
|
pub tools: Vec<DynamicToolSpec>,
|
|
}
|
|
|
|
/// Previous user-turn settings used to reconstruct context changes after resume.
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
|
pub struct PreviousTurnSettings {
|
|
pub model: String,
|
|
/// Historical program for this model; absence must not inherit the next turn's selection.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub cyber_access_program: Option<CyberAccessProgram>,
|
|
pub comp_hash: Option<String>,
|
|
pub realtime_active: Option<bool>,
|
|
}
|
|
|
|
/// Returns the runtime version stored in a turn context or compaction resume metadata.
|
|
pub fn resume_multi_agent_version(item: &RolloutItem) -> Option<MultiAgentVersion> {
|
|
match item {
|
|
RolloutItem::TurnContext(context) => context.multi_agent_version,
|
|
RolloutItem::Compacted(compacted) => compacted
|
|
.resume_metadata
|
|
.as_ref()
|
|
.and_then(|metadata| metadata.multi_agent_version),
|
|
RolloutItem::DynamicToolsUpdated { .. }
|
|
| RolloutItem::SessionMeta(_)
|
|
| RolloutItem::ResponseItem(_)
|
|
| RolloutItem::InterAgentCommunication(_)
|
|
| RolloutItem::InterAgentCommunicationMetadata { .. }
|
|
| RolloutItem::TokenUsageRecord(_)
|
|
| RolloutItem::WorldState(_)
|
|
| RolloutItem::RetainedContext(_)
|
|
| RolloutItem::SecurityRiskScore(_)
|
|
| RolloutItem::RealtimeItem(_)
|
|
| RolloutItem::EventMsg { .. } => None,
|
|
}
|
|
}
|