Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
Showing only changes of commit f01e6b55c7 - Show all commits
+15 -1
View File
@@ -309,7 +309,10 @@ class AgentLoop:
cron_tool = self.tools.get("cron")
if isinstance(cron_tool, CronTool):
cron_tool.set_context(msg.channel, msg.chat_id)
# Track media for this turn (screenshots from computer tool)
media_paths_for_turn: list[str] = []
# Prepend current time + optional time-gap notice to every user message
now_dt = datetime.now()
tz = time.strftime("%Z") or "UTC"
@@ -416,6 +419,16 @@ class AgentLoop:
# If there's an image, use multipart content
if result.base64_image:
# Save screenshot to disk for user
import base64
media_dir = Path.home() / ".nanobot" / "media"
media_dir.mkdir(parents=True, exist_ok=True)
screenshot_path = media_dir / f"screenshot_{int(time.time() * 1000)}.png"
screenshot_path.write_bytes(base64.b64decode(result.base64_image))
media_paths_for_turn.append(str(screenshot_path))
logger.info(f"Saved screenshot to {screenshot_path}")
# Include in tool result for model to see
content_parts = [
{"type": "text", "text": text_content},
{
@@ -520,6 +533,7 @@ class AgentLoop:
chat_id=msg.chat_id,
content=final_content_for_session,
metadata=outbound_metadata,
media=media_paths_for_turn if media_paths_for_turn else None,
)
async def _process_system_message(self, msg: InboundMessage) -> OutboundMessage | None: