I have a character that is a spy, and part of their job is sneaking around and getting into places without being noticed. However, in order to have conflict in the plot, have characters interacting to build character development, and the like, I need to have the protagonists and antagonists interact. If the spy character successfully Metal Gear Solid's their way through the entire plot, the antagonist will never even know they are there.
But to have the characters interact would mean that someone would have to notices the spy character, which in turn makes the spy character seem incompetent because they keep getting noticed or caught, and the character is supposed to be portrayed as good at their job. E.g., in one scene I have the character trying to sneak into a meeting and they get caught by a patrol which leads to a fight that furthers the plot. How can I make this happen without making the spy seem to be bad at espionage?
I know some spies like James Bond are frequently depicted as getting captured or getting spotted by guards, but I'm not sure how the narrative is able to counteract that and portray them as competent (I know externally audiences generally do regard characters like James Bond as good at their job, I just don't know the narrative techniques to achieve that).
How would I go about making a spy character seem competent while still allowing for conflict in the plot?