mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-07 17:22:09 +00:00
nudge + move queue extension
This commit is contained in:
parent
37cafbe86c
commit
3d8cc2a620
3 changed files with 19 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
from python.helpers.extension import Extension
|
||||
from python.helpers import message_queue as mq
|
||||
from agent import LoopData
|
||||
from agent import AgentContext, Agent, LoopData
|
||||
|
||||
|
||||
class ProcessQueue(Extension):
|
||||
|
|
@ -20,14 +20,15 @@ class ProcessQueue(Extension):
|
|||
# This allows current monologue to fully complete first
|
||||
asyncio.create_task(self._delayed_send(context))
|
||||
|
||||
async def _delayed_send(self, context):
|
||||
async def _delayed_send(self, context: AgentContext):
|
||||
"""Wait for task to complete, then send next queued message."""
|
||||
# Small delay to ensure monologue fully completes
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
# Wait for current task to finish
|
||||
while context.task and context.task.is_alive():
|
||||
# Wait for current task to finish, but no more than 1 minute to prevent hanging tasks
|
||||
total_wait = 0
|
||||
while context.is_running() and total_wait < 60:
|
||||
await asyncio.sleep(0.1)
|
||||
total_wait += 0.1
|
||||
|
||||
# Send next queued message
|
||||
mq.send_next(context)
|
||||
# Send next queued message if task is not running
|
||||
if not context.is_running():
|
||||
mq.send_next(context)
|
||||
Loading…
Add table
Add a link
Reference in a new issue