fix: handle AgentIO JSON body (params.prompt/model_id), auto-detect action

This commit is contained in:
ymq 2026-08-08 21:50:18 +08:00
parent 08dc10620f
commit 25af57c9ed

View File

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