mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 09:28:35 +00:00
refactor(reply): split abort cutoff and timeout policy modules
This commit is contained in:
25
src/cron/service/timeout-policy.ts
Normal file
25
src/cron/service/timeout-policy.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { CronJob } from "../types.js";
|
||||
|
||||
/**
|
||||
* Maximum wall-clock time for a single job execution. Acts as a safety net
|
||||
* on top of per-provider/per-agent timeouts to prevent one stuck job from
|
||||
* wedging the entire cron lane.
|
||||
*/
|
||||
export const DEFAULT_JOB_TIMEOUT_MS = 10 * 60_000; // 10 minutes
|
||||
|
||||
/**
|
||||
* Agent turns can legitimately run much longer than generic cron jobs.
|
||||
* Use a larger safety ceiling when no explicit timeout is set.
|
||||
*/
|
||||
export const AGENT_TURN_SAFETY_TIMEOUT_MS = 60 * 60_000; // 60 minutes
|
||||
|
||||
export function resolveCronJobTimeoutMs(job: CronJob): number | undefined {
|
||||
const configuredTimeoutMs =
|
||||
job.payload.kind === "agentTurn" && typeof job.payload.timeoutSeconds === "number"
|
||||
? Math.floor(job.payload.timeoutSeconds * 1_000)
|
||||
: undefined;
|
||||
if (configuredTimeoutMs === undefined) {
|
||||
return job.payload.kind === "agentTurn" ? AGENT_TURN_SAFETY_TIMEOUT_MS : DEFAULT_JOB_TIMEOUT_MS;
|
||||
}
|
||||
return configuredTimeoutMs <= 0 ? undefined : configuredTimeoutMs;
|
||||
}
|
||||
Reference in New Issue
Block a user