For reference, the description of the Bag of Tricks says, in part (DMG, p. 154):
You can use an action to pull the fuzzy object from the bag and throw it up to 20 feet. When the object lands, it transforms into a creature you determine by rolling a d8 and consulting the table that correspond's to the bag's color. See the Monster Manual for the creature's statistics.
The creature is friendly to you and your companions, and it acts on your turn. You can use a bonus action to command how the creature moves and what action it takes on its next turn, or to give it general orders, such as to attack your enemies. In the absence of such orders, the creature acts in a fashion appropriate to its nature.
How long do creatures from a Bag of Tricks last?