Automatic interruption function or asking the user if they need to interrupt the current task

During my experience with the system, I observed that when utilizing the agent for executing lengthy tasks, the context tends to become excessively long after a certain duration. This often leads to a noticeable decline in the quality of the output results. To address this issue, I propose implementing a mechanism to monitor the remaining context at each automatic task execution. The system could then either prompt the user to decide whether to interrupt the current task or automatically terminate the task when the context is insufficient to support the next automated step. I believe this approach would significantly enhance the quality and efficiency of each agent-driven task.