fix(prompt): Word 渲染段命令行按 backend 换路径——host 不再注容器路径

_build_system_prompt 渲染段原硬编码 /sandbox/rendering/render.py,host 模式
(本地 dogfood)下该容器路径不存在,agent 照调必 FileNotFoundError。
按 is_docker 分支:docker 原样不变;host 换 venv 解释器 + 宿主真实路径。
skill 文档里的 /sandbox 写法是 docker 专属管线,不动。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-07-22 16:13:56 +08:00
parent 6e455d37be
commit 2e063e2ac0
1 changed files with 10 additions and 1 deletions

View File

@ -18,6 +18,7 @@ state.json 已删除(元数据全在 PG)。
from __future__ import annotations
import os
import sys
from datetime import datetime
from pathlib import Path
from typing import Any, Callable, Optional, Tuple
@ -379,6 +380,14 @@ def _build_system_prompt(
wd_path = "/workspace"
else:
wd_path = str(wd_abs)
# 渲染器调用命令按 backend 换:docker 是容器内 bind 的 /sandbox 路径 + 容器 python;
# host(本地 dogfood)按宿主真实路径 + 当前解释器(venv,依赖齐)—— 否则 agent 拿着
# 容器路径在宿主上调,必 FileNotFoundError。skill 文档里的 /sandbox 写法是 docker
# 专属管线,不受此影响。
if is_docker:
render_cmd = "python /sandbox/rendering/render.py"
else:
render_cmd = f'"{sys.executable}" "{ROOT / "rendering" / "render.py"}"'
today = datetime.now().strftime("%Y-%m-%d")
tname = task_name or "<未指定>"
short_id = task_id.hex[:8]
@ -414,7 +423,7 @@ def _build_system_prompt(
f"**优先**把正文写成 Markdown(`<task_dir>/sections/*.md`,纯文本、零转义 / 零语法风险),"
f"再调平台渲染器出 docx —— **别在 run_python 里手撸 python-docx 内联大段中文正文**"
f"(中文引号 / 全角标点混进源码极易 SyntaxError、反复返工烧 token):\n\n"
f" python /sandbox/rendering/render.py --profile report --format docx <task_dir>/sections/ -o <task_dir>/<报告名>.docx\n\n"
f" {render_cmd} --profile report --format docx <task_dir>/sections/ -o <task_dir>/<报告名>.docx\n\n"
f"渲染器自动管字体(正文宋体小四 / 标题黑体 / 1.5 倍行距)、目录(加 `--toc`)、"
f"表格、`![](path)` 居中插图 + 图题编号、mermaid 图。已加载 proposal / paper 等 skill 时"
f"按其 render 指引的 profile 走(更具体),通用报告用 `--profile report`。\n"