This article seems to capture some key ideas in when we use definite and indefinite articles, it's rather more subtle than just how specific we are being. An extract:
A/an
This is used when the noun that we wish to refer to is unknown to our listener/reader or is not part of the common ground that we share. It is most often used to introduce new information.
I saw a UFO yesterday.
Tell me a story.
Have you ever seen a tornado?
The
By using the, we are signalling to our listener that s/he is very likely to know what we are referring to and that the context of our conversation should help them to identify this. We can use the, therefore, to
refer backwards to something that we have already mentioned
refer forwards to something that we can take for granted will happen
refer to our common ground or shared knowledge
In your examples consider what happens if we change indefinite to definite:
This is a cake which she made yesterday
This is the cake which she made yesterday
In both cases we are referring to (probably pointing to) a specific cake. The difference in meaning is that in the second case we state that of the cakes we are considering she only made one cake yesterday.
I'm going to skip the history example because that gets really tricky, a history and the history give rather different meanings to the word history
The banana example would be understood
I ate 3 bananas brought by you yesterday
If we add a definite article
I ate the 3 bananas brought by you yesterday
we imply that the listener brought exactly 3 bananas. Note that in both cases we are actually being quite specific about the bananas we ate; we are talking about specific bananas, but the use of the adds to the picture.