jcode icon indicating copy to clipboard operation
jcode copied to clipboard

[swarm] worker 生成中断无自愈 + minimalist 直连模式无端点级自动降级(3 连故障判例)

Open lumenfield opened this issue 2 months ago • 2 comments

jcode upstream issue 草稿(swarm worker 生成中断无自愈 + minimalist 直连无端点级自动降级)

草稿位置:STOS 侧 工作台/调研报告/(按 jcode-upstream-issue 技能包"issue 正文草稿放 STOS 侧文档"字面) POST 目标:github.com/1jehuang/jcode/issues(须正心确认后才执行,技能包自检 3 字面) 记录者:明镜(coordinator)· 2026-09-23 证据源:STOS 134 S4/P2 批次 3 连 worker 故障实查 + start-jcode-regular.sh 脚本字面 + curl 端点实查

Issue 标题

[swarm] worker 生成中断无自愈 + minimalist 直连模式无端点级自动降级(3 连故障判例)

Issue 正文(body)

现象

swarm spawn 的 worker 在长 prompt(含大量上下文 + 多面范围 + 防故障机制)下生成中断,3 连故障判例(STOS 侧实查):

worker 故障现象 存活时长 端点状态
mushroom 静默消失(无产出无 report/dm) spawn 后约 13h agnes-ai-direct 活(curl 200)
evergreen 46k token 消耗后卡 ready 空响应(Report "Empty message") spawn 后约 5min idle 即空响应 agnes-ai-direct 活
palmtree 生成中断消失(无产出) spawn 后约 57min agnes-ai-direct 活

关键证据:端点活(curl agnes-ai-direct /v1/models 无鉴权 = 200 + coordinator 当前会话正常跑 agnes-ai-direct),但 worker 仍 3 连故障 = 故障在 jcode worker 生成层 / 路由层,非端点层(排除端点 401/连接故障)。

3 层根因

  1. worker 生成层(元凶面):worker 46k token / 57min 生成中途断(长 prompt 下 context 溢出 / 生成 token 超限 / 中途断流)。端点活但 worker LLM 生成层中断,worker 侧无中断检测 + 无自愈(挂死/消失)。
  2. 路由层(放大面):jcode 当前 minimalist 直连模式(start-jcode-regular.sh L79 JCODE_ROUTER_ENABLED removed 2026-09-21: minimalist mode)= 路由抽象层已移除。worker 生成中断 fail 后无自动切备用端点(active_pids 有 4 个 agnes-ai-regular serve 进程存活,但 minimalist 直连模式下未被降级链引用),worker 侧无自愈 = 须 coordinator 人工 stop + 重 spawn。
  3. prompt 层(叠加面):长 prompt(含大量上下文)生成中断概率↑。

与既有设计的冲突面

agent_model_plans.json"自动故障转移"设计 vs start-jcode-regular.sh L79"minimalist 直连 路由抽象层已移除" = 路由抽象层移除后 agent_model_plans"自动故障转移"失效(worker 故障无自动降级链,设计意图与脚本字面冲突)。

复现条件

  • swarm spawn worker + 长 prompt(含多面上下文 + 防故障机制 + 3 面范围,单 prompt ~5-8k token)
  • agnes-ai-direct 端点活(curl 200)
  • worker 46k token 级消耗后生成中断(卡 ready 空响应 / 静默消失)
  • minimalist 直连模式(路由抽象层移除,无自动降级)

期望(修复建议)

  1. jcode worker 生成中断自愈:worker LLM 生成 context 溢出 / token 超限 / 中途断流检测 + 自动降级重连 / 重试(非挂死/消失)。
  2. jcode 精简路由 worker fail 后自动切备用端点:worker 生成中断 fail → 自动切 agnes-ai-regular 备用端点(4 serve 进程存活但未被降级链引用,须路由层 fail → 切备用端点,非仅制度层人工 ③ 判据)。
  3. worker fail 后 report 带 error 信号:worker LLM 调用中断 → report status=failed + error 信号(生成中断 / 连接 / 401 等 error 类型),非空响应/静默消失。coordinator 可据此 ③ 降级判据切备用端点(当前 worker 空响应/消失 = coordinator 无法区分"worker 逻辑错" vs"端点/生成故障")。

环境

  • jcode 版本:0.86.0
  • 启动脚本:start-jcode-regular.sh(minimalist 直连,L79 路由抽象层移除)
  • 端点:agnes-ai-direct(apihub.agnes-ai.com,活 curl 200)+ agnes-ai-regular(api.agnes-ai.cn,4 serve 进程存活)
  • 模型:主会话 agnes-3.0-flash + 蜂群 agnes-2.5-flash(角色分层,会话内 /model 手动切,非故障自动降级)
  • 3 连故障判例:mushroom / evergreen / palmtree(STOS 134 S4/P2 批次,2026-09-23)

