diff --git a/src/auto-reply/reply/dispatch-acp.ts b/src/auto-reply/reply/dispatch-acp.ts index 20b700807e2..7f40f253e2d 100644 --- a/src/auto-reply/reply/dispatch-acp.ts +++ b/src/auto-reply/reply/dispatch-acp.ts @@ -345,13 +345,15 @@ export async function tryDispatchAcpReply(params: { params.ctx.OriginatingChannel ?? params.ctx.Surface ?? params.ctx.Provider, ); const explicitDispatchAccountId = normalizeOptionalString(params.ctx.AccountId); + const dispatchChannels = params.cfg.channels as + | Record + | undefined; + const defaultDispatchAccount = + normalizedDispatchChannel == null + ? undefined + : dispatchChannels?.[normalizedDispatchChannel]?.defaultAccount; const effectiveDispatchAccountId = - explicitDispatchAccountId ?? - normalizeOptionalString( - ( - params.cfg.channels as Record | undefined - )?.[normalizedDispatchChannel]?.defaultAccount, - ); + explicitDispatchAccountId ?? normalizeOptionalString(defaultDispatchAccount); const projector = createAcpReplyProjector({ cfg: params.cfg, shouldSendToolSummaries: params.shouldSendToolSummaries,