If we assume OP started with 3 pieces of luggage they could be:
1. A bag intended for check in but within the size limits for main carry on
2. A bag of unknown size intended as main carry on
3. A laptop bag within size limits for second carry on
Then, if laptop bag goes inside bag 1 AND bag 2 is too big for 2nd carry on the agent would need to check either bag 1 or bag 2. OP could not take bag 1 (with laptop inside) and bag 2 (greater than second carry limit) as carry on.
If these assumptions are correct then agent was correct.