Skip to content

fix(cli,i18n): warn after offline config writes when octop run is live; append root cause to stream errors (#952 方向 1+3) - #1001

Open
vicfei wants to merge 1 commit into
TencentCloud:developfrom
vicfei:fix/952-cli-restart-hint
Open

vicfei wants to merge 1 commit into
TencentCloud:developfrom
vicfei:fix/952-cli-restart-hint

Conversation

@vicfei

@vicfei vicfei commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#952 的两个独立修复方向(与 #969 的 factory 同步正交,sxh313 在 issue 里明确留出的两块):

1. CLI 离线写后提示运行中的 octop run 需重启

  • 新增 cli/support/runtime_probe.py:读 config.json 的 bind_host/port(octop run 启动时已把解析后的地址写回 config.json,见 run.py::_save_configfile_overrides),探测 GET /api/health(0.5s 超时;0.0.0.0/:: 归一到 127.0.0.1)。全部 best-effort:探测失败 = 不提示,绝不阻塞或拖慢 CLI 写命令
  • provider create/delete、channel create/patch/delete、cron create/delete 共 7 个离线写点接线:命中活实例时向 stderr 输出本地化提示(zh/en),不污染 --json 的 stdout
  • 顺带替换 cron create 原有的无条件英文提示(打到 stdout)为条件触发的本地化版本

2. 对话错误透传真实根因

  • format_stream_error 此前一旦命中分类(或 model_call_failed 兜底)就把原始异常文案整体替换成本地化通用文案——#952 的现场里用户只看到「模型调用多次重试后仍失败」,提示去查模型配置,而配置页面显示一切正常,无从定位
  • 现在在替换处把原始原因追加回来:原因:{cause}(en: Cause: {cause}),凭证脱敏(sk-… / Bearer …)+ 截断 300 字符;send_file_to_user 透传路径不动(fix(chat): prevent misclassifying send_file_to_user tool errors as model outages (#852) #925 的语义)
  • 四个对话通道(HTTP SSE / WS / CLI repl / gateway processor)共用这一个格式化点,一处修改全部生效

Testing

  • 新增 tests/unit/cli/test_runtime_probe.py(9 用例:健康/无监听/非健康 JSON/wildcard 归一/无 config 不落盘/损坏 config/stderr 输出/静默)
  • tests/unit/i18n/test_stream.py 新增 6 用例(模型未找到根因、401 脱敏、Bearer 脱敏、长文案截断、guidance 去重、en 后缀),4 个锁定旧契约("原始文案不可见")的用例更新为新契约(guidance 首行 + 根因可见)
  • make all 全绿(format-all / lint / mypy --strict / 全量单测)

Fixes #952 (方向 1+3;方向 2 由 #969 覆盖)

…e; append root cause to stream errors (TencentCloud#952)

- provider/channel/cron offline writes probe /api/health on the configured
  bind address and print a localized restart hint on stderr (never stdout,
  so --json stays parseable); replaces cron create's unconditional English
  hint
- format_stream_error keeps surfacing the original cause (secrets redacted,
  clipped) instead of fully replacing it with generic localized guidance;
  shared by the HTTP / WS / CLI / gateway processor chat paths

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant