Given a quantum heat engine that operates in a cycle that reaches maximal efficiency for a time-dependent Hamiltonian H(t) of the working substance, with overall controllable driving H(t) = g(t) H, we study the deviation of the efficiency from the optimal value due to a generic time-independent perturbation in the Hamiltonian. We show that for a working substance consisting of two two-level systems, by suitably tuning the interaction, the deviation can be suppressed up to the third order in the perturbation parameter-and thus almost retaining the optimality of the engine.