Accurately capture the time that custom.exec calls blocks the main thread.

This commit is contained in:
Albin Cassirer
2026-04-20 17:50:01 -07:00
parent b078a9f611
commit 3bb7ee8935
2 changed files with 73 additions and 22 deletions
@@ -78,19 +78,18 @@ impl CodeModeExecuteHandler {
return Err(FunctionCallError::RespondToModel(err));
}
};
if !matches!(&response, codex_code_mode::RuntimeResponse::Yielded { .. }) {
let result_payload = codex_trace::write_payload(
"code_cell_result",
&code_cell_response_payload(&response),
);
emit_code_cell_ended(
&exec,
&runtime_cell_id,
&response,
/*model_visible_wait_call_id*/ None,
result_payload.as_ref(),
);
}
let result_payload =
codex_trace::write_payload("code_cell_result", &code_cell_response_payload(&response));
// A yielded response is the end of the model-visible custom `exec`
// call, not the end of the runtime cell. Emit it anyway so the trace
// can distinguish "the model got a cell id" from "the JS finished".
emit_code_cell_ended(
&exec,
&runtime_cell_id,
&response,
/*model_visible_wait_call_id*/ None,
result_payload.as_ref(),
);
handle_runtime_response(&exec, response, args.max_output_tokens, started_at)
.await
.map_err(FunctionCallError::RespondToModel)