feat: add previously interrupted message to current

ref: N25B-452
This commit is contained in:
2026-01-19 14:47:11 +01:00
parent 04d19cee5c
commit c0789e82a9

View File

@@ -35,6 +35,7 @@ class LLMAgent(BaseAgent):
self.history = []
self._querying = False
self._interrupted = False
self._interrupted_message = ""
self._go_ahead = asyncio.Event()
async def setup(self):
@@ -82,11 +83,14 @@ class LLMAgent(BaseAgent):
self._interrupted = True # interrupt the previous processing
await self._go_ahead.wait() # wait until we get the go-ahead
message.text = f"{self._interrupted_message} {message.text}"
self._go_ahead.clear()
self._querying = True
full_message = ""
async for chunk in self._query_llm(message.text, message.norms, message.goals):
if self._interrupted:
self._interrupted_message = message
self.logger.debug("Interrupted processing of previous message.")
break
await self._send_reply(chunk)
@@ -105,6 +109,7 @@ class LLMAgent(BaseAgent):
)
await self._send_full_reply(full_message)
self._go_ahead.set()
self._interrupted = False
async def _send_reply(self, msg: str):