#11216: Fix nightly failures: cron webchat delivery result + media cleanup timing
docs
app: web-ui
gateway
cli
agents
stale
Cluster:
Cron Job Enhancements
Fixes two nightly test failures:
1) cron isolated-agent: explicit delivery.channel=webchat should not hard-fail job status; return status=ok with deliveryResult error, and preserve webchat as messageChannel.
2) media server: cleanup-after-send timing could flake; remove delay so cleanup happens immediately after response finish.
Manual verification:
- pnpm vitest run src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts
- pnpm vitest run src/media/server.test.ts
Notes:
- WebChat is still not deliverable via outbound providers; this makes cron semantics more ergonomic/consistent for explicit channel requests.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adjusts cron isolated-agent delivery semantics so that explicitly requesting `delivery.channel=webchat` doesn’t hard-fail the cron job; instead it returns `status=ok` while surfacing an explicit `deliveryResult` error and preserving `webchat` as the agent `messageChannel`. It also tweaks media server cleanup to remove a small post-response delay to avoid timing flakes in tests/CI.
The changes fit into the existing outbound routing/delivery pipeline by extending `resolveDeliveryTarget` and `runCronIsolatedAgentTurn` to separate “agent channel selection” from “outbound deliverability”, and by making response-finish cleanup deterministic for the media route.
<h3>Confidence Score: 3/5</h3>
- This PR is close to safe to merge, but there is a logical bug in the webchat delivery-target special-case that prevents preserving an explicit `to` and can cause incorrect delivery outcomes.
- Core changes are small and targeted, but the new webchat special-case currently calls `resolveOutboundTarget` with `channel=webchat`, which is guaranteed to fail and defeats the intent of preserving the explicit delivery target. Fixing that should make the cron semantics change behave as described; the media cleanup timing tweak is low risk.
- src/cron/isolated-agent/delivery-target.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#13638: fix: pass delivery context to cron isolated agent subagents
by dario-github · 2026-02-10
83.1%
#13383: fix(cron): route text-only payloads through direct delivery
by Masha-L · 2026-02-10
82.6%
#6522: fix(cron): deliver original message when agent response is heartbea...
by sidmohan0 · 2026-02-01
82.4%
#23086: fix(cron): surface channel resolution error for isolated sessions w...
by hydro13 · 2026-02-22
82.1%
#16996: fix(cron): parse Telegram topic target format for announce delivery
by Glucksberg · 2026-02-15
80.8%
#6007: fix(cron): auto-map agentId to accountId for Discord deliveries
by dwfinkelstein · 2026-02-01
80.1%
#8097: fix: auto-convert one-shot reminders for reliable delivery
by Gerrald12312 · 2026-02-03
80.0%
#19767: cron: validate webhook delivery targets on create
by advaitpaliwal · 2026-02-18
78.8%
#21896: fix(cron): disable messaging tool when delivery.mode is none
by lailoo · 2026-02-20
78.3%
#22845: Pass agentDir through cron and followup embedded runs
by seilk · 2026-02-21
77.6%