case-run: honor async timeout options

This commit is contained in:
Codex Agent
2026-06-06 15:23:08 +08:00
parent b3e063f38a
commit 2be05a55cf
2 changed files with 14 additions and 3 deletions
+11 -1
View File
@@ -121,6 +121,7 @@ test("case run start returns immediately and status/result/logs are short pollin
try {
await createCaseRepo(caseRepo, caseId);
await mkdir(cwd, { recursive: true });
let workerArgs: string[] = [];
const started = await runHwlabCli([
"case",
"run",
@@ -129,11 +130,16 @@ test("case run start returns immediately and status/result/logs are short pollin
"--case-repo",
caseRepo,
"--run-id",
"run-async"
"run-async",
"--agent-timeout-ms",
"180000",
"--job-timeout-ms",
"70000"
], {
cwd,
now: () => "2026-06-05T00:00:00.000Z",
startProcess: async (input) => {
workerArgs = input.args;
await writeFile(input.stdoutPath, "worker accepted\n", "utf8");
await writeFile(input.stderrPath, "", "utf8");
return { pid: 4242 };
@@ -148,6 +154,10 @@ test("case run start returns immediately and status/result/logs are short pollin
assert.match(started.payload.statusCommand, /case run status run-async/u);
assert.match(started.payload.resultCommand, /case run result run-async/u);
assert.match(started.payload.logsCommand, /case run logs run-async/u);
assert.equal(workerArgs.includes("--agent-timeout-ms"), true);
assert.equal(workerArgs[workerArgs.indexOf("--agent-timeout-ms") + 1], "180000");
assert.equal(workerArgs.includes("--job-timeout-ms"), true);
assert.equal(workerArgs[workerArgs.indexOf("--job-timeout-ms") + 1], "70000");
const status = await runHwlabCli(["case", "run", "status", "run-async"], { cwd, now: () => "2026-06-05T00:00:01.000Z" });
assert.equal(status.exitCode, 0);
+3 -2
View File
@@ -10,8 +10,9 @@ const DEFAULT_API_URL = "http://74.48.78.17:19667";
const DEFAULT_WEB_URL = "http://74.48.78.17:19666";
const DEFAULT_POLL_INTERVAL_MS = 1000;
const DEFAULT_JOB_TIMEOUT_MS = 50000;
const MAX_JOB_TIMEOUT_MS = 50000;
const MAX_JOB_TIMEOUT_MS = 300000;
const DEFAULT_AGENT_TIMEOUT_MS = 120000;
const MAX_AGENT_TIMEOUT_MS = 600000;
const MAX_AGENT_TRACE_COMMANDS = 30;
const HWLAB_API_KEY_PREFIX = "hwl_live_";
const STANDARD_CASE_REPO_PATH = "/root/hwlab-case-registry";
@@ -748,7 +749,7 @@ async function submitAgentTask(context: CaseContext, input: { baseUrl: string; p
async function pollAgentResult(context: CaseContext, input: { baseUrl: string; traceId: string; acceptedBody: any; resultUrl?: string; run?: PreparedCaseRun; agent?: AgentRunStage }) {
const requestedTimeoutMs = numberOption(context.parsed.agentTimeoutMs ?? context.parsed.timeoutMs) ?? DEFAULT_AGENT_TIMEOUT_MS;
const timeoutMs = Math.max(Math.min(requestedTimeoutMs, DEFAULT_AGENT_TIMEOUT_MS), 1000);
const timeoutMs = Math.max(Math.min(requestedTimeoutMs, MAX_AGENT_TIMEOUT_MS), 1000);
const pollIntervalMs = Math.max(numberOption(context.parsed.agentPollIntervalMs ?? context.parsed.pollIntervalMs) ?? DEFAULT_POLL_INTERVAL_MS, 250);
const startedAt = Date.now();
const resultPath = text(input.acceptedBody?.resultUrl) || `/v1/agent/chat/result/${encodeURIComponent(input.traceId)}`;