|
from python.helpers.extension import Extension |
|
from agent import LoopData |
|
from python.extensions.message_loop_end._10_organize_history import DATA_NAME_TASK |
|
import asyncio |
|
|
|
|
|
class OrganizeHistoryWait(Extension): |
|
async def execute(self, loop_data: LoopData = LoopData(), **kwargs): |
|
|
|
|
|
while self.agent.history.is_over_limit(): |
|
|
|
task = self.agent.get_data(DATA_NAME_TASK) |
|
|
|
|
|
if task: |
|
if not task.done(): |
|
self.agent.context.log.set_progress("Compressing history...") |
|
|
|
|
|
await task |
|
|
|
|
|
self.agent.set_data(DATA_NAME_TASK, None) |
|
else: |
|
|
|
self.agent.context.log.set_progress("Compressing history...") |
|
await self.agent.history.compress() |
|
|
|
|