Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edd9da46ea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (params.trigger === "cron" && params.timeoutMs) { | ||
| return Math.min(Math.floor(params.timeoutMs * 0.5), DEFAULT_LLM_IDLE_TIMEOUT_MS); |
There was a problem hiding this comment.
Handle no-timeout cron jobs before proportional idle math
resolveLlmIdleTimeoutMs applies the proportional cron branch whenever timeoutMs is truthy, but isolated cron runs always pass a numeric timeout and resolveAgentTimeoutMs encodes timeoutSeconds: 0 (no overall timeout) as 2_147_000_000 (src/agents/timeout.ts). That means no-timeout cron jobs still get a 60s idle timeout and can abort early, while the fallback branch that returns 0 for cron is effectively unreachable in production (src/cron/isolated-agent/run.ts). Please gate the proportional branch on an actual bounded cron timeout (or plumb raw timeoutSeconds) so explicit no-timeout cron jobs do not inherit the idle timeout.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes early-abort on cron runs whose
Confidence Score: 5/5Safe to merge — narrowly scoped change with correct logic and solid test coverage. The change touches only No files require special attention; the minor test-coverage gap in Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-runner/run/llm-idle-timeout.test.ts
Line: 96-106
Comment:
**Missing `"memory"` and `"overflow"` trigger coverage**
The non-cron triggers describe block tests `"user"`, `"heartbeat"`, and `"manual"` but omits `"memory"` and `"overflow"`, which are also valid `EmbeddedRunTrigger` values (see `params.ts:26`). Since the function falls through to `DEFAULT_LLM_IDLE_TIMEOUT_MS` for any non-`"cron"` trigger, this is a coverage gap rather than a bug — but adding them makes the suite exhaustive and guards against future divergence if the two omitted triggers ever need different handling.
```suggestion
it("returns default for non-cron triggers", () => {
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "user" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "heartbeat" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "manual" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "memory" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "overflow" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
});
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(agents): proportional idle timeout f..." | Re-trigger Greptile |
| it("returns default for non-cron triggers", () => { | ||
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "user" })).toBe( | ||
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | ||
| ); | ||
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "heartbeat" })).toBe( | ||
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | ||
| ); | ||
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "manual" })).toBe( | ||
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Missing
"memory" and "overflow" trigger coverage
The non-cron triggers describe block tests "user", "heartbeat", and "manual" but omits "memory" and "overflow", which are also valid EmbeddedRunTrigger values (see params.ts:26). Since the function falls through to DEFAULT_LLM_IDLE_TIMEOUT_MS for any non-"cron" trigger, this is a coverage gap rather than a bug — but adding them makes the suite exhaustive and guards against future divergence if the two omitted triggers ever need different handling.
| it("returns default for non-cron triggers", () => { | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "user" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "heartbeat" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "manual" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| }); | |
| it("returns default for non-cron triggers", () => { | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "user" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "heartbeat" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "manual" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "memory" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "overflow" })).toBe( | |
| DEFAULT_LLM_IDLE_TIMEOUT_MS, | |
| ); | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/run/llm-idle-timeout.test.ts
Line: 96-106
Comment:
**Missing `"memory"` and `"overflow"` trigger coverage**
The non-cron triggers describe block tests `"user"`, `"heartbeat"`, and `"manual"` but omits `"memory"` and `"overflow"`, which are also valid `EmbeddedRunTrigger` values (see `params.ts:26`). Since the function falls through to `DEFAULT_LLM_IDLE_TIMEOUT_MS` for any non-`"cron"` trigger, this is a coverage gap rather than a bug — but adding them makes the suite exhaustive and guards against future divergence if the two omitted triggers ever need different handling.
```suggestion
it("returns default for non-cron triggers", () => {
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "user" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "heartbeat" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "manual" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "memory" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
expect(resolveLlmIdleTimeoutMs({ cfg: undefined, trigger: "overflow" })).toBe(
DEFAULT_LLM_IDLE_TIMEOUT_MS,
);
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Cherry-pick of openclaw#61239 (Linux2010). Cron jobs with timeoutSeconds > 60s no longer abort early at the default 60s LLM idle timeout. idle_timeout = min(overall_timeout * 0.5, 60s). CHANGELOG conflict resolved by keeping HEAD.
Cron-triggered runs now use proportional idle timeout (50% of overall timeout, capped at 60s) instead of the hardcoded 60s default. This allows long-running cron jobs with custom timeoutSeconds to run without early abortion, while still detecting genuinely stuck models. Changes: - resolveLlmIdleTimeoutMs: add trigger and timeoutMs parameters - Cron with timeoutMs: idle = min(timeoutMs * 0.5, 60s) - Cron without timeoutMs: disable idle check (return 0) - Non-cron triggers: unchanged behavior - Add 12 new test cases covering cron scenarios Fixes openclaw#61118
edd9da4 to
9c3e3ee
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c3e3ee04f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (params.trigger === "cron" && params.timeoutMs) { | ||
| return Math.min(Math.floor(params.timeoutMs * 0.5), DEFAULT_LLM_IDLE_TIMEOUT_MS); |
There was a problem hiding this comment.
Distinguish unbounded cron runs before proportional idle math
In the isolated cron path, timeoutMs is always numeric (from prepareCronRunContext via resolveAgentTimeoutMs), and timeoutSeconds: 0 is represented as 2_147_000_000 for “no timeout.” With the current truthy check, those unbounded cron runs still take the proportional branch and resolve to a 60s idle timeout, so they can still abort early on long silent model phases. That also makes the later cron fallback branch returning 0 effectively unreachable in production.
Useful? React with 👍 / 👎.
|
Thanks @Linux2010. I landed the cron timeout fix on main in d9dc75774b. I went with disabling the default idle watchdog for cron runs when no timeout is explicitly configured, and inheriting Closing this PR as superseded by the landed commit. |
Summary
Fixes #61118
Alternative to #60210 with a more flexible approach.
Problem
Isolated cron runs inherited the embedded runner's default 60s LLM idle timeout, causing jobs with
timeoutSeconds > 60to abort early when the model didn't produce tokens for >60s.Solution
Instead of completely disabling idle timeout for cron (as #60210 does), this PR makes it proportional to the overall job timeout:
Examples
Benefits over #60210
min(timeout/2, 60s)idleTimeoutSecondsconfig still winsChanges
llm-idle-timeout.ts: AddtriggerandtimeoutMsparameters toresolveLlmIdleTimeoutMsattempt.ts: PasstriggerandtimeoutMsto the functionllm-idle-timeout.test.ts: Add 12 new test cases for cron scenariosCHANGELOG.md: Document the fixTesting
All 20 tests pass:
Comparison with #60210