Error connecting to model provider in case of long chat

This is my second case involving the Gemini agent, but I noticed in the first case that clearing the chat solves the problem, but continued interaction in the chat makes the agent more adapted to the project. Would a solution be possible?