


























@@ -25,8 +25,22 @@ const describeLive = LIVE && CODEX_HARNESS_LIVE ? describe : describe.skip;
2525const LIVE_TIMEOUT_MS = 420_000;
2626const GATEWAY_CONNECT_TIMEOUT_MS = 60_000;
2727const AGENT_REQUEST_TIMEOUT_MS = 180_000;
28+// Keep this below LIVE_TIMEOUT_MS so timeout diagnostics win over Vitest's generic cap.
29+const TRAJECTORY_EXPORT_INSTRUCTION_TIMEOUT_MS = 120_000;
2830const DEFAULT_CODEX_MODEL = "openai/gpt-5.5";
293132+type TrajectoryExportApprovalEntry = {
33+id?: string;
34+request?: {
35+command?: string;
36+};
37+};
38+39+type TrajectoryExportApprovalSummary = {
40+id?: string;
41+hasTrajectoryExportCommand: boolean;
42+};
43+3044function logLiveStep(step: string, details?: Record<string, unknown>): void {
3145if (!CODEX_HARNESS_DEBUG) {
3246return;
@@ -189,6 +203,22 @@ function extractAssistantTexts(messages: unknown[]): string[] {
189203return texts;
190204}
191205206+function isTrajectoryExportApproval(entry: TrajectoryExportApprovalEntry): boolean {
207+return Boolean(entry.request?.command?.includes("sessions export-trajectory"));
208+}
209+210+function summarizeTrajectoryExportApproval(
211+entry: TrajectoryExportApprovalEntry,
212+): TrajectoryExportApprovalSummary {
213+const summary: TrajectoryExportApprovalSummary = {
214+hasTrajectoryExportCommand: isTrajectoryExportApproval(entry),
215+};
216+if (entry.id) {
217+summary.id = entry.id;
218+}
219+return summary;
220+}
221+192222async function waitForTrajectoryExportInstructionText(params: {
193223client: GatewayClient;
194224events: EventFrame[];
@@ -214,6 +244,7 @@ async function waitForTrajectoryExportInstructionText(params: {
214244});
215245}
216246let assistantTexts: string[];
247+let approvalSummaries: TrajectoryExportApprovalSummary[];
217248try {
218249const history = (await params.client.request(
219250"chat.history",
@@ -227,9 +258,19 @@ async function waitForTrajectoryExportInstructionText(params: {
227258} catch {
228259assistantTexts = [];
229260}
261+try {
262+const approvals = (await params.client.request(
263+"exec.approval.list",
264+{},
265+{ timeoutMs: 10_000 },
266+)) as TrajectoryExportApprovalEntry[];
267+approvalSummaries = approvals.map(summarizeTrajectoryExportApproval);
268+} catch {
269+approvalSummaries = [];
270+}
230271throw new Error(
231272`timed out waiting for trajectory export instruction text for ${params.runId}; ` +
232-`events=${params.events.length}; finalTexts=${formatTextPreview(finalTexts)}; assistantTexts=${formatTextPreview(assistantTexts)}`,
273+`events=${params.events.length}; finalTexts=${formatTextPreview(finalTexts)}; assistantTexts=${formatTextPreview(assistantTexts)}; approvals=${JSON.stringify(approvalSummaries)}`,
233274);
234275}
235276@@ -285,35 +326,16 @@ function extractVisibleMessageText(message: unknown): string | undefined {
285326286327async function approveTrajectoryExport(client: GatewayClient): Promise<string> {
287328const startedAt = Date.now();
288-let approval:
289-| {
290-id?: string;
291-request?: {
292-command?: string;
293-};
294-}
295-| undefined;
296-let lastApprovalSummaries: Array<{ id?: string; hasTrajectoryExportCommand: boolean }> = [];
329+let approval: TrajectoryExportApprovalEntry | undefined;
330+let lastApprovalSummaries: TrajectoryExportApprovalSummary[] = [];
297331while (Date.now() - startedAt < 60_000) {
298332const approvals = (await client.request(
299333"exec.approval.list",
300334{},
301335{ timeoutMs: 10_000 },
302-)) as Array<{
303-id?: string;
304-request?: {
305-command?: string;
306-};
307-}>;
308-lastApprovalSummaries = approvals.map((entry) => ({
309- ...(entry.id ? { id: entry.id } : {}),
310-hasTrajectoryExportCommand: Boolean(
311-entry.request?.command?.includes("sessions export-trajectory"),
312-),
313-}));
314-approval = approvals.find((entry) =>
315-entry.request?.command?.includes("sessions export-trajectory"),
316-);
336+)) as TrajectoryExportApprovalEntry[];
337+lastApprovalSummaries = approvals.map(summarizeTrajectoryExportApproval);
338+approval = approvals.find(isTrajectoryExportApproval);
317339if (approval) {
318340break;
319341}
@@ -461,7 +483,7 @@ describeLive("gateway live trajectory export", () => {
461483expectedText: "Trajectory exports can include",
462484runId: exportRunId,
463485 sessionKey,
464-timeoutMs: 60_000,
486+timeoutMs: TRAJECTORY_EXPORT_INSTRUCTION_TIMEOUT_MS,
465487});
466488expect(finalText).toContain("Trajectory exports can include");
467489expect(finalText).toContain("through exec approval");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。