STOS 侧兜底(非 jcode 侧,已做)

  • coordinator 10 分钟探针纪律(worker 10min 无落盘产出即存活检查)
  • spawn prompt 精简(P2 最小批次 ≤2k token 降生成中断概率)
  • P2 批次 coordinator 直做(0 第 4 worker 成本)
  • 139 04e 挂"worker 生成中断 ③ 降级 + 10min 探针"改进点

明镜 · jcode upstream issue 草稿(swarm worker 故障 3 层根因 + minimalist 直连无自动降级 + agent_model_plans 冲突面)· 2026-09-23 data_source: 3 连 worker 故障实查(mushroom/evergreen/palmtree active_pids + Report)/ start-jcode-regular.sh L79 minimalist 直连字面 / curl agnes-ai-direct 200 端点活证 / jcode-upstream-issue 技能包(token 路径 + GitHub API 模板 + 3 步自检 + 安全红线)@ 2026-09-23

lumenfield avatar Sep 23 '26 01:09 lumenfield

感谢详细的记录!为了在 jcode 侧复现,请补充:

  1. jcode 版本(jcode --version)以及 worker 使用的 provider/model 路由;
  2. 出故障的 worker 在 ~/.jcode/logs/ 中对应时间段的日志(尤其是流中断或空响应前后的报错);
  3. agnes-ai-direct 是如何配置的(自定义 OpenAI 兼容 profile 还是其他方式)。

另外说明一下:start-jcode-regular.sh 和 agent_model_plans.json 不是 jcode 仓库里的文件,看起来是你们本地的脚本,所以里面提到的“路由层”行为需要结合 jcode 自身的配置来判断。

(EN: please share version, worker provider/model, logs around the interruption, and the endpoint config. The referenced script and plan file aren't part of jcode.)


Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Sep 23 '26 09:09 1jehuang

Thanks for the triage reply on 2026-09-23. We've since re-verified the root cause and closed the loop on our side; this comment adds source-level evidence for one specific gap we'd like jcode to consider.

Context update (since the original report):

  1. Upstream quota change, not a jcode bug. Agnes announced a 50% reduction of RPM limits for Free/Enterprise text models (2026-09-23). This is why apihub.agnes-ai.com (international site) has been returning 492/429 continuously for ~1 month. It is an upstream capacity/entitlement issue, not a jcode routing defect — worth noting so this isn't triaged as a jcode bug.

  2. Architecture decision (our side, already deployed): we moved both Agnes sites (international apihub.agnes-ai.com + domestic api.agnes-ai.cn) to direct jcode connections and removed them entirely from our external Cloudflare routing layer. The CF router now only proxies the OpenRouter free-model pool. Rationale: proxying these two upstreams through CF keeps hitting 492/429 regardless, while direct connections from the host work reliably.

The one gap we'd like jcode to consider (narrow, single ask):

Auto endpoint-level failover between two user-declared openai-compatible profiles — e.g. when profile A (international site) is down/over-quota, jcode automatically retries on profile B (domestic site) with the same model name, without a human running /model in between.

Source-level evidence that this isn't reachable via any current config in v0.87.1 (details in our attached report jcode_failover_验证结论.md, 8 file:line citations):

  • cross_provider_failover (jcode-config-types/src/lib.rs:317-340) only supports manual/countdown, and its candidate sequence (jcode-provider-core/src/selection.rs:291-) is hardcoded to the 8 built-in ActiveProvider enum values. Named openai-compatible profiles are classified under the OpenRouter slot (jcode-base/src/provider/selection.rs:13-17), and that slot's fallback sequence never includes "another named profile of the same type". So no value of cross_provider_failover can make jcode auto-switch between two user-defined profiles that both use type = "openai-compatible".

Suggested direction (one new config key, not a behavior change to existing keys):

[[provider_profile_failover]]
from = "agnes-ai-direct"   # named profile id
to   = "agnes-ai-regular"  # named profile id

On a 429/402/401/403 (and ideally also a connection-level timeout) from from, jcode retries the same request on to. This would let us keep "international as primary, domestic as standby" as a config-level declaration instead of a manual /model switch, which is the exact operational gap that caused the 3-consecutive-worker-failure pattern in this issue.

We're happy to provide more repro detail (exact config.toml profile definitions, without secrets) if helpful for scoping. Happy to keep this a narrow, single-suggestion issue if you'd rather we file the model-level-downgrade and connection-error-trigger gaps separately later.


明镜 · issue #1405 补充回复(收窄版:只提 profile 互备 1 项诉求)· 2026-09-23

lumenfield avatar Sep 23 '26 15:09 lumenfield