Skip to content

fix(cron): make condition watcher authoring reliable - #104787

Merged
steipete merged 2 commits into
mainfrom
codex/event-cron-live-proof
Jul 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/event-cron-live-proof

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #104780

What Problem This Solves

Fixes an issue where agents creating event-based cron condition watchers could omit required runtime semantics or silently choose announce delivery for a headless job, causing an otherwise successful fired payload to fail when no channel route exists.

The feature also lacked deterministic Gateway coverage proving that quiet evaluations persist state without run history before a natural one-shot fire.

Why This Change Was Made

The cron tool description now gives agents the complete condition-watcher contract: operator opt-in, immutable prior state and replacement state, quiet tick behavior, success-only fired-state persistence, explicit silent delivery, once semantics, evaluation budgets, and hidden Code Mode tool access.

A new QA Lab scenario exercises the real Gateway scheduler and timer. It proves quiet state with zero run rows, waits for a natural fired command payload, checks triggerFired, and verifies that once disarms the job after success. Prompt snapshots and a focused description regression test keep the model-facing contract stable.

User Impact

Agents can create silent event-based cron watchers reliably in one pass and accurately explain their lifecycle. Operators get permanent regression coverage for the quiet-poll, fired-payload, state-persistence, and one-shot invariants.

Evidence

  • Live scheduler proof against current main: quiet watcher reached 4 evaluations with zero run rows; natural fire produced EVENT_CRON_RUNTIME_OK, one triggerFired row, persisted state 4, and disabled the job (run_057816bfcaca, run_7836328fd63b).
  • Live GPT-5.4 baseline: 11 cron calls and one failed attempt before recovery (run_ac52302ae0dc).
  • Live failure-driven prompt test: payload generated EVENT_CRON_AGENT_OK, but announce delivery had no route; the run failed, fired state stayed at 2, and once stayed enabled (run_247058d7bd6c).
  • Live GPT-5.4 final: the updated 5,224-character cron prompt created the watcher in one cron call with zero tool failures and delivery.mode: "none" (run_e49cd1a9976d). Natural evaluation 3 produced exactly EVENT_CRON_AGENT_OK, recorded one successful triggerFired row, persisted state 3, and disabled the job (run_56c9324744e9).
  • Exact rebased source: pnpm test src/agents/tools/cron-tool.test.ts — 143 passed; pnpm openclaw qa suite --provider-mode mock-openai --scenario cron-condition-watcher — 1 passed (run_dbc6598f6507).
  • Remote Node 24 changed gate: formatting, prompt snapshot check, typecheck, lint, and import-cycle checks passed (run_d4d33205ee1a).
  • Remote strict build/import smoke passed (run_835412fd0f35).
  • Fresh autoreview: clean, no accepted/actionable findings.

AI-assisted change; implementation and live behavior were inspected and validated end to end.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: qa-lab size: S maintainer Maintainer-authored PR labels Jul 11, 2026

@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: 479e1e0bd4

ℹ️ 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 on lines +54 to +56
everyMs: 250
trigger:
script: "const count = (trigger.state?.count ?? 0) + 1; return { fire: count >= 6, state: { count } };"

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 Widen the quiet-observation window

With everyMs: 250 and fire: count >= 6, there are only four intervals (~1 second) between the first passing quiet condition (count >= 2) and the fired run. On a loaded Gateway/CI run where the first cron.get/cron.runs poll lands after that window, runs.entries.length is already 1 forever, so the waitForCondition later in the scenario times out even though the watcher behaved correctly. Use a much higher fire threshold or otherwise hold the job after the quiet checkpoint before waiting for the natural fire.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification complete for 12f5185c804e481a61521774b89f662217b1f2d0.

  • Live GPT-5.4 authoring: updated cron prompt visible at 5,224 characters; one cron call, zero tool failures, explicit delivery.mode: "none" (run_e49cd1a9976d).
  • Natural fired result: evaluation 3 persisted state 3, produced exactly EVENT_CRON_AGENT_OK, recorded one successful triggerFired row, and disabled the once job (run_56c9324744e9).
  • Exact rebased source: pnpm test src/agents/tools/cron-tool.test.ts — 143 passed; pnpm openclaw qa suite --provider-mode mock-openai --scenario cron-condition-watcher — passed (run_dbc6598f6507).
  • Remote changed gate: formatting, prompt snapshots, typecheck, lint, and import-cycle checks passed (run_d4d33205ee1a).
  • Remote strict build/import smoke passed (run_835412fd0f35).
  • Fresh autoreview: clean, no accepted/actionable findings.
  • Hosted CI run 29172463856 attempt 2: success. The only initial failure was an unrelated session timestamp concurrency flake; the unchanged shard passed on rerun.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 104787: passed with hosted exact-or-recent-rebase gates.

Known proof gaps: none for the changed surface.

@steipete
steipete merged commit 447c986 into main Jul 11, 2026
164 of 165 checks passed
@steipete
steipete deleted the codex/event-cron-live-proof branch July 11, 2026 23:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix(cron): teach agents condition watcher contract

* chore: defer cron note to release closeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve event-cron agent authoring and regression proof

1 participant