WASHINGTON — Gina Haspel was trying to brief President Trump early in her tenure as the C.I.A. director, but he appeared distracted. Houseflies buzzing around the Oval Office were drawing his attention, and ire.

On returning to her office, Ms. Haspel found a solution, according to two officials familiar with the episode, and sent it to Mr. Trump: flypaper.

Ms. Haspel, who will give only her second public speech as director on Thursday, has taken the reins of the nation’s premier intelligence agency at a difficult moment in its 71-year history, under pressure from a president often publicly dismissive of its conclusions and a White House that views national security professionals with deep skepticism.

As she approaches her first full year on the job, Ms. Haspel has proved an adept tactician, charming the president with small gestures and talking to him with a blend of a hardheaded realism and appeals to emotion. A career case officer trained to handle informants, she has relied on the skills of a spy — good listening, empathy and an ability to connect — to make sure her voice is heard at the White House.