Francois Louw's last-minute try continued Bath's 100% winning record in the Challenge Cup with victory at Agen.
Agen's Benjamin Petre and Michael Claassens of Bath exchanged tries as the French hosts led 10-8 at half-time.
Kyle Eastmond and Stephen Donald went over for the visitors after the break, while Agen's Raphael Lagarde took his tally to 17 points with the boot.
The lead changed hands five times after half-time but Louw's late try proved decisive for Bath.
Lagarde's 71st-minute penalty had given the hosts a 22-20 advantage which looked like being enough before Louw went over.
Bath top Pool 4 with 10 points from two matches after picking up bonus points in both of their Challenge Cup victories.
Agen: Bataille; Tagotago, Petre, Lamoulie, Agulla; Lagarde, Bales; Schwalger, Telefoni, Afatia, Bastien, Lagrange, Erbani, Julien, Fonua.
Replacements: Janaudy for Telefoni (8), Demotte for Bastien (48), Cabarry for Schwalger (52), Fono for Fonua (60), Roux for Erbani (61), Dupuy for Bales (72), Edmond-Samuel for Bataille (77).
Not Used: Falefa.
Sin Bin: Lagrange (75).
Bath: Abendanon; Eastmond, Hipkiss, Williams, Biggs; Donald, Claassens; James, Mears, Wilson, Day, Attwood, Louw (capt), Skuse, Skirving.
Replacements: Perenise for Wilson (66), McMillan for Claassens (72).
Not Used: Tanner, Catt, Mercer, Ovens, Vesty, Woodburn.
Referee: Neil Hennessey (WRFU).