@@ -14,6 +14,11 @@ import type { OriginatingChannelType } from "../templating.js";
1414import { isSilentReplyText , SILENT_REPLY_TOKEN } from "../tokens.js" ;
1515import type { GetReplyOptions , ReplyPayload } from "../types.js" ;
1616import { resolveRunAuthProfile } from "./agent-runner-utils.js" ;
17+ import {
18+ resolveOriginAccountId ,
19+ resolveOriginMessageProvider ,
20+ resolveOriginMessageTo ,
21+ } from "./origin-routing.js" ;
1722import type { FollowupRun } from "./queue.js" ;
1823import {
1924 applyReplyThreading ,
@@ -231,9 +236,10 @@ export function createFollowupRunner(params: {
231236 }
232237 return [ { ...payload , text : stripped . text } ] ;
233238 } ) ;
234- const replyToChannel =
235- queued . originatingChannel ??
236- ( queued . run . messageProvider ?. toLowerCase ( ) as OriginatingChannelType | undefined ) ;
239+ const replyToChannel = resolveOriginMessageProvider ( {
240+ originatingChannel : queued . originatingChannel ,
241+ provider : queued . run . messageProvider ,
242+ } ) as OriginatingChannelType | undefined ;
237243 const replyToMode = resolveReplyToMode (
238244 queued . run . config ,
239245 replyToChannel ,
@@ -256,10 +262,18 @@ export function createFollowupRunner(params: {
256262 sentMediaUrls : runResult . messagingToolSentMediaUrls ?? [ ] ,
257263 } ) ;
258264 const suppressMessagingToolReplies = shouldSuppressMessagingToolReplies ( {
259- messageProvider : queued . originatingChannel ?? queued . run . messageProvider ,
265+ messageProvider : resolveOriginMessageProvider ( {
266+ originatingChannel : queued . originatingChannel ,
267+ provider : queued . run . messageProvider ,
268+ } ) ,
260269 messagingToolSentTargets : runResult . messagingToolSentTargets ,
261- originatingTo : queued . originatingTo ,
262- accountId : queued . originatingAccountId ?? queued . run . agentAccountId ,
270+ originatingTo : resolveOriginMessageTo ( {
271+ originatingTo : queued . originatingTo ,
272+ } ) ,
273+ accountId : resolveOriginAccountId ( {
274+ originatingAccountId : queued . originatingAccountId ,
275+ accountId : queued . run . agentAccountId ,
276+ } ) ,
263277 } ) ;
264278 const finalPayloads = suppressMessagingToolReplies ? [ ] : mediaFilteredPayloads ;
265279
0 commit comments