Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: complete ensure_ascii=False and UTF-8 encoding migration
Re-bin73fdd0dd45b3
diff --cc nanobot/agent/subagent.pyindex ffefc080f,7d48cc415..767bc68b4--- a/nanobot/agent/subagent.py+++ b/nanobot/agent/subagent.py@@@ -159,8 -159,8 +159,8 @@@ class SubagentManager# Execute toolsfor tool_call in response.tool_calls:- args_str = json.dumps(tool_call.arguments)+ args_str = json.dumps(tool_call.arguments, ensure_ascii=False)- logger.debug(f"Subagent [{task_id}] executing: {tool_call.name} with arguments: {args_str}")+ logger.debug("Subagent [{}] executing: {} with arguments: {}", task_id, tool_call.name, args_str)result = await tools.execute(tool_call.name, tool_call.arguments)messages.append({"role": "tool",diff --cc nanobot/channels/feishu.pyindex bc4a2b895,c17bf1a7a..a8ca1fae7--- a/nanobot/channels/feishu.py+++ b/nanobot/channels/feishu.py@@@ -315,19 -357,59 +357,59 @@@ class FeishuChannel(BaseChannel).content(content).build()).build()-response = self._client.im.v1.message.create(request)-if not response.success():logger.error(- f"Failed to send Feishu message: code={response.code}, "- f"msg={response.msg}, log_id={response.get_log_id()}"+ "Failed to send Feishu {} message: code={}, msg={}, log_id={}",+ msg_type, response.code, response.msg, response.get_log_id())- else:- logger.debug(f"Feishu message sent to {msg.chat_id}")-+ return False+ logger.debug("Feishu {} message sent to {}", msg_type, receive_id)+ return True+ except Exception as e:+ logger.error("Error sending Feishu {} message: {}", msg_type, e)+ return False++ async def send(self, msg: OutboundMessage) -> None:+ """Send a message through Feishu, including media (images/files) if present."""+ if not self._client:+ logger.warning("Feishu client not initialized")+ return++ try:+ receive_id_type = "chat_id" if msg.chat_id.startswith("oc_") else "open_id"+ loop = asyncio.get_running_loop()++ for file_path in msg.media:+ if not os.path.isfile(file_path):+ logger.warning("Media file not found: {}", file_path)+ continue+ ext = os.path.splitext(file_path)[1].lower()+ if ext in self._IMAGE_EXTS:+ key = await loop.run_in_executor(None, self._upload_image_sync, file_path)+ if key:+ await loop.run_in_executor(+ None, self._send_message_sync,- receive_id_type, msg.chat_id, "image", json.dumps({"image_key": key}),++ receive_id_type, msg.chat_id, "image", json.dumps({"image_key": key}, ensure_ascii=False),+ )+ else:+ key = await loop.run_in_executor(None, self._upload_file_sync, file_path)+ if key:+ media_type = "audio" if ext in self._AUDIO_EXTS else "file"+ await loop.run_in_executor(+ None, self._send_message_sync,- receive_id_type, msg.chat_id, media_type, json.dumps({"file_key": key}),++ receive_id_type, msg.chat_id, media_type, json.dumps({"file_key": key}, ensure_ascii=False),+ )++ if msg.content and msg.content.strip():+ card = {"config": {"wide_screen_mode": True}, "elements": self._build_card_elements(msg.content)}+ await loop.run_in_executor(+ None, self._send_message_sync,+ receive_id_type, msg.chat_id, "interactive", json.dumps(card, ensure_ascii=False),+ )+except Exception as e:- logger.error(f"Error sending Feishu message: {e}")+ logger.error("Error sending Feishu message: {}", e)def _on_message_sync(self, data: "P2ImMessageReceiveV1") -> None:"""diff --cc nanobot/channels/whatsapp.pyindex f799347f3,f3e14d9b5..f5fb52175--- a/nanobot/channels/whatsapp.py+++ b/nanobot/channels/whatsapp.py@@@ -87,9 -87,9 +87,9 @@@ class WhatsAppChannel(BaseChannel)"to": msg.chat_id,"text": msg.content}- await self._ws.send(json.dumps(payload))+ await self._ws.send(json.dumps(payload, ensure_ascii=False))except Exception as e:- logger.error(f"Error sending WhatsApp message: {e}")+ logger.error("Error sending WhatsApp message: {}", e)async def _handle_bridge_message(self, raw: str) -> None:"""Handle a message from the bridge."""diff --cc nanobot/providers/openai_codex_provider.pyindex 5067438ab,2336e71ed..fa2859319--- a/nanobot/providers/openai_codex_provider.py+++ b/nanobot/providers/openai_codex_provider.py@@@ -176,7 -176,7 +176,7 @@@ def _convert_messages(messages: list[diif role == "tool":call_id, _ = _split_tool_call_id(msg.get("tool_call_id"))-- output_text = content if isinstance(content, str) else json.dumps(content)++ output_text = content if isinstance(content, str) else json.dumps(content, ensure_ascii=False)input_items.append({"type": "function_call_output",diff --cc nanobot/session/manager.pyindex 42df1b1c7,9c0c7de62..9c1e427cb--- a/nanobot/session/manager.py+++ b/nanobot/session/manager.py@@@ -159,11 -159,10 +159,10 @@@ class SessionManager"metadata": session.metadata,"last_consolidated": session.last_consolidated}- f.write(json.dumps(metadata_line) + "\n")+ f.write(json.dumps(metadata_line, ensure_ascii=False) + "\n")for msg in session.messages:- f.write(json.dumps(msg) + "\n")+ f.write(json.dumps(msg, ensure_ascii=False) + "\n")-self._cache[session.key] = sessiondef invalidate(self, key: str) -> None: