When using the auxilary "avoir" the past participle's ending agrees both is gender and number with the direct object only when it is placed before the verbs' subject. Here's an example: Le chat a mangé la souris. La souris que le chat a mangée. Here mangé(e) takes an e because la souris is the direct object and is placed before the verb. Since "la souris" is feminine mangé(e) takes the feminin "e" ending.