Skip to content

[sight] bug: cosh-ng 内部 recap 调用被归为独立 0-token 会话,污染会话列表 #2750

Description

@zhangtaibo

Component

agentsight (session attribution / dashboard)

Bug Description

cosh-ng agent 运行期间的内部 recap/总结类 LLM 调用(非用户发起)被赋予了独立的 session_id,作为一个独立会话出现在会话列表中(0 输入 / 0 输出 token),产生噪音条目并虚增会话计数。该会话底层事件 status=interrupted、token 字段为 None,用户在 UI 上看到的是一条「凭空出现」的 0-token 空会话。

Steps to Reproduce

# 1. 在安装了 agentsight(trace 运行中)的机器上,用 cosh-ng 发起一次普通对话,
#    触发 cosh-core 的内部 recap/总结调用
# 2. 查询会话列表(Dashboard「会话列表」页,或):
curl -s -H "Authorization: Bearer $TOKEN"   "http://127.0.0.1:7396/api/sessions?start_ns=0&end_ns=9223372036854775807"
# 3. 找到 agent 为 CoshNG、输入/输出均为 0 的独立会话条目

Actual Behavior

/api/sessions 返回中出现独立会话(连续 3 轮查询结果一致):

{
  "session_id": "f4e2fb506ac3ed…",
  "agent_name": "CoshNG",
  "conversation_count": 1,
  "total_input_tokens": 0,
  "total_output_tokens": 0
}

查询该会话在 genai_events 中的底层事件:

{
  "call_kind": "main",
  "status": "interrupted",
  "input_tokens": null,
  "output_tokens": null,
  "user_query": "Summarize only grounded work into the supplied JSON schema. List every business entity men…"
}
  • user_query 是 cosh-core 的内部总结提示词("Summarize only grounded work…"),不是任何用户输入
  • 同一时间窗内真实用户对话的会话是另一个 session_id(该会话正常聚合了 7 个对话的 token)

Expected Behavior

  • 内部 recap/总结调用应按 call_kind=recap 语义归并到其父会话的统计中,而不是生成独立 session_id;
  • 或至少在会话列表/API 中过滤/标记这类非用户会话,避免 0-token 噪音条目;
  • 事件 status=interrupted 时 token 为 None 的展示也应与正常会话区分。

Root Cause

Not fully confirmed. 从现象推断:recap 调用发生时(推测为 cosh-core 子进程被回收/会话收尾阶段),该事件的 session_id 被赋予了新值而非父会话的 session_id;且该事件 status=interrupted(调用未完成),token 字段未落库,聚合后形成 0-token 会话。

Suggested Fix

事件采集/落库阶段将 recap 类调用的 session_id 与父会话关联(或会话聚合时按 call_kind 过滤),确保会话列表只呈现用户会话。

Environment

  • OS: Alibaba Cloud Linux 4 (Agentic Edition)
  • Component version: agentsight 0.10.2
  • Package/RPM: agentsight-0.10.2-1.alnx4.x86_64
  • Observed agent: cosh-ng 0.16.1 (cosh-shell raw cosh-core)

Additional Context

  • 稳定性: 连续 3 次稳定复现
  • 影响: 会话列表出现非用户会话噪音条目,会话计数虚高;0-token 会话对用户无诊断价值

Metadata

Metadata

Labels

component:sightsrc/agentsight/type:bugA confirmed defect or incorrect behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions