We describe error-related potentials generated while a human user monitors the performance of an external agent and discuss their use for a new type of Brain-Computer Interaction. In this approach, single trial detection of error-related EEG potentials is used to infer the optimal agent behavior by decreasing the probability of agent decisions that elicited such potentials. Contrasting with traditional approaches, the user acts as a critic of an external autonomous system instead of continuously generating control commands. This sets a cognitive monitoring loop where the human directly provides information about the overall system performance that, in turn, can be used for its improvement. We show that it is possible to recognize erroneous and correct agent decisions from EEG (average recognition rates of 75.8% and 63.2%, respectively), and that the elicited signals are stable over long periods of time (from 50 to $>$600 days). Moreover, these performances allow to infer the optimal behavior of a simple agent in a Brain-Computer Interaction paradigm after a few trials.