Bound rollout trace capture with configurable storage limits (#61896)

## What changed

- Add `rollout_trace.max_payload_bytes` and `rollout_trace.max_bytes`, defaulting to 64 MiB per body or separated value and 256 MiB per bundle. Root and child threads share the bundle budget.
- Record explicit truncations and omissions when limits are reached, reserve space for later events, and stop at the last complete event if the event log fills.
- Reuse identical prepared-prompt items and store inline images separately from message structure. Preserve exact JSON bytes for complete composite payloads and surviving content and links in partial captures.
- Let reducers handle partial payloads while retaining lifecycle information and reporting `closed_with_partial_payloads` for closed bundles with incomplete captures.

## Testing

Add coverage for payload reuse and byte-exact reconstruction, truncation, compressed bundle budgets, later events after omissions, readable prefixes after event-space exhaustion, and CLI capture-limit configuration and startup failures.

GitOrigin-RevId: be99a68da427414a7a12bf8209f232c1a0bbe545
This commit is contained in:
cassirer-openai
2026-11-16 22:26:31 +00:00
committed by copyberry
parent c0d47262f3
commit ef6ce8100a
23 changed files with 712 additions and 107 deletions
+13
View File
@@ -161,6 +161,16 @@ pub struct FeatureToggleToml {
pub enabled: Option<bool>,
}
/// Storage budgets for one native rollout trace, shared by the root and its children.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default, PartialEq, Eq, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct RolloutTraceToml {
/// Maximum uncompressed bytes retained per new body or separated value. Defaults to 64 MiB.
pub max_payload_bytes: Option<usize>,
/// Maximum bytes for the manifest, event log, and compressed payload shards. Defaults to 256 MiB.
pub max_bytes: Option<u64>,
}
/// Base config deserialized from ~/.codex/config.toml.
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, JsonSchema)]
#[schemars(deny_unknown_fields)]
@@ -371,6 +381,9 @@ pub struct ConfigToml {
#[serde(default = "default_history")]
pub history: Option<History>,
/// Capture limits for local rollout traces when recording is enabled.
pub rollout_trace: Option<RolloutTraceToml>,
/// Directory where Codex stores the SQLite state DB.
/// Defaults to `$CODEX_SQLITE_HOME` when set. Otherwise uses `$CODEX_HOME`.
pub sqlite_home: Option<AbsolutePathBuf>,