fix(routing): handle cross-provider messages in collect mode

When queued messages come from different providers (Slack + Telegram),
process them individually instead of collecting into a single prompt.
This ensures each reply routes back to its originating provider.

- Add hasCrossProviderItems() to detect multi-provider queues
- Skip collect mode when cross-provider detected
- Preserve originatingChannel/originatingTo when collecting same-provider
This commit is contained in:
Josh Lehman
2026-01-06 13:43:10 -08:00
committed by Peter Steinberger
parent 2d67ec5bfa
commit 5414da9fd4
2 changed files with 59 additions and 3 deletions

View File

@@ -82,9 +82,13 @@ export function createFollowupRunner(params: {
cfg: queued.run.config,
});
if (!result.ok) {
logVerbose(
`followup queue: route-reply failed: ${result.error ?? "unknown error"}`,
);
// Log error and fall back to dispatcher if available.
const errorMsg = result.error ?? "unknown error";
logVerbose(`followup queue: route-reply failed: ${errorMsg}`);
// Fallback: try the dispatcher if routing failed.
if (opts?.onBlockReply) {
await opts.onBlockReply(payload);
}
}
} else if (opts?.onBlockReply) {
await opts.onBlockReply(payload);