Skip to content

[Bug]: telemetry event_count_bucket counts token deltas, making it incomparable across conversations #4673

Closed

Description

@VascoSch92

Part of #4671.

Actual Behavior

TelemetrySubscriber._handle (telemetry/subscriber.py:107) increments unconditionally, before its match:

def _handle(self, event: Event) -> None:
    self._event_count += 1

    match event:
        case AgentErrorEvent():   ...
        case ConversationErrorEvent():   ...
        case ConversationStateUpdateEvent():   ...

The subscriber registers through event_service.subscribe_to_events (conversation_service.py:2319), i.e. the same unfiltered PubSub as everything else, so it receives every token delta. The counter ships as event_count_bucket.

Repro

uv run pytest tests/agent_server/telemetry/ -q

Green today: no test asserts that deltas are excluded from event_count_bucket. To see the skew, run one conversation with stream=true and one without and compare the reported bucket.

Why it matters

The metric silently changes meaning depending on whether streaming was on and how verbose the model was. A streamed conversation with three tool calls can outscore a non-streamed conversation with thirty. Any dashboard or alert built on event_count_bucket is comparing token volume against conversation activity — and there is no way to tell from the data which one you're looking at.

Fix

Move the increment inside the match, or filter deltas before the subscriber sees them (same root cause, same one-line class of fix as the webhook issue). Note that either choice is a discontinuity in the existing metric; that's worth a heads-up to whoever consumes it rather than a silent correction.

Acceptance Criteria

  • Two identical conversations, one with stream=true and one without, report the same event_count_bucket.

Activity

  1. added
    bug
    on Aug 27, 2026
  2. github-actions commented on Aug 27, 2026

    @github-actions
    Contributor

    ✅ ready-for-dev label applied

    This issue meets the readiness criteria and is ready for contribution.
    A contributor can now open a PR that links this issue (Fixes #<number>).

    This is an automated check — no AI was used to generate this comment.

  3. self-assigned this
    on Aug 27, 2026
  4. added
    ready-for-dev
    on Aug 27, 2026
  5. added
    architecture
    priority:medium
    on Aug 28, 2026
  6. VascoSch92 commented on Aug 28, 2026

    @VascoSch92
    MemberAuthor

    Note for anyone landing here from #4671: this was closed by #4689 with a kind filter (Subscriber.receives_streaming_deltas), which is deliberately interim — the structural half, taking deltas off the shared bus entirely, is now #4696, added to the epic as step 1b. That step removes the flag.

    One side effect of the filter is tracked separately in #4695: _EventSubscriber does not opt in, and it is the subscriber that resets the runtime idle timer, so a long stream no longer keeps a managed pod alive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

architecturebugpriority:mediumready-for-dev

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions