Skip to content

[codex] Fix cron chat session-key binding - #81376

Closed
VishalJ99 wants to merge 2 commits into
openclaw:mainfrom
VishalJ99:codex/fix-cron-chat-session-binding
Closed

VishalJ99 wants to merge 2 commits into
openclaw:mainfrom
VishalJ99:codex/fix-cron-chat-session-binding

Conversation

@VishalJ99

@VishalJ99 VishalJ99 commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #81375.

  • Stop the cron tool from stamping the caller chat sessionKey onto implicit sessionTarget="main" / payload.kind="systemEvent" jobs.
  • Preserve explicit job.sessionKey and preserve caller-session stamping for isolated agentTurn jobs, where the run-scoped cron session and inferred announce delivery still need that context.
  • Add regression coverage for both paths.

Root Cause / Live Behavior

Observed on 2026-05-13 after a macOS restart with local OpenClaw 2026.5.10-beta.1 (dedc49c):

  • WhatsApp was healthy, linked, connected, and running.
  • A user WhatsApp hi was ingested at 11:08:08 BST (web-inbound, web-auto-reply, and gateway/channels/whatsapp/inbound all logged it), but no visible reply was delivered and typing later timed out.
  • Two due cron jobs created from the same chat were bound to sessionTarget="main", payload.kind="systemEvent", and the WhatsApp direct-chat session key. Startup catch-up put that cron work on the same session lane as the human DM; one job ran from about 11:06:35 to 11:08:39, and the next started immediately afterward.
  • Editing the live jobs to isolated agentTurn + announce delivery removed the lane collision. The WhatsApp channel stayed healthy and later outbound delivery succeeded.

I checked current upstream/latest beta before patching. 2026.5.12-beta.4 includes the adjacent WhatsApp pending-debounce close fix (#81246), and upstream main includes the active-run stuck-lane diagnostic fix (#81302), but neither changes this cron-tool session-key stamping behavior.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: User-facing cron jobs created from a live WhatsApp chat could inherit that chat's session key as implicit main/systemEvent work, so post-reboot catch-up could occupy the same session lane as a human DM and make WhatsApp appear non-responsive.
  • Real environment tested: macOS OpenClaw gateway using WhatsApp Web, local OpenClaw 2026.5.10-beta.1 (dedc49c), with private phone numbers and JIDs redacted. Inbound smoke source was local wacli using the default authenticated sender store into the OpenClaw PA WhatsApp account.
  • Exact steps or command run after this patch: Applied the same target-state mitigation on the live setup by editing the affected cron jobs to isolated agentTurn jobs with explicit WhatsApp announce delivery, then sent a fresh inbound WhatsApp message through wacli, and checked OpenClaw runtime logs plus channel status.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
$ openclaw cron show 4aff489a-e5b4-450f-add0-c2ea03efa8b2
name: Dross aliveness heartbeat
session: isolated
agent: main
delivery: announce -> whatsapp:<redacted-owner> (explicit)
status: ok

$ openclaw cron show 406c58a8-f715-4ed6-b30f-2e29821d45f4
name: Morning calendar reminder setup
session: isolated
agent: main
delivery: announce -> whatsapp:<redacted-owner> (explicit)
status: ok

$ wacli --json --timeout 120s send text --to <redacted-pa-jid> --message "hi - codex wacli live smoke test 20260513T104309Z"
{"success":true,"data":{"id":"3EB03292C2A65E44315BFC","sent":true,"to":"<redacted-pa-jid>"},"error":null}

2026-05-13 11:43:10 BST web-inbound body="hi - codex wacli live smoke test 20260513T104309Z"
2026-05-13 11:43:10 BST web-auto-reply correlationId=3EB03292C2A65E44315BFC
2026-05-13 11:43:10 BST gateway/channels/whatsapp/inbound Inbound message <redacted-owner> -> <redacted-pa> (direct, 106 chars)
2026-05-13 11:43:14 BST gateway/channels/whatsapp/outbound Sending message -> sha256:<redacted>
2026-05-13 11:43:14 BST gateway/channels/whatsapp/outbound Sent message 3EB0E1298C5CBA7AC4A14E -> sha256:<redacted> (198ms)

$ openclaw channels status --json
{
  "accountId": "dross-pa",
  "running": true,
  "connected": true,
  "healthState": "healthy",
  "lastInboundAt": "2026-05-13T10:43:10.783Z",
  "lastOutboundAt": "2026-05-13T10:43:14.944Z"
}
  • Observed result after fix: The affected cron jobs no longer use the live WhatsApp direct-chat lane; they run isolated and announce back to the redacted WhatsApp target. A fresh inbound WhatsApp message sent via wacli was received by OpenClaw and OpenClaw sent a WhatsApp reply about four seconds later.
  • What was not tested: The source patch itself was not installed into the running local OpenClaw gateway; the live system was verified by applying the target-state cron-job mitigation that this patch makes future cron creations default to. Android/WhatsApp UI tap-path testing was not performed because the wacli sender path provided a cleaner real inbound WhatsApp smoke test.
  • Before evidence (optional but encouraged):
2026-05-13 11:08:08 BST web-inbound raw inbound body="hi"
2026-05-13 11:08:08 BST web-auto-reply inbound web message correlationId=3BB9F614B18F07BC09E6
2026-05-13 11:08:08 BST gateway/channels/whatsapp/inbound Inbound message <redacted-owner> -> <redacted-pa> (direct, 58 chars)
2026-05-13 11:09:39 BST [typing] TTL exceeded (60000ms), auto-stopping typing indicator

Verification

  • pnpm test src/agents/tools/cron-tool.test.ts (clean worktree on current origin/main): 81 passed.
  • git diff --check -- src/agents/tools/cron-tool.ts src/agents/tools/cron-tool.test.ts

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. agents Agent runtime and tooling size: XS proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 13, 2026
@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 12:17 AM ET / 04:17 UTC.

Summary
The branch changes cron.add session-key stamping and prompt snapshots, updates cron-tool tests, and removes the WhatsApp audio-decode dependency and lockfile resolution.

PR surface: Source +14, Tests +15, Config -1, Other -101. Total -73 across 10 files.

Reproducibility: yes. at source level: current main defaults omitted-target systemEvent cron jobs to main and then stamps the resolved caller sessionKey when the target is not isolated. I did not rerun the live WhatsApp restart scenario.

Review metrics: 2 noteworthy metrics.

  • Cron Session-Key Invariant: 1 PR assertion conflicts with 1 current-main no-stamp regression. The changed default controls whether scheduled cron work uses cron-owned sessions or live chat/dashboard sessions after catch-up.
  • Plugin Dependency Surface: 1 direct dependency removed; Baileys optional peer resolution pruned. A cron-tool fix should not alter WhatsApp package resolution unless that dependency change is intentional and separately proven.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #81375
Summary: This PR is the open candidate fix for the canonical cron main/systemEvent session-key binding issue; adjacent cron/session-lane work overlaps but does not supersede the remaining bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase onto current main and preserve the existing isolated cron no-stamp behavior.
  • Restore WhatsApp audio-decode package and lockfile entries, or split that dependency change into a separate proven PR.
  • [P1] Add redacted runtime logs, terminal output, or equivalent proof from a gateway running this patched branch.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body includes redacted logs from manually editing live cron jobs to the target state, but it explicitly says the patched source was not installed in the running gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The branch conflicts with current main, so the final merge result needs a rebase and fresh review before session-key behavior can be trusted.
  • [P1] If the PR's isolated agentTurn behavior is preserved, scheduled work can again inherit live chat or dashboard session keys and collide with user sessions.
  • [P1] The WhatsApp audio-decode package and Baileys peer resolution are removed without dependency-contract or media proof in a cron-focused PR.
  • [P1] The supplied real-world logs show a manually edited target-state mitigation, not OpenClaw running this patched branch.

Maintainer options:

  1. Rebase And Narrow The Cron Fix (recommended)
    Rebase onto current main, keep isolated cron jobs free of caller sessionKey, restore unrelated dependency metadata, and add patched-gateway proof before merge.
  2. Split The WhatsApp Dependency Change
    If removing audio-decode is intentional, move that package and lockfile change to a separate WhatsApp dependency PR with Baileys and media-handling proof.
  3. Replace The Stale Branch
    If the contributor branch cannot be reconciled cleanly, open a narrow replacement PR for the cron-only fix while crediting this work and keeping the linked issue as canonical.

Next step before merge

  • [P1] Human handling is needed because the branch conflicts and the remaining proof must come from a contributor-run gateway with this patched source.

Security
Needs attention: Needs attention because a cron-focused PR removes WhatsApp audio-decode package and lockfile metadata without dependency-contract or media proof.

Review findings

  • [P1] Preserve isolated cron session isolation — src/agents/tools/cron-tool.ts:826
  • [P1] Restore the WhatsApp audio-decode dependency — extensions/whatsapp/package.json:11
Review details

Best possible solution:

Land a rebased cron-only fix that suppresses caller sessionKey for implicit main/systemEvent jobs, preserves isolated cron-owned sessions, restores WhatsApp dependency metadata, and includes redacted proof from a gateway running the patched branch.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main defaults omitted-target systemEvent cron jobs to main and then stamps the resolved caller sessionKey when the target is not isolated. I did not rerun the live WhatsApp restart scenario.

Is this the best way to solve the issue?

No as submitted. The main/systemEvent guard is the right direction, but the branch must preserve current isolated-session behavior, restore unrelated WhatsApp dependency metadata, rebase cleanly, and prove the patched source in a real gateway.

Full review comments:

  • [P1] Preserve isolated cron session isolation — src/agents/tools/cron-tool.ts:826
    This branch only suppresses main/systemEvent stamping and adds a test expecting isolated agentTurn jobs to inherit the caller WhatsApp sessionKey. Current main deliberately omits caller sessionKey for isolated cron adds after fix(cron): honor isolated sessionTarget and fail missing cron.remove id #86234, so rebase this PR so isolated jobs stay cron-owned and only implicit main/systemEvent stamping is suppressed.
    Confidence: 0.91
  • [P1] Restore the WhatsApp audio-decode dependency — extensions/whatsapp/package.json:11
    This cron fix also removes the WhatsApp plugin's audio-decode dependency and prunes the lockfile, but Baileys still declares audio-decode as an optional dependency and current package metadata resolves it. Restore the dependency files or split this into a separate proven WhatsApp dependency PR.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5a5913a98b03.

Label changes

Label justifications:

  • P1: The PR targets a real agent/channel workflow where cron catch-up can occupy a live chat lane and delay or suppress user replies.
  • merge-risk: 🚨 compatibility: The diff changes persisted cron session-key behavior and removes WhatsApp plugin dependency metadata used by current package resolution.
  • merge-risk: 🚨 session-state: The diff controls which session key cron jobs store and run under, including live chat keys versus cron-owned isolated keys.
  • merge-risk: 🚨 message-delivery: The target bug and the stale isolated-session behavior can delay, suppress, or misroute chat-visible cron and inbound message delivery.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes redacted logs from manually editing live cron jobs to the target state, but it explicitly says the patched source was not installed in the running gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +14, Tests +15, Config -1, Other -101. Total -73 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 1 15 1 +14
Tests 7 32 17 +15
Docs 0 0 0 0
Config 1 0 1 -1
Generated 0 0 0 0
Other 1 2 103 -101
Total 10 49 122 -73

Security concerns:

  • [medium] Unrelated dependency and lockfile deletion — extensions/whatsapp/package.json:11
    The branch removes audio-decode from the WhatsApp plugin package and prunes lockfile entries even though Baileys declares that optional runtime dependency and current package metadata resolves it.
    Confidence: 0.88

What I checked:

Likely related people:

  • vignesh07: Authored the commit that added cron.add caller sessionKey stamping and cron timer routing by job.sessionKey. (role: feature-history contributor; confidence: high; commits: f988abf202e3; files: src/agents/tools/cron-tool.ts, src/cron/normalize.ts, src/cron/service/timer.ts)
  • stevenepalmer: Authored the merged cron fix that established explicit isolated cron adds should not inherit caller sessionKey. (role: adjacent invariant contributor; confidence: high; commits: 6709f4efe56c; files: src/agents/tools/cron-tool.ts, src/agents/tools/cron-tool.test.ts, src/gateway/server-methods/cron.ts)
  • steipete: Authored the current WhatsApp audio-decode dependency alignment and committed the earlier cron session-key routing change. (role: recent WhatsApp dependency contributor; confidence: high; commits: 7c5a412b38d2, f988abf202e3; files: extensions/whatsapp/package.json, pnpm-lock.yaml, src/agents/tools/cron-tool.ts)
  • joshavant: Recently changed cron caller identity and agent/session scoping on the same tool and gateway cron surfaces. (role: recent cron scoping contributor; confidence: medium; commits: cee2aca40912; files: src/agents/tools/cron-tool.ts, src/gateway/server-methods/cron.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@VishalJ99
VishalJ99 marked this pull request as ready for review May 13, 2026 11:30
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Changes Detected

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/whatsapp/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile or workspace dependency policy changes are present.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web scripts Repository scripts size: S and removed size: XS labels May 13, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 28, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 28, 2026
@clawsweeper

clawsweeper Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg: 🥚 incubating until a hatchable PR state. Hatch with @clawsweeper hatch when eligible.

Rules and details

Hatchability:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

About:

  • Eggs appear after real-behavior proof passes. They are collectible flavor only.
  • Review momentum changes the shell state: follow-up work warms it, re-review makes it wobble, and a clean final review lets it hatch.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 29, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 29, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label May 29, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 19, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict low_signal_unmergeable_pr (decision packet 2026-07-01T04:17:51.748Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: whatsapp-web Channel integration: whatsapp-web dependencies-changed PR changes dependency-related files merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron tool can bind systemEvent jobs to live chat lanes and delay inbound replies after restart

2 participants