fix: reduce runner command poll latency

This commit is contained in:
Codex
2026-06-02 02:00:30 +08:00
parent 9b401086d0
commit 30458a7efe
4 changed files with 18 additions and 1 deletions
+1
View File
@@ -174,6 +174,7 @@ function runnerEnv(options: RunnerJobRenderOptions, context: { namespace: string
{ name: "AGENTRUN_K8S_JOB_NAME", value: context.jobName },
{ name: "AGENTRUN_LOG_PATH", value: "/tmp/agentrun-runner.jsonl" },
{ name: "AGENTRUN_RUNNER_IDLE_TIMEOUT_MS", value: "600000" },
{ name: "AGENTRUN_RUNNER_POLL_INTERVAL_MS", value: "250" },
{ name: "HOME", value: "/home/agentrun" },
{ name: "CODEX_HOME", value: codexHome },
...(selectedSecret ? [{ name: "AGENTRUN_CODEX_SECRET_HOME", value: selectedSecret.projectionMountPath }] : []),
+6 -1
View File
@@ -62,7 +62,7 @@ export async function runOnce(options: RunnerOnceOptions): Promise<JsonRecord> {
const stopHeartbeat = startHeartbeat(api, options.runId, runner.id, leaseMs);
const idleTimeoutMs = options.idleTimeoutMs ?? 120_000;
const pollIntervalMs = options.pollIntervalMs ?? 2_000;
const pollIntervalMs = normalizePollIntervalMs(options.pollIntervalMs);
const commandResults: CommandExecutionResult[] = [];
let workspacePath: string | undefined;
let materializationAttempted = false;
@@ -231,3 +231,8 @@ function noPendingResult(runner: RunnerRecord, claimed: RunRecord, commandResult
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function normalizePollIntervalMs(value: number | undefined): number {
if (!Number.isFinite(value ?? NaN)) return 250;
return Math.max(50, Math.min(2_000, Math.floor(value!)));
}