Skip to content

Python: [Bug]: Duplicate LLM Telemetry Emission #4675

Closed

Description

@sphenry

Description

Same gen_ai.response.id emitted across multiple spans/services, inflating token and cost accounting in Application Insights. Usage dashboards and cost assertions require manual de-dup logic; raw queries overcount by ~2x.

Workaround is to designate responsesapi as canonical source

Code Sample

Error Messages / Stack Traces

Package Versions

python-1.0.0rc4

Python Version

No response

Additional Context

No response

Activity

  1. added
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    on Mar 13, 2026
  2. eavanvalkenburg commented on Mar 13, 2026

    @eavanvalkenburg
    Member

    I have a fix up in PR #4685:

    The change uses ContextVar-based ownership so the outer agent span stops duplicating gen_ai.response.id and token-usage telemetry that already belongs to the inner chat span, while still preserving agent-level response telemetry for agents that do not rely on a chat client.

  3. moved this from In Review to Done in Agent Frameworkon Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions