Agar stepped down from his Rhinos role in March, following a fifth defeat in six games.
The ex-Hull and Wakefield Trinity coach previously had a spell at the helm of the French national side and will join Samoa team boss Matt Parish’s staff for the global tournament.
Samoa face England in the opening match of the men’s competition at Newcastle’s St James’ Park on Saturday, October 15.
They take on Greece in Doncaster - where the squad will have their training base - a week later before a final group game against France in Warrington on Sunday, October 30.
That will see Agar go up against Sean Long, who was one of his assistant-coaches at Leeds.
Long, who remains on Rhinos’ backroom staff under new boss Rohan Smith, is an assistant-coach with France, under ex-Catalans Dragons chief Laurent Frayssinous.
Penrith Panthers assistant-coach Andrew Webster and ex-Samoa captain Frank Pritchard will also join Parish’s staff.
Former Manly Sea Eagles coach Geoff Toovey - who replaced Rohan Smith in the Bradford Bulls hot seat for the 2017 season - will continue as another of Parish’s assistants.
Samoa have a warm-up game against Cook Islands in Campbelltown, outside Sydney, next month.