diff --git a/pipeline_service/db_query.py b/pipeline_service/db_query.py index 57e10dd..fb8c747 100644 --- a/pipeline_service/db_query.py +++ b/pipeline_service/db_query.py @@ -120,8 +120,18 @@ async def tool_query_project_data(sor, table: str, project_id: str, try: recs = await sor.sqlExe(full_sql, {"pid": project_id}) except Exception as e: + msg = str(e)[:200] + # 2026-09-15:LLM 常把 params JSON 键当列传(如 stage='analysis_redo')→ 1054。 + # 回带该表真实列清单,让调用方下一轮自恢复,不再白烧轮次。 + if 'Unknown column' in msg: + try: + cols = await sor.sqlExe("SHOW COLUMNS FROM " + table, {}) + names = ', '.join(getattr(c, 'Field', '') or '' for c in (cols or [])) + msg += '。表 %s 可用列: %s(stage/task_kind 等在 params JSON 内,不是列)' % (table, names) + except Exception: + pass # 产线扩展表在其他产线库可能不存在——容错但报实情 - return 'FAIL: 查询异常(表可能不存在于当前产线库): ' + str(e)[:200] + return 'FAIL: 查询异常(表可能不存在于当前产线库): ' + msg rows = [_rec_to_dict(r) for r in (recs or [])] # 审计(append-only):谁在查什么