mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Move rollout trace recording to a background worker (#61253)
## Why Recording inference starts synchronously serializes prompts and writes trace payloads before model work can proceed. Defer that work so inference dispatch can continue while the trace is recorded. ## What changed - Use one worker per trace bundle to write events in submission order, with up to eight pending jobs. - Share prepared prompts and encoded requests with the worker, and build remote compaction snapshots there. Write payloads before publishing events that reference them. - Add `TraceWriter::flush` and `ThreadTraceContext::flush` for live reads. Drain accepted jobs and seal the bundle on shutdown; suppress the closing marker after a recording failure. ## Testing Add tests for deferred prompt serialization, ordered start and completion events, shutdown draining, and serialization failures that preserve earlier evidence without publishing a closing marker. Verify compaction snapshots are built on the worker and skipped when tracing is disabled. GitOrigin-RevId: 32fd787bb1d281f1814df2f08c73b667628f8add
This commit is contained in:
committed by
copyberry
parent
aa5f492031
commit
b8dde1eb40
@@ -311,7 +311,7 @@ mod job {
|
||||
prompt.output_schema_strict = true;
|
||||
|
||||
let (result, token_usage) = context
|
||||
.stream_stage_one_prompt(config, &prompt, stage_one_context)
|
||||
.stream_stage_one_prompt(config, prompt, stage_one_context)
|
||||
.await?;
|
||||
|
||||
let output = StageOneOutput::parse(&result, config.memories.version)?;
|
||||
|
||||
@@ -319,7 +319,7 @@ impl MemoryStartupContext {
|
||||
pub(crate) async fn stream_stage_one_prompt(
|
||||
&self,
|
||||
config: &Config,
|
||||
prompt: &Prompt,
|
||||
prompt: Prompt,
|
||||
context: &StageOneRequestContext,
|
||||
) -> anyhow::Result<(String, Option<TokenUsage>)> {
|
||||
let installation_id = resolve_installation_id(&config.codex_home).await?;
|
||||
@@ -364,7 +364,7 @@ impl MemoryStartupContext {
|
||||
.await;
|
||||
let mut stream = client_session
|
||||
.stream(
|
||||
prompt,
|
||||
&Arc::new(prompt),
|
||||
&context.model_info,
|
||||
&context.session_telemetry,
|
||||
context.reasoning_effort.clone(),
|
||||
|
||||
@@ -725,7 +725,7 @@ async fn memories_startup_phase1_uses_live_thread_service_tier_and_detached_meta
|
||||
context
|
||||
.stream_stage_one_prompt(
|
||||
&test.config,
|
||||
&codex_core::Prompt::default(),
|
||||
codex_core::Prompt::default(),
|
||||
&request_context,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user