mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
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:
committed by
copyberry
parent
c0d47262f3
commit
ef6ce8100a
@@ -4860,6 +4860,25 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"RolloutTraceToml": {
|
||||
"additionalProperties": false,
|
||||
"description": "Storage budgets for one native rollout trace, shared by the root and its children.",
|
||||
"properties": {
|
||||
"max_bytes": {
|
||||
"description": "Maximum bytes for the manifest, event log, and compressed payload shards. Defaults to 256 MiB.",
|
||||
"format": "uint64",
|
||||
"minimum": 0.0,
|
||||
"type": "integer"
|
||||
},
|
||||
"max_payload_bytes": {
|
||||
"description": "Maximum uncompressed bytes retained per new body or separated value. Defaults to 64 MiB.",
|
||||
"format": "uint",
|
||||
"minimum": 0.0,
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"RuntimeAgentInstancesConfigToml": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
@@ -9131,6 +9150,14 @@
|
||||
"description": "Review model override used by the `/review` feature.",
|
||||
"type": "string"
|
||||
},
|
||||
"rollout_trace": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/RolloutTraceToml"
|
||||
}
|
||||
],
|
||||
"description": "Capture limits for local rollout traces when recording is enabled."
|
||||
},
|
||||
"sandbox_mode": {
|
||||
"allOf": [
|
||||
{
|
||||
|
||||
@@ -73,6 +73,7 @@ use codex_protocol_test_support::uuid_v7_item_id_generator_for_test;
|
||||
use codex_rollout_trace::ExecutionStatus;
|
||||
use codex_rollout_trace::InferenceTraceAttempt;
|
||||
use codex_rollout_trace::InferenceTraceContext;
|
||||
use codex_rollout_trace::RawPayloadKind;
|
||||
use codex_rollout_trace::RawTraceEventPayload;
|
||||
use codex_rollout_trace::RolloutTrace;
|
||||
use codex_rollout_trace::TraceWriter;
|
||||
@@ -1510,6 +1511,15 @@ async fn replay_until_cancelled(temp: &TempDir) -> anyhow::Result<RolloutTrace>
|
||||
.next()
|
||||
.expect("inference should be reduced");
|
||||
if inference.execution.status == ExecutionStatus::Cancelled {
|
||||
// Cancellation publishes one partial response. Prepared prompts can index shared child records.
|
||||
assert_eq!(
|
||||
rollout
|
||||
.raw_payloads
|
||||
.values()
|
||||
.filter(|p| p.kind == RawPayloadKind::InferenceResponse)
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
return Ok(rollout);
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
@@ -1811,7 +1821,6 @@ async fn dropped_response_stream_traces_cancelled_partial_output() -> anyhow::Re
|
||||
rollout.threads["thread-root"].conversation_item_ids,
|
||||
inference.request_item_ids
|
||||
);
|
||||
assert_eq!(rollout.raw_payloads.len(), 3);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -2084,7 +2093,6 @@ async fn dropped_backpressured_response_stream_traces_cancelled_partial_output()
|
||||
|
||||
assert_eq!(inference.execution.status, ExecutionStatus::Cancelled);
|
||||
assert_eq!(inference.response_item_ids.len(), 1);
|
||||
assert_eq!(rollout.raw_payloads.len(), 3);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use codex_protocol::protocol::SandboxPolicy;
|
||||
use codex_rmcp_client::McpOAuthRefreshMode;
|
||||
use codex_rollout_trace::TraceCaptureLimits;
|
||||
use codex_sandboxing::SandboxType;
|
||||
pub use codex_thread_store::ExtraConfig;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
@@ -1040,6 +1041,9 @@ pub struct Config {
|
||||
/// Settings that govern if and what will be written to `~/.codex/history.jsonl`.
|
||||
pub history: History,
|
||||
|
||||
/// Limits shared by all threads recording into one native rollout trace.
|
||||
pub rollout_trace_limits: TraceCaptureLimits,
|
||||
|
||||
/// When true, session is not persisted on disk. Default to `false`
|
||||
pub ephemeral: bool,
|
||||
|
||||
@@ -4153,6 +4157,12 @@ impl Config {
|
||||
let allow_login_shell = cfg.allow_login_shell.unwrap_or(true);
|
||||
|
||||
let history = cfg.history.unwrap_or_default();
|
||||
let rollout_trace = cfg.rollout_trace.unwrap_or_default();
|
||||
let defaults = TraceCaptureLimits::default();
|
||||
let rollout_trace_limits = TraceCaptureLimits {
|
||||
max_payload_bytes: rollout_trace.max_payload_bytes.unwrap_or(defaults.max_payload_bytes),
|
||||
max_bytes: rollout_trace.max_bytes.unwrap_or(defaults.max_bytes),
|
||||
};
|
||||
|
||||
if multi_agent_v2.max_concurrent_threads_per_session == 0 {
|
||||
return Err(std::io::Error::new(
|
||||
@@ -4762,6 +4772,7 @@ impl Config {
|
||||
application_network_policy: Default::default(),
|
||||
application_auth_route_config: None,
|
||||
history,
|
||||
rollout_trace_limits,
|
||||
ephemeral: ephemeral.unwrap_or_default(),
|
||||
allow_persistent_dynamic_tool_updates: false,
|
||||
extra_config: None,
|
||||
|
||||
@@ -1904,7 +1904,7 @@ impl Session {
|
||||
parent_rollout_thread_trace.start_child_thread_trace(trace_metadata)
|
||||
}
|
||||
} else {
|
||||
ThreadTraceContext::start_root(trace_metadata)
|
||||
ThreadTraceContext::start_root(trace_metadata, config.rollout_trace_limits)
|
||||
};
|
||||
let rollout_thread_trace = rollout_thread_trace.unwrap_or_else(|err| {
|
||||
startup_error.get_or_insert_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user