fix: 继续收敛 codex trace 残余噪声 (#68)

Co-authored-by: Codex <codex@pikas.tech>
This commit is contained in:
Lyon
2026-06-02 10:11:31 +08:00
committed by GitHub
parent 2c2524880e
commit a6f7581b96
6 changed files with 21 additions and 15 deletions
+12 -11
View File
@@ -153,7 +153,7 @@ async function executeCommand(api: RunnerManagerApi, options: RunnerOnceOptions,
await api.appendEvent(options.runId, { type: "backend_status", payload: { phase: "backend-turn-started", commandId: command.id, attemptId, runnerId: runner.id, backendProfile: options.backendProfile ?? null, workspaceReady: Boolean(workspacePath) } });
const abortController = new AbortController();
const stopCancelWatch = watchCancellation(api, options.runId, command.id, abortController);
const stopBackendProgress = startBackendProgress(api, options.runId, command.id, attemptId, runner.id, options.backendProfile ?? null);
const backendProgress = startBackendProgress();
let stopSteerWatch: (() => void) | undefined;
try {
const latestRun = await api.getRun(options.runId);
@@ -184,8 +184,8 @@ async function executeCommand(api: RunnerManagerApi, options: RunnerOnceOptions,
return await reportCommandFailure(api, options.runId, command.id, runner, attemptId, failure, "runner:execute");
} finally {
stopSteerWatch?.();
stopBackendProgress();
await appendBestEffort(api, options.runId, { type: "backend_status", payload: { phase: "backend-turn-finished", commandId: command.id, attemptId, runnerId: runner.id } });
const progressSummary = backendProgress.stop();
await appendBestEffort(api, options.runId, { type: "backend_status", payload: { phase: "backend-turn-finished", commandId: command.id, attemptId, runnerId: runner.id, ...progressSummary } });
stopCancelWatch();
}
}
@@ -307,20 +307,21 @@ function startHeartbeat(api: RunnerManagerApi, runId: string, runnerId: string,
};
}
function startBackendProgress(api: RunnerManagerApi, runId: string, commandId: string, attemptId: string, runnerId: string, backendProfile: string | null): () => void {
function startBackendProgress(): { stop: () => JsonRecord } {
let stopped = false;
let ticks = 0;
const startedAt = Date.now();
const emit = async (): Promise<void> => {
const tick = (): void => {
if (stopped) return;
ticks += 1;
await appendBestEffort(api, runId, { type: "backend_status", payload: { phase: "backend-turn-running", commandId, attemptId, runnerId, backendProfile, elapsedMs: Date.now() - startedAt, ticks } });
};
const timer = setInterval(() => { void emit(); }, 10_000);
void emit();
return () => {
stopped = true;
clearInterval(timer);
const timer = setInterval(tick, 10_000);
return {
stop: () => {
stopped = true;
clearInterval(timer);
return { elapsedMs: Date.now() - startedAt, progressTicks: ticks, progressEventsPrinted: false };
},
};
}