mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
## Why Model output alone does not establish that an item entered conversation history. Treating every response item as accepted can include discarded attempts, while relying on a later request misses accepted final output when a turn ends or is interrupted. ## What changed - Record `HistoryItemAccepted` events and retain Responses item IDs, generating missing IDs consistently across item events. - Build thread conversation history from request inputs, compaction checkpoints, and explicit acceptance. Keep unaccepted output accessible through its inference call. - Preserve inference provenance across retries and late response records without overwriting newer request or compaction snapshots. - Mark turns with errors as failed. Bump trace schemas to version 2 and reject incompatible bundles and event schemas during replay. ## Testing Add reducer coverage for discarded attempts with identical text, late responses, compaction, inherited context, and legacy bundle rejection. Add CLI integration tests that run `debug trace-reduce` after success, stream failure, and interruption followed by shutdown, including responses without provider item IDs. GitOrigin-RevId: 8e387a91d9b3f704df82847d630e6f0b08f998b3
50 lines
1.7 KiB
Rust
50 lines
1.7 KiB
Rust
//! Trace bundle manifest and local layout constants.
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use crate::model::AgentThreadId;
|
|
|
|
pub(crate) const MANIFEST_FILE_NAME: &str = "manifest.json";
|
|
pub(crate) const RAW_EVENT_LOG_FILE_NAME: &str = "trace.jsonl";
|
|
pub(crate) const PAYLOADS_DIR_NAME: &str = "payloads";
|
|
/// Conventional file name for a reducer-written `RolloutTrace` cache.
|
|
pub const REDUCED_STATE_FILE_NAME: &str = "state.json";
|
|
pub(crate) const TRACE_MANIFEST_SCHEMA_VERSION: u32 = 2;
|
|
pub(crate) const REDUCED_TRACE_SCHEMA_VERSION: u32 = 2;
|
|
|
|
/// Manifest stored at the root of a trace bundle.
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub(crate) struct TraceBundleManifest {
|
|
pub(crate) schema_version: u32,
|
|
pub(crate) trace_id: String,
|
|
pub(crate) rollout_id: String,
|
|
/// Root thread for the recorded rollout. Replay should fail rather than
|
|
/// inventing a placeholder, because every reduced object is scoped back to
|
|
/// this thread tree.
|
|
pub(crate) root_thread_id: AgentThreadId,
|
|
pub(crate) started_at_unix_ms: i64,
|
|
pub(crate) raw_event_log: String,
|
|
pub(crate) payloads_dir: String,
|
|
}
|
|
|
|
impl TraceBundleManifest {
|
|
/// Builds a manifest that uses the standard local bundle layout.
|
|
pub(crate) fn new(
|
|
trace_id: String,
|
|
rollout_id: String,
|
|
root_thread_id: AgentThreadId,
|
|
started_at_unix_ms: i64,
|
|
) -> Self {
|
|
Self {
|
|
schema_version: TRACE_MANIFEST_SCHEMA_VERSION,
|
|
trace_id,
|
|
rollout_id,
|
|
root_thread_id,
|
|
started_at_unix_ms,
|
|
raw_event_log: RAW_EVENT_LOG_FILE_NAME.to_string(),
|
|
payloads_dir: PAYLOADS_DIR_NAME.to_string(),
|
|
}
|
|
}
|
|
}
|