nudge + move queue extension

frdel committed Jan 30, 2026 at 12:40 UTC 3d8cc2a6201beb93ef9892832df8bd2621396998
3 files changed +19 -9
agent.py
+5 -1
@@ -225,7 +225,7 @@ class AgentContext:
225 def nudge(self):
226 self.kill_process()
227 self.paused = False
228 - self.task = self.run_task(self.get_agent().monologue)
228 + self.task = self.communicate(UserMessage(self.agent0.read_prompt("fw.msg_nudge.md")))
229 return self.task
230
231 def get_agent(self):
@@ -277,6 +277,10 @@ class AgentContext:
277 superior = agent.data.get(Agent.DATA_NAME_SUPERIOR, None)
278 if superior:
279 response = await self._process_chain(superior, response, False) # type: ignore
280 +
281 + # call end of process extensions
282 + await self.get_agent().call_extensions("process_chain_end", data={})
283 +
284 return response
285 except Exception as e:
286 agent.handle_critical_exception(e)
prompts/fw.msg_nudge.md new
+5
@@ -0,0 +1,5 @@
1 +```json
2 +{
3 + "system_message": "Nudged - continue",
4 +}
5 +```
\ No newline at end of file
python/extensions/process_chain_end/_50_process_queue.py renamed
+9 -8
@@ -1,7 +1,7 @@
1 import asyncio
2 from python.helpers.extension import Extension
3 from python.helpers import message_queue as mq
4 -from agent import LoopData
4 +from agent import AgentContext, Agent, LoopData
5
6
7 class ProcessQueue(Extension):
@@ -20,14 +20,15 @@ class ProcessQueue(Extension):
20 # This allows current monologue to fully complete first
21 asyncio.create_task(self._delayed_send(context))
22
23 - async def _delayed_send(self, context):
23 + async def _delayed_send(self, context: AgentContext):
24 """Wait for task to complete, then send next queued message."""
25 - # Small delay to ensure monologue fully completes
26 - await asyncio.sleep(0.1)
25
28 - # Wait for current task to finish
29 - while context.task and context.task.is_alive():
26 + # Wait for current task to finish, but no more than 1 minute to prevent hanging tasks
27 + total_wait = 0
28 + while context.is_running() and total_wait < 60:
29 await asyncio.sleep(0.1)
30 + total_wait += 0.1
31
32 - # Send next queued message
33 - mq.send_next(context)
32 + # Send next queued message if task is not running
33 + if not context.is_running():
34 + mq.send_next(context)