Rebase onto upstream (a4d95fd)
#12
+16
-5
@@ -155,7 +155,8 @@ class AgentLoop:
|
||||
await self.bus.publish_outbound(OutboundMessage(
|
||||
channel=msg.channel,
|
||||
chat_id=msg.chat_id,
|
||||
content=f"Sorry, I encountered an error: {str(e)}"
|
||||
content=f"Sorry, I encountered an error: {str(e)}",
|
||||
metadata=msg.metadata or {},
|
||||
))
|
||||
except asyncio.TimeoutError:
|
||||
continue
|
||||
@@ -283,13 +284,16 @@ class AgentLoop:
|
||||
session.clear()
|
||||
self.sessions.save(session)
|
||||
return OutboundMessage(channel=msg.channel, chat_id=msg.chat_id,
|
||||
content="🐈 New session started. Memory consolidated.")
|
||||
content="🐈 New session started. Memory consolidated.",
|
||||
metadata=msg.metadata or {})
|
||||
if cmd == "/help":
|
||||
return OutboundMessage(channel=msg.channel, chat_id=msg.chat_id,
|
||||
content="🐈 nanobot commands:\n/new — Start a new conversation\n/help — Show available commands\n/quota — Show quota status")
|
||||
content="🐈 nanobot commands:\n/new — Start a new conversation\n/help — Show available commands\n/quota — Show quota status",
|
||||
metadata=msg.metadata or {})
|
||||
if cmd == "/quota":
|
||||
status = self._get_quota_status()
|
||||
return OutboundMessage(channel=msg.channel, chat_id=msg.chat_id, content=status)
|
||||
return OutboundMessage(channel=msg.channel, chat_id=msg.chat_id, content=status,
|
||||
metadata=msg.metadata or {})
|
||||
|
||||
# Update tool contexts
|
||||
message_tool = self.tools.get("message")
|
||||
@@ -309,6 +313,12 @@ class AgentLoop:
|
||||
tz = time.strftime("%Z") or "UTC"
|
||||
time_str = now_dt.strftime("%Y-%m-%d %H:%M (%A)")
|
||||
current_message = f"[Current time: {time_str} {tz}]\n{msg.content}"
|
||||
|
||||
# Prefix hook messages so the agent can identify them
|
||||
hook_source = msg.metadata.get("hook_source") if msg.metadata else None
|
||||
if hook_source:
|
||||
current_message = f'[HOOK MESSAGE from "{hook_source}"]\n{current_message}'
|
||||
|
||||
last_user_ts = None
|
||||
for m in reversed(session.messages):
|
||||
if m.get("role") == "user":
|
||||
@@ -540,7 +550,8 @@ class AgentLoop:
|
||||
return OutboundMessage(
|
||||
channel=origin_channel,
|
||||
chat_id=origin_chat_id,
|
||||
content=final_content
|
||||
content=final_content,
|
||||
metadata=msg.metadata or {},
|
||||
)
|
||||
|
||||
async def _consolidate_memory(self, session, archive_all: bool = False) -> None:
|
||||
|
||||
Reference in New Issue
Block a user