From 47d5c490e427ec4c50c136fdb86e7032a71a1506 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 8 Aug 2026 23:35:00 +0800 Subject: [PATCH] fix: robust DictObject handling for AgentIO JSON body auto-detect --- wwwroot/api/cockpit_chat.dspy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 5f0218f..25a1d1c 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -2,13 +2,14 @@ import aiohttp action = (params_kw or {}).get('action', 'list_messages') -# AgentIO sends JSON body without action field — detect from message_text presence +# AgentIO sends JSON body: {"params":{"prompt":"...","model_id":"..."},...} if action != 'send_message': - p = params_kw or {} - msg = (p.get('message_text') or '').strip() + try: p = dict(params_kw) if params_kw else {} + except: p = {} + msg = p.get('message_text', '') or '' if not msg: - inner = p.get('params', {}) - if isinstance(inner, dict): + inner = p.get('params', None) + if hasattr(inner, 'get') and callable(inner.get): msg = (inner.get('prompt') or inner.get('message_text') or '').strip() if msg: action = 'send_message'