From fe355d0a27387d12522b7e4beb067496652490ca Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Tue, 30 Jun 2026 03:17:37 -0700 Subject: [PATCH] fix(moa): handle dict/str message shape in MoA response extraction Sibling of #15795's context_compressor fix. agent/moa_loop.py used the same response.choices[0].message.content access; while wrapped in try/except (so no crash), a dict/str-shaped message silently returned empty. Coerce defensively so the content is actually extracted. --- agent/moa_loop.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/agent/moa_loop.py b/agent/moa_loop.py index e3375416054..583a0d56ccb 100644 --- a/agent/moa_loop.py +++ b/agent/moa_loop.py @@ -354,8 +354,14 @@ def _extract_text(response: Any) -> str: except Exception: pass try: - content = response.choices[0].message.content - return (content or "").strip() + message = response.choices[0].message + if isinstance(message, dict): + content = message.get("content") + else: + content = getattr(message, "content", message) + if not isinstance(content, str): + content = str(content) if content else "" + return content.strip() except Exception: return ""