Skip to content

fix(agents): prefer cron for deferred follow-ups - #60811

Merged
vincentkoc merged 6 commits into
openclaw:mainfrom
vincentkoc:codex/cron-prompt-followups
Apr 4, 2026
Merged

vincentkoc merged 6 commits into
openclaw:mainfrom
vincentkoc:codex/cron-prompt-followups

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

AI-assisted: Codex

  • Problem: the agent prompt/tool guidance treated delayed follow-ups as a valid exec/process polling problem instead of clearly steering them to cron.
  • Why it matters: requests like "check back in 10 minutes" can get implemented as sleep/poll loops even though OpenClaw already has scheduler wiring.
  • What changed: tightened the system prompt plus cron/exec/process tool descriptions so future-time follow-up maps to cron, while background exec/process is reserved for work that starts now.
  • What did NOT change (scope boundary): no scheduler backend changes, no cron runtime behavior changes, no new task wiring.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: the top-level agent prompt explicitly suggested exec/process waiting for long delays, and the tool descriptions did not draw a strong boundary between background work and scheduled follow-up.
  • Missing detection / guardrail: prompt-level guidance did not explicitly say “future-time follow-up => cron; do not emulate scheduling with sleep/polling”.
  • Contributing context (if known): OpenClaw already had the scheduler/task wiring, so the failure mode was largely model policy, not runtime capability.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/system-prompt.test.ts, src/agents/tools/cron-tool.test.ts, src/agents/bash-tools.test.ts
  • Scenario the test should lock in: delayed follow-up language steers the model to cron, while exec/process descriptions frame themselves as background-now tools instead of timer emulation tools.
  • Why this is the smallest reliable guardrail: the bug is in prompt/tool wording, so prompt and description assertions are the narrowest direct lock.
  • Existing test that already covers this (if any): none directly
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Agents should be more likely to schedule "check back later" / reminder-style requests with cron instead of using shell sleep or poll loops.
  • Background shell/process tools still cover work that starts now and keeps running.

Diagram (if applicable)

Before:
[user asks for future follow-up] -> [prompt suggests exec/process waiting] -> [model may choose sleep or polling]

After:
[user asks for future follow-up] -> [prompt/tool policy points to cron] -> [scheduled follow-up]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Codex worktree
  • Model/provider: prompt/tooling only
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Build the agent system prompt and inspect the tool guidance for delayed follow-up requests.
  2. Inspect the cron, exec, and process tool descriptions.
  3. Confirm future-time follow-up now maps to cron, and background exec/process language is scoped to work that starts now.

Expected

  • Delayed follow-up requests steer to cron.
  • exec/process no longer read like timer emulation tools.

Actual

  • Matches expected in direct runtime sanity checks.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: direct runtime sanity checks using bun -e confirmed the updated prompt/tool descriptions are emitted as intended.
  • Edge cases checked: kept the fallback path for runtimes without cron guidance and left scheduler wiring untouched.
  • What you did not verify: I attempted scoped pnpm test -- ... lanes and codex review --base origin/main, but both stalled in this machine's current local test/review contention, so I am not claiming clean Vitest output here.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: prompt wording may be too strong in runtimes that intentionally omit cron.
    • Mitigation: the explicit deferred-follow-up guidance only activates when cron is available (or when the default tool fallback is in effect); otherwise the old long-wait guidance remains.

@vincentkoc vincentkoc self-assigned this Apr 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Apr 4, 2026
@vincentkoc vincentkoc changed the title [codex] fix(agents): prefer cron for deferred follow-ups fix(agents): prefer cron for deferred follow-ups Apr 4, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 4, 2026 10:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad4ac5d3c7

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/bash-tools.exec.ts Resolved
@greptile-apps

greptile-apps Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR tightens system-prompt and tool-description wording so that future-time follow-up requests ("check back in 10 minutes", reminders) are steered to cron instead of exec sleep/polling loops. The production-code changes (system-prompt.ts, bash-tools.exec.ts, bash-tools.process.ts, cron-tool.ts) are correct and well-scoped, with no runtime behaviour changes.

Three of the new or modified test assertions will fail without further fixes:

  • src/auto-reply/status.tools.test.ts (line 133–135): the test fixture rawDescription doesn't include "Use this for reminders…", so describeToolForVerbose cannot produce the expected output.
  • src/agents/system-prompt.test.ts (lines 122–129): toolNames: ["message", "memory_search"] causes hasCronTool = false, so the cron-preference guidance is never emitted and the three toContain calls fail.
  • src/agents/tools-effective-inventory.test.ts (line 173–175): the expected 241-char description string will be truncated to ≤120 chars by summarizeToolDescriptionText's default maxLen.

Confidence Score: 4/5

Production code changes are safe and correct; three test assertions introduced by this PR will fail in CI and need to be fixed before merging.

All runtime/prompt changes are prompt-wording only with no behaviour regressions. However, three of the new or modified test assertions are verifiably broken — the test fixture for status.tools.test.ts is missing the expected sentence, the system-prompt.test.ts minimal-mode test uses tool names that result in hasCronTool=false, and tools-effective-inventory.test.ts expects a string longer than the 120-char truncation limit. The PR author explicitly acknowledged not running tests. These are P1 CI failures that must be corrected before landing.

src/auto-reply/status.tools.test.ts (fixture mismatch), src/agents/system-prompt.test.ts (hasCronTool=false for given toolNames), src/agents/tools-effective-inventory.test.ts (truncation vs expected length)

Comments Outside Diff (3)

  1. src/auto-reply/status.tools.test.ts, line 107-138 (link)

    P1 Test fixture mismatch — assertion will fail

    The rawDescription passed to the test fixture (line 122–123) is "Manage Gateway cron jobs and send wake events.\n\nACTIONS:...", but the toContain assertion at line 133–135 expects a string that includes "Use this for reminders, \"check back later\" requests, delayed follow-ups, and recurring tasks. Do not emulate scheduling with exec sleep or process polling." — a phrase that is absent from the fixture's rawDescription.

    describeToolForVerbose builds its output exclusively from what is passed in via rawDescription; it trims at the first ACTIONS: line, leaving only "Manage Gateway cron jobs and send wake events.". The additional sentence therefore can never appear in the output, and the assertion will fail.

    The fixture's rawDescription needs to be updated to contain the full first paragraph of the actual createCronTool description so that describeToolForVerbose can produce the expected output.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/auto-reply/status.tools.test.ts
    Line: 107-138
    
    Comment:
    **Test fixture mismatch — assertion will fail**
    
    The `rawDescription` passed to the test fixture (line 122–123) is `"Manage Gateway cron jobs and send wake events.\n\nACTIONS:..."`, but the `toContain` assertion at line 133–135 expects a string that includes `"Use this for reminders, \"check back later\" requests, delayed follow-ups, and recurring tasks. Do not emulate scheduling with exec sleep or process polling."` — a phrase that is **absent** from the fixture's `rawDescription`.
    
    `describeToolForVerbose` builds its output exclusively from what is passed in via `rawDescription`; it trims at the first `ACTIONS:` line, leaving only `"Manage Gateway cron jobs and send wake events."`. The additional sentence therefore can never appear in the output, and the assertion will fail.
    
    The fixture's `rawDescription` needs to be updated to contain the full first paragraph of the actual `createCronTool` description so that `describeToolForVerbose` can produce the expected output.
    
    How can I resolve this? If you propose a fix, please make it concise.
  2. src/agents/system-prompt.test.ts, line 96-138 (link)

    P1 hasCronTool is false for the given toolNames — cron guidance assertions will fail

    The test passes toolNames: ["message", "memory_search"]; neither includes "cron". With those tool names, availableTools.has("cron") is false and usingDefaultToolFallback is also false (because toolLines.length > 0). Therefore hasCronTool = false, and buildAgentSystemPrompt takes the else-branch:

    `For long waits, avoid rapid poll loops: use ${execToolName} with enough yieldMs or ${processToolName}(action=poll, timeout=<ms>).`

    The three new assertions added at lines 122–129 expect the cron-preferred guidance ("For follow-up at a future time …", "Use exec/process only for commands that start now…", "Do not emulate scheduling with sleep loops…"), which will not be present in the prompt. All three toContain calls will fail.

    To fix this, add "cron" to toolNames in this test case, or adjust the assertions to match the fallback guidance that is actually emitted when cron is absent.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/agents/system-prompt.test.ts
    Line: 96-138
    
    Comment:
    **`hasCronTool` is false for the given `toolNames` — cron guidance assertions will fail**
    
    The test passes `toolNames: ["message", "memory_search"]`; neither includes `"cron"`. With those tool names, `availableTools.has("cron")` is `false` and `usingDefaultToolFallback` is also `false` (because `toolLines.length > 0`). Therefore `hasCronTool = false`, and `buildAgentSystemPrompt` takes the else-branch:
    
    ```ts
    `For long waits, avoid rapid poll loops: use ${execToolName} with enough yieldMs or ${processToolName}(action=poll, timeout=<ms>).`
    ```
    
    The three new assertions added at lines 122–129 expect the cron-preferred guidance (`"For follow-up at a future time …"`, `"Use exec/process only for commands that start now…"`, `"Do not emulate scheduling with sleep loops…"`), which will **not** be present in the prompt. All three `toContain` calls will fail.
    
    To fix this, add `"cron"` to `toolNames` in this test case, or adjust the assertions to match the fallback guidance that is actually emitted when cron is absent.
    
    How can I resolve this? If you propose a fix, please make it concise.
  3. src/agents/tools-effective-inventory.test.ts, line 159-177 (link)

    P1 241-char expected string will be truncated to 120 chars — assertion will fail

    summarizeToolDescription calls summarizeToolDescriptionText without a maxLen, so truncateSummary uses its default of 120 characters. The first paragraph of the fixture description ("Manage Gateway cron jobs (status/list/add/update/remove/run/runs) and send wake events. Use this for reminders…process polling.") is ~241 characters, which exceeds 120 and will be truncated with "...".

    The toBe assertion at line 173–175 expects the full 241-character string; it will fail because the actual description field is the truncated form.

    Either raise the maxLen (pass a larger value from summarizeToolDescription / the call site), or adjust the expected string in the test to match what the current 120-char truncation actually produces.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/agents/tools-effective-inventory.test.ts
    Line: 159-177
    
    Comment:
    **241-char expected string will be truncated to 120 chars — assertion will fail**
    
    `summarizeToolDescription` calls `summarizeToolDescriptionText` without a `maxLen`, so `truncateSummary` uses its default of **120 characters**. The first paragraph of the fixture description ("Manage Gateway cron jobs (status/list/add/update/remove/run/runs) and send wake events. Use this for reminders…process polling.") is ~241 characters, which exceeds 120 and will be truncated with `"..."`.
    
    The `toBe` assertion at line 173–175 expects the full 241-character string; it will fail because the actual `description` field is the truncated form.
    
    Either raise the `maxLen` (pass a larger value from `summarizeToolDescription` / the call site), or adjust the expected string in the test to match what the current 120-char truncation actually produces.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/auto-reply/status.tools.test.ts
