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

Đang mở Phù hợp với người mới
#1,086 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Đọc internal/runtime/conversation_process.go quanh bộ tiếp nhận sự kiện ở các dòng 678–682, sau đó so sánh với các sự kiện tiến trình được phát ra trong internal/runtime/process.go và cách internal/httpapi/assistant_diagnostic_evidence.go ghi lại chúng. Theo dõi luồng sự kiện của tiến trình hội thoại và cập nhật cách xử lý để chẩn đoán phản ánh việc tiến trình bắt đầu, hoàn tất hoặc không thể khởi động. Hoàn tất khi chẩn đoán báo cáo trạng thái tiến trình nhất quán và ghi nhận mã thoát khi có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

[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,未发现重复。
Ngôn ngữ chính
Go
Star
711
Fork
114
Merge trung bình
15 giờ
Pull request đã merge (30 ngày)
134

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/LoopForge

Tất cả issue của Tencent/LoopForge

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.