Preserve code mode dispatch errors in rollout traces (#60122)

## Why

Code mode requests can fail before a `CodeCellStarted` event. Suppressing their dispatch traces loses the caller-facing error in that case.

## What changed

Record dispatch lifecycles for code mode custom payloads, preserving their results independently of code cell events.

## Testing

Update the incompatible-payload regression test to use the code mode tool name and verify that replay retains the failed tool call and result payload even when no code cells were recorded.

GitOrigin-RevId: 687a36cd7ba55665ed7abc88c36732597e7fb025
This commit is contained in:
tongzhou wang
2026-11-07 12:41:14 +00:00
committed by copyberry
parent 43b4274f3f
commit 57a808a392
2 changed files with 6 additions and 64 deletions
@@ -249,7 +249,7 @@ async fn dispatch_lifecycle_trace_records_incompatible_payload_failures() -> any
attach_test_trace(&mut session, &turn, temp.path())?;
let registry = ToolRegistry::with_handler_for_test(Arc::new(TestHandler {
tool_name: codex_tools::ToolName::plain("test_tool"),
tool_name: codex_tools::ToolName::plain(codex_code_mode::PUBLIC_TOOL_NAME),
}));
let session = Arc::new(session);
let turn = Arc::new(turn);
@@ -260,7 +260,7 @@ async fn dispatch_lifecycle_trace_records_incompatible_payload_failures() -> any
session,
turn,
"incompatible-call",
codex_tools::ToolName::plain("test_tool"),
codex_tools::ToolName::plain(codex_code_mode::PUBLIC_TOOL_NAME),
ToolCallSource::Direct,
ToolPayload::Custom {
input: "{}".to_string(),
@@ -275,6 +275,7 @@ async fn dispatch_lifecycle_trace_records_incompatible_payload_failures() -> any
let tool_call = &replayed.tool_calls["incompatible-call"];
assert_eq!(tool_call.execution.status, ExecutionStatus::Failed);
assert!(tool_call.raw_result_payload_id.is_some());
assert!(replayed.code_cells.is_empty());
Ok(())
}