What does the Bhagavad Gita mean when it says caste is based on Gunas? Does it mean trained, external behavior, or genetic predisposition?
According to the various Smritis, Vedas, and ancient Vedic scholars and commentators, the word Guna in the Gita verse means genetic predisposition.
For reference, Gita verse 18.41 says:
The duties of the Brāhmaṇas, Kṣatriyas; Vaishyas and the Śūdras O Arjuna, are distinctly
divided according to their inherent dispositions.
The medieval Sri Vaishnava Vedic scholar, Ramanujacharya, has commented on that verse as follows:
The character of Brāhmaṇas, Kṣatriyas, Vaishyas, and Śūdras arise from their various
inherent dispositions. In other words their past Karma is the cause of their being born in
a specific caste. The dominant Guna is the result of such
Karma.
The Sattva-guna becomes dominant in the character of the Brāhmaṇa
through the suppression of the qualities of Rajas and Tamas.
In the Kṣatriya the dominant quality is Rajas through the suppression
of Sattva and Tamas.
The Tamo-guna becomes the inherent nature of the Vaishya, becoming
slightly dominant by suppressing Sattva and Rajas.
While in the Śūdra the Tamo Guna is much more dominant.
Obligations and duties are assigned to them by the Scriptures
according to their inherent dispositions. For the Shastras assume that
the Brāhmaṇas and the others
Next the question is, what does it mean by "inherent disposition"? Does this mean genetic predisposition or trained behavior?
According to the medieval Sri Vaishnava Vedic scholar, Vedanta Desikan, it means genetic predisposition acquired at birth:
Owing to the preponderance of such qualities as sattvam, in the body, a man is entitled to be called a Brahmin, a kshatriya, and the like. But this is different from the praise of being a Brahmin that is often given in certain passages, owing to the quality of sattvam and the like in the mind. The qualities of caste pertaining to the body which are due to the special qualities of the body arise even at the time of birth and remain until death. The Brahmin-like qualities which arise out of the preponderance of sattvam in the mind may be present in all castes. In Prahlada [an Asura], they are present even at the time of birth. In others, owing to such specific causes as contact with acharyas, these mental qualities are acquired later.
If in a Brahmin are found such features as are incongruous with his caste, it will meet with censure that, born in a caste which is declared by the shastras as being capable of such virtues as self restraint and mental serenity, he lapsed from the condition suitable to him. - page 306, Rahasya Traya Sara
As for the next question:
What does the word karma mean in that verse?
The word "karma" in verse 4.13:
The [social] system of four castes was generated by Me according to division of Gunas and Karma. Though I am the generator, know Me as a non-agent and immutable.
means work (karma) that the shastras prescribe to people of different castes based on their guna:
The whole universe from Brahma down to a clump of grass, together with the system of
four social divisions divided according to the Gunas and by actions [karma] like self-control in
accordance with the Gunas, was projected into being by Krishna. - Ramanujacharya's Gita Bhashya
However, in verse 18.41, karma means something else. It means actions done in previous lives that cause you to be born in a particular caste:
The character of Brāhmaṇas, Kṣatriyas, Vaishyas, and Śūdras arise from their various
inherent dispositions. In other words their past Karma is the cause of their being born in
a specific caste. The dominant Guna is the result of such
Karma. - Ramanujacharya's Gita Bhashya
This is in accordance with what the Smritis say. According to the Manusmriti, your future birth in a particular caste or species will be determined by the kind of mental guna you have cultivated and expressed in your life.
Manu 12.40 - Those partaking of ‘Sattva’ reach the state of the gods, those endowed with ‘Rajas,’ the state of men, and those characterised by ‘Tamas,’ the state of beasts; such is the threefold migratory state.
Inanimate beings, worms, insects, fishes, snakes, tortoise, cattle and wild animals,—represent the lowest state due to the quality of ‘Tamas.’—(42)
Elephants, horses, despised Śūdras, Mlecchas, lions, tigers and
boars—represent the middling state due to the quality of ‘Tamas.’—(43)
Cāraṇas, Suparṇas, hypocritical men, Rākṣasas, and Piśācas—represent
the highest state among those partaking of the quality of
‘Tamas.’—(44)
So if your consciousness is like that of an animal, very tamasic, you will be born as an animal. Whereas, on the other hand, a Shudra who is naturally tamasic by genetic predisposition, serves Brahmanas and cultivates a sattvic consciousness, will be reborn as a Brahmana or Deva:
Manu 12.48 - Ascetics and hermits, Brāhmaṇas, celestial beings, lunar asterisms, and Daityas represent the first state partaking of ‘Sattva.’