openclaw - ✅(Solved) Fix Cron isolated Discord announce can inherit poisoned deliveryContext and fail with Unknown Channel [1 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63733Fetched 2026-04-10 03:41:59
View on GitHub
Comments
3
Participants
3
Timeline
5
Reactions
0
Timeline (top)
commented ×3cross-referenced ×1referenced ×1

Cron-owned isolated jobs with explicit Discord announce delivery can resolve to a poisoned delivery context and fail with Unknown Channel even when the cron job definition itself is correct.

In this case, a job configured to announce to Discord DM target user:<redacted> repeatedly re-acquired deliveryContext: {"to":"heartbeat"} and finished deliveryStatus: not-delivered.

Error Message

The failing post-restart canary run showed:

  • cron job: 36abfb0a-44b5-4c7d-822f-ade7d9db9435
  • run session: 3c9ab8ba-5d20-4be7-8fed-2faf34853bf4
  • delivered: false
  • deliveryStatus: not-delivered

Root Cause

Cron-owned isolated jobs with explicit Discord announce delivery can resolve to a poisoned delivery context and fail with Unknown Channel even when the cron job definition itself is correct.

In this case, a job configured to announce to Discord DM target user:<redacted> repeatedly re-acquired deliveryContext: {"to":"heartbeat"} and finished deliveryStatus: not-delivered.

Fix Action

Fixed

PR fix notes

PR #63802: fix(cron): clear poisoned system-event deliveryContext from isolated session (#63733)

Description (problem / solution / changelog)

Summary

Fixes #63733

Root Cause

When a heartbeat or cron-event run executes under the same session key as an isolated cron job, it can write a poisoned deliveryContext (e.g. {to: "heartbeat"}) into the shared session store.

If the isolated cron job later reuses that session (isNewSession=false), it inherits the poisoned context and its announce delivery fails with Unknown Channel — even after clean gateway restarts.

The existing cleanup code only cleared deliveryContext when isNewSession=true, leaving reused sessions vulnerable to this contamination.

Fix

resolveCronSession now detects a system-event delivery context (to === "heartbeat", "cron-event", or "exec-event") via the new isSystemDeliveryContext helper, and clears it unconditionally — just as it would for a new session.

Legitimate delivery routing state (e.g. a real Slack channel ID channel:C0XXXXXXXXX) is preserved unchanged.

Testing

Added a regression test covering the poisoned-context scenario. All 11 session tests pass.

Changed files

  • src/cron/isolated-agent/session.test.ts (modified, +27/-0)
  • src/cron/isolated-agent/session.ts (modified, +25/-2)
RAW_BUFFERClick to expand / collapse

Summary

Cron-owned isolated jobs with explicit Discord announce delivery can resolve to a poisoned delivery context and fail with Unknown Channel even when the cron job definition itself is correct.

In this case, a job configured to announce to Discord DM target user:<redacted> repeatedly re-acquired deliveryContext: {"to":"heartbeat"} and finished deliveryStatus: not-delivered.

Environment

  • OpenClaw 2026.4.8 (9ece252)
  • Host: macOS
  • Gateway restarted cleanly during repro
  • Discord delivery target format: channel=discord, to=user:<redacted>

Why this looks like a product bug, not misconfiguration

I checked the current docs before filing this:

  • cron docs say isolated jobs plus announce delivery are the intended pattern for report-style/background work
  • Discord docs say outbound targets should use explicit prefixes like user:<id> or channel:<id>
  • troubleshooting docs say to verify cron runs, delivery target, auth, and logs

The setup matches that guidance. The failure persisted after job normalization, job recreation, and a clean gateway restart.

Minimal repro story

  1. Create or normalize a cron job to use:
    • sessionTarget: isolated
    • delivery.mode: announce
    • delivery.channel: discord
    • delivery.to: user:<redacted>
    • delivery.bestEffort: true
  2. Run the job and inspect cron runs plus session state.
  3. Observe delivery failure with:
    • delivery payload failed (bestEffort): Unknown Channel
  4. Restart the gateway cleanly.
  5. Force one bounded rerun.
  6. Observe the same failure again.

Observed behavior

The failing post-restart canary run showed:

  • cron job: 36abfb0a-44b5-4c7d-822f-ade7d9db9435
  • run session: 3c9ab8ba-5d20-4be7-8fed-2faf34853bf4
  • delivered: false
  • deliveryStatus: not-delivered

Gateway log:

  • [cron:36abfb0a-44b5-4c7d-822f-ade7d9db9435] delivery payload failed (bestEffort): Unknown Channel

Session-context symptom:

  • the canary base cron session briefly rebuilt cleanly after restart, then re-acquired:
    • deliveryContext: {"to":"heartbeat"}

That poisoned context is inconsistent with the explicit Discord announce target.

Expected behavior

Cron-owned isolated jobs with explicit Discord announce delivery should honor the configured Discord target and should not inherit or reapply unrelated heartbeat delivery context.

Current best hypothesis

This looks like a deterministic cron session-context lookup / inheritance / precedence bug in the agent:main:cron:* path, not just stale in-memory state.

Reason:

  • job definition is correct
  • recreated jobs still failed
  • fresh gateway restart did not clear the behavior
  • poisoned context was re-applied after restart

Extra notes

Independent read-only review by a validator lane and a thinker lane both converged on the same conclusion class:

  • not well explained by simple stale RAM alone
  • better explained by deterministic polluted-context precedence / cron session-context resolution

Offer

If useful, I can provide a sanitized evidence bundle structure and exact pre/post restart session-context diffs.

extent analysis

TL;DR

The most likely fix for the issue is to investigate and resolve the cron session-context lookup or inheritance bug in the agent:main:cron:* path.

Guidance

  • Verify that the cron job definition is correct and the Discord target is properly configured, as the issue seems to be related to the session-context resolution.
  • Check the gateway logs for any errors or warnings related to the cron session-context lookup or inheritance.
  • Try to reproduce the issue with a minimal setup to isolate the problem and provide more detailed logs or evidence.
  • Consider providing a sanitized evidence bundle structure and exact pre/post restart session-context diffs to help with further investigation.

Notes

The issue seems to be related to a deterministic bug in the cron session-context resolution, and not just a simple misconfiguration or stale in-memory state. The fact that the issue persists after a clean gateway restart and job recreation suggests a more complex problem.

Recommendation

Apply a workaround by trying to reset or clear the cron session-context before running the job, if possible, to see if it resolves the issue. This could involve modifying the job definition or the gateway configuration to avoid the poisoned context.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Cron-owned isolated jobs with explicit Discord announce delivery should honor the configured Discord target and should not inherit or reapply unrelated heartbeat delivery context.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING