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.
This commit is contained in:
teknium1 2026-06-30 03:17:37 -07:00 committed by Teknium
parent 9dc6dc062f
commit fe355d0a27

View file

@ -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 ""