fix(db_query): 1054未知列错误回带表真实列清单——LLM把params JSON键(stage/task_kind)当列传是高频误用,报错带列名让下一轮自恢复,不白烧轮次(2026-09-15甘肃项目实测抓到)
This commit is contained in:
parent
66387c4210
commit
b0342db38e
@ -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):谁在查什么
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user