From 25af57c9ed2dea3f7b67ac1a9486833505a744a8 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 8 Aug 2026 21:50:18 +0800 Subject: [PATCH] fix: handle AgentIO JSON body (params.prompt/model_id), auto-detect action --- wwwroot/api/cockpit_chat.dspy | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 21d03b0..5f0218f 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -2,6 +2,16 @@ import aiohttp action = (params_kw or {}).get('action', 'list_messages') +# AgentIO sends JSON body without action field — detect from message_text presence +if action != 'send_message': + p = params_kw or {} + msg = (p.get('message_text') or '').strip() + if not msg: + inner = p.get('params', {}) + if isinstance(inner, dict): + msg = (inner.get('prompt') or inner.get('message_text') or '').strip() + if msg: + action = 'send_message' dbname = get_module_dbname('pipeline-sdlc') AGENT_PROMPT = """你是开发产线驾驶舱 Agent。需要数据时调工具,最终用 reply 回复。 @@ -177,8 +187,17 @@ async def _exec_tool(sor, tool, params, ctx, uid, org_id): if action == 'send_message': - message_text = (params_kw or {}).get('message_text','').strip() - user_model_id = (params_kw or {}).get('model_id','') + # AgentIO sends JSON: {"params":{"prompt":"...","model_id":"..."},...} + # FormData sends: action=send_message&message_text=...&model_id=... + p = params_kw or {} + message_text = (p.get('message_text') or '').strip() + user_model_id = p.get('model_id', '') + # Try JSON body from AgentIO + if not message_text: + inner = p.get('params', {}) + if isinstance(inner, dict): + message_text = (inner.get('prompt') or inner.get('message_text') or '').strip() + user_model_id = inner.get('model_id') or inner.get('llmid') or user_model_id if not message_text: return json.dumps({"error":"message_text is required"},ensure_ascii=False) blocked, reason = _security_scan(message_text)