After coming together with Australia 116 in arrears and only two wickets in hand, tailenders Agar and Cummins showed the batsmen how to bat with a gutsy 49-run stand that ultimately took the tourists to a more respectable total of 217.
Off-spinner Mehidy Hasan, who took 12 wickets at the same venue to script Bangladesh's first test win over England previous year, struck in his second over, sneaking one through the gate to dismiss the rival captain for eight.
Earlier electing to bat, the Mushfiqur Rahim-led Bangladesh posted 260 with Shakib top-scoring with 84.
Matt Renshaw and Peter Handscomb were also subjected to a trial by spin with Mehidy (3-52) and left-arm spinner Shakib Al Hasan (3-54) hunting in tandem on a surface that perfectly suited their craft.
Opener Tamim Iqbal was batting on 30 with nightwatchman Taijul Islam yet to open the account.
However, in the first over after tea, Shakib got Cummins to end the stubborn partnership.
Taylor Swift Announces New Album, Release Date
It's been almost three years since Swift's last album - "1989" - which won the Album of the Year Grammy. Thus, with all of the controversy lately, critics have been quick to call her reputation into question.
But the left-handed Agar frustrated the Bangladesh bowlers during his 97-ball stay at the crease that was laced with 2 fours and a six.
Having challenged Renshaw earlier in the morning, spinner Shakib Al Hasan got his man eventually, with the Queenslander sent on his way for 45 after Soumya juggled catch at slip shortly before lunch.
It means he has five-wicket hauls against all the teams playing the illustrious format, barring newcomers Ireland and Afghanistan, who received their Test statuses only in June.
The Australian spinners, most notably Lyon, had found turn and bounce, but it was Glenn Maxwell who broke the big partnership with his only wicket of the innings when Tamim rocked back and shaped to cut, but succeeded only in lifting a catch to backward point. Lyon was lucky to snare Mehidy, who was given out caught at short-leg despite missing the ball - but by then, Bangladesh were out of reviews.
After bowling out Bangladesh for 265 in the first innings, Steven Smith's young Australian team was dismissed for 217.
Shakib Al Hasan lit up his 50th test with all-round brilliance to help Bangladesh claim a handy first-innings lead. "No matter in what manner the wicket behaves, unless you can bowl in the right areas it is hard to earn success".