Line: 107-138

Comment:
**Test fixture mismatch — assertion will fail**

The `rawDescription` passed to the test fixture (line 122–123) is `"Manage Gateway cron jobs and send wake events.\n\nACTIONS:..."`, but the `toContain` assertion at line 133–135 expects a string that includes `"Use this for reminders, \"check back later\" requests, delayed follow-ups, and recurring tasks. Do not emulate scheduling with exec sleep or process polling."` — a phrase that is **absent** from the fixture's `rawDescription`.

`describeToolForVerbose` builds its output exclusively from what is passed in via `rawDescription`; it trims at the first `ACTIONS:` line, leaving only `"Manage Gateway cron jobs and send wake events."`. The additional sentence therefore can never appear in the output, and the assertion will fail.

The fixture's `rawDescription` needs to be updated to contain the full first paragraph of the actual `createCronTool` description so that `describeToolForVerbose` can produce the expected output.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/system-prompt.test.ts
Line: 96-138

Comment:
**`hasCronTool` is false for the given `toolNames` — cron guidance assertions will fail**

The test passes `toolNames: ["message", "memory_search"]`; neither includes `"cron"`. With those tool names, `availableTools.has("cron")` is `false` and `usingDefaultToolFallback` is also `false` (because `toolLines.length > 0`). Therefore `hasCronTool = false`, and `buildAgentSystemPrompt` takes the else-branch:

```ts
`For long waits, avoid rapid poll loops: use ${execToolName} with enough yieldMs or ${processToolName}(action=poll, timeout=<ms>).`
```

The three new assertions added at lines 122–129 expect the cron-preferred guidance (`"For follow-up at a future time …"`, `"Use exec/process only for commands that start now…"`, `"Do not emulate scheduling with sleep loops…"`), which will **not** be present in the prompt. All three `toContain` calls will fail.

To fix this, add `"cron"` to `toolNames` in this test case, or adjust the assertions to match the fallback guidance that is actually emitted when cron is absent.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/tools-effective-inventory.test.ts
Line: 159-177

Comment:
**241-char expected string will be truncated to 120 chars — assertion will fail**

`summarizeToolDescription` calls `summarizeToolDescriptionText` without a `maxLen`, so `truncateSummary` uses its default of **120 characters**. The first paragraph of the fixture description ("Manage Gateway cron jobs (status/list/add/update/remove/run/runs) and send wake events. Use this for reminders…process polling.") is ~241 characters, which exceeds 120 and will be truncated with `"..."`.

The `toBe` assertion at line 173–175 expects the full 241-character string; it will fail because the actual `description` field is the truncated form.

Either raise the `maxLen` (pass a larger value from `summarizeToolDescription` / the call site), or adjust the expected string in the test to match what the current 120-char truncation actually produces.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Merge branch 'main' into codex/cron-prom..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee307c4683

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/system-prompt.ts Resolved
@vincentkoc
vincentkoc merged commit b742909 into openclaw:main Apr 4, 2026
27 of 35 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5caa16a20d

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"- canvas: present/eval/snapshot the Canvas",
"- nodes: list/describe/notify/camera/screen on paired nodes",
"- cron: manage cron jobs and wake events (use for reminders; when scheduling a reminder, write the systemEvent text as something that will read like a reminder when it fires, and mention that it is a reminder depending on the time gap between setting and firing; include recent context in reminder text if appropriate)",
`- cron: ${cronToolSummary.toLowerCase()}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve cron field casing in fallback tool summaries

When toolLines is empty, this fallback branch lowercases cronToolSummary, which rewrites schema-like keys such as systemEvent and yieldMs to systemevent/yieldms. In prompts built through this path, the model is taught incorrect cron argument names and can generate invalid tool calls for scheduled reminders. Keep the summary text casing intact (or only lowercase plain prose) so parameter names remain valid.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* fix(agents): prefer cron for deferred follow-ups

* fix(agents): gate cron scheduling guidance

* fix(changelog): add scheduling guidance note

* fix(agents): restore exec approval agent hint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant