From 0cd43585bc0fb98239322a5aeb9c880ea4df8abf Mon Sep 17 00:00:00 2001 From: Molecule AI Integration Tester Date: Sun, 10 May 2026 09:37:26 +0000 Subject: [PATCH] fix(a2a): handle string error in a2a_tools.py + remove dead staging trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two-part fix from PR #268 (ported by Integration Tester after PR #268 was closed without merge): PART 1 — workspace/builtin_tools/a2a_tools.py: Fixes AttributeError when platform returns a plain string as the error field. Before: data["error"].get("message") ← crashes if error is a string After: isinstance(err, dict) → err.get("message") isinstance(err, str) → use err directly otherwise → str(err) Also guards against result being a non-dict: result.get("parts") if isinstance(result, dict) else [] PART 2 — .gitea/workflows/ and .github/workflows/ publish-workspace-server-image.yml: Removed dead "staging" branch trigger. Trunk-based migration (2026-05-08) removed the staging branch but the workflow triggers weren't updated, causing every staging push to attempt and fail the publish workflow (missing Gitea Actions secrets at the time, failing in 9s). Now triggers on main only. Co-Authored-By: Claude Opus 4.7 --- .../publish-workspace-server-image.yml | 2 +- .../publish-workspace-server-image.yml | 2 +- workspace/builtin_tools/a2a_tools.py | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/publish-workspace-server-image.yml b/.gitea/workflows/publish-workspace-server-image.yml index 96a03b7e..e9ca5ec2 100644 --- a/.gitea/workflows/publish-workspace-server-image.yml +++ b/.gitea/workflows/publish-workspace-server-image.yml @@ -23,7 +23,7 @@ name: publish-workspace-server-image on: push: - branches: [staging, main] + branches: [main] paths: - 'workspace-server/**' - 'canvas/**' diff --git a/.github/workflows/publish-workspace-server-image.yml b/.github/workflows/publish-workspace-server-image.yml index be88f2cc..2a1b8b17 100644 --- a/.github/workflows/publish-workspace-server-image.yml +++ b/.github/workflows/publish-workspace-server-image.yml @@ -32,7 +32,7 @@ name: publish-workspace-server-image on: push: - branches: [staging, main] + branches: [main] paths: - 'workspace-server/**' - 'canvas/**' diff --git a/workspace/builtin_tools/a2a_tools.py b/workspace/builtin_tools/a2a_tools.py index df4f9d78..84e61ff1 100644 --- a/workspace/builtin_tools/a2a_tools.py +++ b/workspace/builtin_tools/a2a_tools.py @@ -66,10 +66,21 @@ async def delegate_task(workspace_id: str, task: str) -> str: ) data = a2a_resp.json() if "result" in data: - parts = data["result"].get("parts", []) - return parts[0].get("text", "(no text)") if parts else str(data["result"]) + result = data["result"] + parts = result.get("parts", []) if isinstance(result, dict) else [] + if parts and isinstance(parts[0], dict): + return parts[0].get("text", "(no text)") + return str(result) if isinstance(result, str) else "(no text)" elif "error" in data: - return f"Error: {data['error'].get('message', str(data['error']))}" + err = data["error"] + msg = "" + if isinstance(err, dict): + msg = err.get("message", "") + elif isinstance(err, str): + msg = err + else: + msg = str(err) + return f"Error: {msg}" return str(data) except Exception as e: return f"Error sending A2A message: {e}"