From Trades to Agg Trades

Hi, I am recently doing research on the trades data, and I am confused about the aggTrades data. Could you plz explain how it works? I know Aggregate trade combines trades with the same price together in a period of time, but sometimes it doesn’t seems like that.

e.g. in Trades
and in aggTrades
here, you can see tradeid 2665741 and 2665742&2665743 don’t aggregate together.

And another example
here, tradeid 2665829 to 2665833 were separate into three records in aggTrades.

So, how the agg actually works? Thank you.

Which symbol is this?

The data is AAVEETH-aggTrades-2022-06-22.csv and AAVEETH-trades-2022-06-22.csv.

And for trades, the columns are:
index id price qty quote_qty time IsBuyerMaker

for AggTrades, the columns are:
index agg_id price qty first_id last_id time IsBuyerMaker

If you go to the official documentation here: binance-spot-api-docs/ at master · binance/binance-spot-api-docs · GitHub

You can see following:

Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.

The “same take order” is the clue here.
There may be many orders sitting at the same price level, a single incoming taker order may match with one or more at the same price level but it may not exhaust all of them.
If it doesn’t exhaust all of them and the price on the book won’t change before next order you would see this scenario.