diff --git a/acp_adapter/server.py b/acp_adapter/server.py index cc19f855d9b2..3e79bdcd38a4 100644 --- a/acp_adapter/server.py +++ b/acp_adapter/server.py @@ -1936,8 +1936,8 @@ class HermesACPAgent(acp.Agent): return "No tools available." lines = [f"Available tools ({len(tools)}):"] for t in tools: - name = t.get("function", {}).get("name", "?") - desc = t.get("function", {}).get("description", "") + name = (t.get("function") or {}).get("name", "?") + desc = (t.get("function") or {}).get("description", "") # Truncate long descriptions if len(desc) > 80: desc = desc[:77] + "..." diff --git a/gateway/platforms/qqbot/onboard.py b/gateway/platforms/qqbot/onboard.py index b48c39a4f87a..6fd80c29fb6a 100644 --- a/gateway/platforms/qqbot/onboard.py +++ b/gateway/platforms/qqbot/onboard.py @@ -100,7 +100,7 @@ def _create_bind_task(timeout: float = ONBOARD_API_TIMEOUT) -> Tuple[str, str]: if data.get("retcode") != 0: raise RuntimeError(data.get("msg", "create_bind_task failed")) - task_id = data.get("data", {}).get("task_id") + task_id = (data.get("data") or {}).get("task_id") if not task_id: raise RuntimeError("create_bind_task: missing task_id in response") diff --git a/gateway/platforms/yuanbao.py b/gateway/platforms/yuanbao.py index 7145ec578773..5aa2f275feee 100644 --- a/gateway/platforms/yuanbao.py +++ b/gateway/platforms/yuanbao.py @@ -2153,7 +2153,7 @@ class GroupAtGuardMiddleware(InboundMiddleware): for elem in msg_body: if elem.get("msg_type") != "TIMCustomElem": continue - data_str = elem.get("msg_content", {}).get("data", "") + data_str = (elem.get("msg_content") or {}).get("data", "") if not data_str: continue try: @@ -2172,7 +2172,7 @@ class GroupAtGuardMiddleware(InboundMiddleware): for elem in msg_body: if elem.get("msg_type") != "TIMCustomElem": continue - data_str = elem.get("msg_content", {}).get("data", "") + data_str = (elem.get("msg_content") or {}).get("data", "") if not data_str: continue try: diff --git a/gateway/run.py b/gateway/run.py index 9eeb04546b5c..76eca5a8ebf8 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -15110,7 +15110,7 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew has_agent_tts = any( msg.get("role") == "assistant" and any( - tc.get("function", {}).get("name") == "text_to_speech" + (tc.get("function") or {}).get("name") == "text_to_speech" for tc in (msg.get("tool_calls") or []) ) for msg in agent_messages diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 7cae542d7cc6..e4f6687f4207 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -6683,7 +6683,7 @@ class SlackAdapter(BasePlatformAdapter): original_text = "" for block in message.get("blocks", []): if block.get("type") == "section": - original_text = block.get("text", {}).get("text", "") + original_text = (block.get("text") or {}).get("text", "") break # Slack re-escapes HTML entities in the interaction payload @@ -6862,7 +6862,7 @@ class SlackAdapter(BasePlatformAdapter): original_text = "" for block in message.get("blocks", []): if block.get("type") == "section": - original_text = block.get("text", {}).get("text", "") + original_text = (block.get("text") or {}).get("text", "") break # Slack re-escapes HTML entities in the interaction payload @@ -6964,7 +6964,7 @@ class SlackAdapter(BasePlatformAdapter): original_text = "" for block in message.get("blocks", []): if block.get("type") == "section": - original_text = block.get("text", {}).get("text", "") + original_text = (block.get("text") or {}).get("text", "") break from tools import clarify_gateway as _clarify_mod diff --git a/tui_gateway/server.py b/tui_gateway/server.py index b8ac2301a01d..eb9f5cda0e66 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -10044,7 +10044,7 @@ def _(rid, params: dict) -> dict: "error", sid, { - "message": err.get("error", {}).get( + "message": (err.get("error") or {}).get( "message", "agent initialization failed" ) },