修复:DSH 自主查询、图片直显与报告稳定性

允许 Agent 在循环中查目录、修正查询和提问,保留实时权限检查及模型原始回答。
统一相同查询证据与图表资源;排名补齐阶段指标,修正 OR 重量筛选,并限制模型明细输入。
增加运行恢复、图表自适应坐标轴与两位小数,修复报告主图选择、重复图及边缘标签。

验证:独立副本通过 162 项 Python、73 项前端及 21 项后端测试,前端构建通过。
线上已用原 8 题复测,并追加两轮双期对比;TOP100 与组合筛选分别核对 100 行和 20 行。
This commit is contained in:
2026-11-12 16:14:20 +08:00
parent f1a2fbd494
commit bc19475b29
35 changed files with 983 additions and 114 deletions
@@ -81,6 +81,13 @@ def _plan(request, protocol, delegated, connection, workspace, cancel, emit):
if isinstance(catalog.get("groupDepartments"), dict):
request["_scopeDirectory"] = {"groupDepartments": copy.deepcopy(catalog["groupDepartments"])}
if ((catalog.get('productMatch') or {}).get('query')
and (catalog.get('productMatch') or {}).get('status') in ('ambiguous', 'none')):
# 缩写与未匹配规格直接交给 DSH 查询目录和提问,不先调用独立规划模型。
request['_analysisDirectory']['productLookupHint'] = {'search':catalog['productMatch']['query'],'needsLookup':True}
return {'goal': request['question'], 'fields': ['rate'], 'stages': [], 'dimensions': [],
'trendRequired': any(word in request['question'] for word in ('趋势','走势','逐月'))}
emit({"type": "progress", "message": "正在理解本轮目标和连续追问…"})
retry = protocol.get("retryTask")
if isinstance(retry, dict) and retry:
@@ -205,10 +212,22 @@ def _run_turn(payload, *, stdout, stdin, output_lock):
connection = (gate.base_url, gate_key, model)
emit({"type": "progress", "message": "正在查询质量数据分析平台并整理结论…"})
planning_started = time.monotonic()
task = _plan(request, protocol, delegated, connection, workspace, cancelled, emit)
try:
task = _plan(request, protocol, delegated, connection, workspace, cancelled, emit)
except (ValueError, RuntimeErrorSafe) as error:
if cancelled.is_set() or getattr(error, 'http_status', None) in (401, 403):
raise
# 意图格式失败可在循环内恢复,不属于权限拒绝。
_atomic_json(workspace / 'private/startup-intent-diagnostic.json', {'errorType': type(error).__name__})
task = {}
request["context"].pop("_businessCatalog", None)
if not isinstance(task, dict):
raise RuntimeErrorSafe("未形成可提交的任务提案。")
request['_agentIntent'] = copy.deepcopy(task if isinstance(task, dict) else {})
for key in ('productMatch','productResolution'):
request['_agentIntent'].pop(key,None)
if (not isinstance(task, dict) or task.get('needsClarification') or
task.get('executionMode') == 'native_agent' or task.get('kind') not in ('report','explain','restate','members')):
from dsh_startup import execution_task
task = execution_task(task, request['question'], request.get('_analysisDirectory', {}))
authorize()
planning_ms = round((time.monotonic() - planning_started) * 1000)
confirmation_started = time.monotonic()