Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

session_start and task_classified telemetry fire once per user turn, not once per session

未关闭
#1,047 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
typescript
领域
observability

调研方向

从 packages/opencode/src/session/prompt.ts 中 364 和 498 行附近的 loop() 开始,然后检查 939 行附近的 telemetry 块,以及 session 作用域的状态或之前的 assistant 消息如何可用。使用三条消息重现该问题并检查 telemetry。完成的标准是每个 session 都从开场轮次发出一个 session_start 和一个 task_classified,同时 1088 行有意按每次 loop 记录的 trace 保持不变。

由索引模型根据 Issue 内容生成。

描述

Summary

session_start and task_classified are emitted once per user turn, not once per session. Session counts in telemetry are therefore inflated by roughly the average number of turns per session, and task_classified re-classifies intent on every turn instead of once from the opening message.

Detail

Both events are emitted from a if (step === 1) block in packages/opencode/src/session/prompt.ts:939:

  • session_start — packages/opencode/src/session/prompt.ts:953
  • task_classified — packages/opencode/src/session/prompt.ts:1004

step is not session-scoped. It is declared inside loop():

  • let step = 0 — packages/opencode/src/session/prompt.ts:364
  • step++ — packages/opencode/src/session/prompt.ts:498

and loop() is invoked once per prompt, i.e. once per user turn. So step === 1 means "first model step of this turn", and the block runs again for every subsequent message in the same session.

Impact

  • session_start overcounts sessions. A session with N user turns emits N session_start events, all carrying the same session_id.
  • Any funnel or retention metric built on session_start counts is proportionally wrong. De-duplicating by session_id at query time recovers the true count, so historical data is salvageable, but no current dashboard is doing that unless it was written with this in mind.
  • task_classified reports the intent of whatever the user most recently typed, not the task the session was opened for. Its confidence distribution is also skewed by short follow-up messages ("thanks", "yes", "try again") being classified as tasks.
  • Cost: an extra pair of tracked events per turn, plus the classifyTaskIntent regex sweep over up to 2000 characters per turn.

Reproduction

Start a session, send three messages, and inspect the emitted telemetry (or set a breakpoint on the step === 1 block). Three session_start events are emitted with identical session_id.

Suggested fix

Gate both events on something session-scoped rather than on step. Options, roughly in order of preference:

  1. Check whether the session already has prior assistant messages before emitting — a session that has already produced output is not starting.
  2. Keep a per-session "already emitted" claim in the telemetry module, similar to how other once-per-session state is tracked.
  3. Emit at session creation instead of in the prompt loop, which is where the event name says it belongs.

Note that packages/opencode/src/session/prompt.ts:1088 also uses if (step === 1), but that one is intentionally per-loop() (it traces the system prompt once per loop invocation, and the comment there says so). Only the telemetry block at line 939 is affected.

主要语言
TypeScript
星标
813
派生
134
平均合并
2 天 2 小时
30 天内合并 PR
67

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AltimateAI/altimate-code 的其他 Issue

查看 AltimateAI/altimate-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。