|
@@ -118,7 +118,7 @@ class DataQueryService:
|
|
|
self.state.finish_message(message.message_id, "failed", safe_error)
|
|
self.state.finish_message(message.message_id, "failed", safe_error)
|
|
|
self.state.fail_active_runs(message.message_id, safe_error)
|
|
self.state.fail_active_runs(message.message_id, safe_error)
|
|
|
try:
|
|
try:
|
|
|
- await self.feishu.reply_text(message.message_id, f"查询失败:{safe_error}")
|
|
|
|
|
|
|
+ await self.feishu.reply_text(message.message_id, f"处理失败:{safe_error}")
|
|
|
except Exception as reply_exc:
|
|
except Exception as reply_exc:
|
|
|
logger.error(
|
|
logger.error(
|
|
|
"Failed to send error reply message_id=%s error=%s",
|
|
"Failed to send error reply message_id=%s error=%s",
|
|
@@ -147,6 +147,13 @@ class DataQueryService:
|
|
|
if decision.status != "ready":
|
|
if decision.status != "ready":
|
|
|
await self.feishu.reply_text(message.message_id, decision.reply)
|
|
await self.feishu.reply_text(message.message_id, decision.reply)
|
|
|
return
|
|
return
|
|
|
|
|
+ if decision.execution_mode == "direct_reply":
|
|
|
|
|
+ if decision.sql:
|
|
|
|
|
+ raise RuntimeError("Agent 的自然语言回复不应包含 SQL")
|
|
|
|
|
+ if not decision.reply.strip():
|
|
|
|
|
+ raise RuntimeError("Agent 的自然语言回复为空")
|
|
|
|
|
+ await self.feishu.reply_text(message.message_id, decision.reply)
|
|
|
|
|
+ return
|
|
|
if decision.execution_mode == "sql" and not decision.sql:
|
|
if decision.execution_mode == "sql" and not decision.sql:
|
|
|
raise RuntimeError("Agent 返回 ready 但没有 SQL")
|
|
raise RuntimeError("Agent 返回 ready 但没有 SQL")
|
|
|
if decision.execution_mode == "skill_script" and decision.selected_skill != "query-user-behavior-path":
|
|
if decision.execution_mode == "skill_script" and decision.selected_skill != "query-user-behavior-path":
|
|
@@ -217,7 +224,7 @@ class DataQueryService:
|
|
|
repairs.append({"attempt": attempt + 1, "error": self._safe_error(exc)})
|
|
repairs.append({"attempt": attempt + 1, "error": self._safe_error(exc)})
|
|
|
thread_id, current = await self.codex.repair(thread_id, sql, str(exc), attempt + 1)
|
|
thread_id, current = await self.codex.repair(thread_id, sql, str(exc), attempt + 1)
|
|
|
self.state.set_thread(message.conversation_key, thread_id)
|
|
self.state.set_thread(message.conversation_key, thread_id)
|
|
|
- if current.status != "ready" or not current.sql:
|
|
|
|
|
|
|
+ if current.status != "ready" or current.execution_mode != "sql" or not current.sql:
|
|
|
raise RuntimeError(current.reply or "Agent 无法修复 SQL")
|
|
raise RuntimeError(current.reply or "Agent 无法修复 SQL")
|
|
|
|
|
|
|
|
if result is None:
|
|
if result is None:
|