[Bug]: AI 对话诊断的 process.state 恒为 not_started,同时累加 stdoutLines,且拿不到退出码

Open Beginner friendly
#1,086 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Read internal/runtime/conversation_process.go around the event sink at lines 678–682, then compare it with the process events emitted in internal/runtime/process.go and how internal/httpapi/assistant_diagnostic_evidence.go records them. Trace the conversation process event flow and update the handling so diagnostics reflect process start, completion, or start failure. Done when diagnostics report a consistent process state and capture the exit code where available.

Written by the indexing model from the issue text.

Description

[Bug]: AI 对话诊断的 process.state 恒为 not_started,同时累加 stdoutLines,且拿不到退出码

Component / host: Platform — web / API
Edition: Platform
LoopForge version: v0.4.0(自托管镜像,诊断中平台版本显示为 (devel))

What happened?

AI 对话导出的诊断里,进程状态永远是初始值,同时却又记录了成百上千行输出:

"process": {
  "state": "not_started",
  "stdoutLines": 355,
  "stderrLines": 0,
  "firstStdoutAt": "2026-11-19T05:27:30.965950928Z",
  "lastStdoutAt": "2026-11-19T05:27:43.980091067Z"
}

state 说"进程没启动",stdoutLines 说"已经跑了 13 秒、输出 355 行"。同一个对象里两个结论互斥。
同时 attempts[].exitCode 永远为空。

原因链(代码定位)

  1. internal/httpapi/assistant_diagnostic_evidence.go:79-90 的 process(event):
    只有收到 process.started 才把 State 从 not_started 改为 running;
    收到 process.stdout 只累加 StdoutLines 与时间戳,不改状态。

    switch event.Name {
    case "process.started":
        p.State, p.StartedAt = "running", &now
    ...
    case "process.stdout":
        p.StdoutLines++
    

    因此只要 process.started 不到达,就会出现 not_started + 有输出行的组合。

  2. AI 对话走会话进程池,internal/runtime/conversation_process.go:678-682 的事件 sink
    把非 stdout/stderr 的事件全部丢弃:

    sink := func(ev domain.TelemetryEvent) {
        if ev.Name != "process.stdout" && ev.Name != "process.stderr" {
            return
        }
        ...
    }
    

    被丢掉的正是 process.started(带 pid)、process.finished(带 exitCode)、
    process.start_failed。而 internal/runtime/process.go:41 / 47 / 82 本来会发出这三个事件。

  3. 由于 process.finished 不到达,assistant_diagnostics.go 的 exited() 也拿不到
    *exec.ExitError,attempts[].exitCode 永远为空。

影响

  • process.state 字段实际没有信息量:对话链路永远是 not_started,
    无法区分"进程根本没起来""启动失败""跑了 13 秒后退出"。
  • 没有退出码,无法判断模型进程是被信号杀死、正常退出还是启动即失败;
    排查超时/OOM/崩溃时这一层完全缺失。
  • 与同对象的 stdoutLines 冲突,会让读诊断的人怀疑整份文件的可信度。

期望行为

任选其一:

  1. 会话进程池转发 process.started(含 pid)与 process.finished(含 exitCode),
    让对话链路和 runner 链路(internal/runtime/process.go)的遥测口径一致;
  2. 若确实不采集,就不要输出恒为 not_started 的 state,
    改为明确标注"该链路不采集进程状态",避免与 stdoutLines 直接矛盾。

Reproduction

  1. 平台 v0.4.0,任意跑一轮 AI 对话(能产生工具调用即可,无需成功)。
  2. 导出诊断,观察 attempts[].process.state 与 stdoutLines 是否矛盾,
    以及 attempts[].exitCode 是否始终缺失。

Sanitized diagnostics

{
  "attempts": [
    {
      "id": "<attempt>/1",
      "phase": "execution",
      "versionSource": "not_reported",
      "binarySource": "discovered",
      "process": {
        "state": "not_started",
        "stdoutLines": 355,
        "stderrLines": 0,
        "firstStdoutAt": "2026-11-19T05:27:30.965950928Z",
        "lastStdoutAt": "2026-11-19T05:27:43.980091067Z"
      }
    }
  ]
}
{
  "timeline": [
    { "kind": "cli.preparing", "phase": "setup", "source": "platform" },
    { "kind": "model.turn_started", "source": "cli" },
    { "kind": "model.first_output_delta", "source": "cli" },
    { "kind": "cli.cancelled", "phase": "execution", "source": "platform" }
  ]
}

Safety checks

  • 已移除凭证、私有端点、内部标识与个人数据。
  • 已检索现有 issue,未发现重复。
Dominant language
Go
Stars
711
Forks
114
Avg merge
15h
Merged PRs (30d)
134

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Tencent/LoopForge

All issues in Tencent/LoopForge

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.