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'