← Back to PRs

#11216: Fix nightly failures: cron webchat delivery result + media cleanup timing

by DeanoC open 2026-02-07 15:16 View on GitHub →
docs app: web-ui gateway cli agents stale
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