Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#1,047 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
observability

Research direction

Start in packages/opencode/src/session/prompt.ts at loop() around lines 364 and 498, then inspect the telemetry block around line 939 and how session-scoped state or prior assistant messages are available. Reproduce the issue with three messages and inspect telemetry. Done means each session emits one session_start and one task_classified from the opening turn, while the intentionally per-loop trace at line 1088 remains unchanged.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
813
Forks
134
Avg merge
2d 3h
Merged PRs (30d)
65

Contributor guide

Open the contributing guide

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 AltimateAI/altimate-code

All issues in AltimateAI/altimate-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.