Skip to content

fix(cron): skip delivery target resolution when delivery mode is none#34518

Open
kaxo-io wants to merge 3 commits intoopenclaw:mainfrom
kaxo-io:fix/delivery-mode-none-channel-last
Open

fix(cron): skip delivery target resolution when delivery mode is none#34518
kaxo-io wants to merge 3 commits intoopenclaw:mainfrom
kaxo-io:fix/delivery-mode-none-channel-last

Conversation

@kaxo-io
Copy link
Copy Markdown

@kaxo-io kaxo-io commented Mar 4, 2026

Summary

Why

resolveDeliveryTarget() was being called unconditionally, which could still resolve/fallback channel routing even when cron delivery was disabled. That allowed channel:last paths to leak into runtime routing and surface as message delivery failures.

Tests

  • npx vitest run src/cron/isolated-agent/run.delivery-mode-none-channel-last.test.ts src/cron/delivery.test.ts
  • npx vitest run src/cron/isolated-agent/run.*.test.ts

Fixes #30393

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR fixes a bug where resolveDeliveryTarget() was called unconditionally in runCronIsolatedAgentTurn, allowing the channel:last fallback path to leak into routing even when delivery.mode was "none". The fix guards the call behind deliveryRequested and substitutes a typed ok: false stub so messageChannel and agentAccountId remain undefined in the embedded agent invocation when delivery is disabled.

Key changes:

  • run.ts: resolveDeliveryTarget is now only awaited when deliveryRequested === true; otherwise a minimal { ok: false, mode: "implicit", error } value satisfies the DeliveryTargetResolution type without triggering channel lookups
  • run.test-harness.ts: resolveCronDeliveryPlanMock and resolveDeliveryTargetMock are now exported as independently controllable mocks; the old hardcoded "discord" channel return is removed and replaced with a correct no-delivery default
  • New regression test: Directly covers the delivery.mode=none + channel:last scenario from issue Bug: Cron delivery mode 'none' + channel 'last' causes Message failed #30393, asserting resolveDeliveryTarget is never called and messageChannel passed to the embedded agent is undefined

Confidence Score: 5/5

  • This PR is safe to merge — the fix is minimal, well-scoped, and directly tested against the regression scenario.
  • The change is a targeted conditional guard around a single function call. The stub value correctly satisfies the DeliveryTargetResolution discriminated union type. All downstream consumers of resolvedDelivery are either already gated on deliveryRequested or operate safely with undefined channel/accountId fields. The new regression test and the refactored harness improve confidence that the fix works and that future changes to delivery logic won't regress silently.
  • No files require special attention.

Last reviewed commit: 58a2f2d

@kaxo-io kaxo-io force-pushed the fix/delivery-mode-none-channel-last branch from 0313d5c to e378959 Compare March 4, 2026 18:14
@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 Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Cron delivery mode 'none' + channel 'last' causes Message failed

1 participant