Skip to content

fix(telemetry): describe option objects in the session report - #2431

Merged
davidzhao merged 2 commits into
mainfrom
yore-gangly-darted
Sep 7, 2026
Merged

fix(telemetry): describe option objects in the session report#2431
davidzhao merged 2 commits into
mainfrom
yore-gangly-darted

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Ports livekit/agents#7127.

Summary

  • serialize session option values into JSON-safe primitives and containers
  • expose telemetry.DescribesOptions so option objects explicitly control safe telemetry descriptions
  • describe TurnDetector configuration without credentials or endpoints
  • omit customer-authored instructions recursively and retain PII aliases
  • include the effective default turn detector in session report options
Source diff coverage
  • livekit-agents/livekit/agents/inference/eot/detector.py: ported to agents/src/inference/eot/detector.ts. describe_options() becomes describeOptions() and fields use target camelCase conventions; the target always supports local fallback, so localFallback is reported as true.
  • livekit-agents/livekit/agents/telemetry/__init__.py: ported to agents/src/telemetry/index.ts. The Python protocol export becomes the public structural TypeScript interface DescribesOptions.
  • livekit-agents/livekit/agents/telemetry/traces.py: ported to agents/src/telemetry/traces.ts. Python mappings, sequences, sets, and module.Class names are adapted to JS records/maps, iterables, sets, and stable constructor names. Recursive aliases, prompt omission, deterministic descriptions, failure fallback, and JSON safety are preserved.
  • tests/test_session_options_report.py: adapted into agents/src/telemetry/traces.test.ts, following the target co-located Vitest convention. Every source test behavior is covered: default detector, threshold overrides, credential safety, mode strings, opt-in and opaque objects, sparse/failing descriptions, custom iterables and sets, prompt omission, nested aliases, and JSON safety.

Target infrastructure adaptation: agents/src/voice/agent_session.ts stores the eager effective default detector in reportable session options, matching the Python options object used by the source serializer. agents/etc/agents.api.md and the patch changeset are updated for the new public API.

No source files were omitted and there are no infrastructure gaps.

Validation

  • pnpm test agents (151 files, 2,486 passed, 5 skipped)
  • pnpm build:agents
  • pnpm --filter @livekit/agents lint
  • pnpm exec prettier --check "agents/src/**/*.ts"
  • pnpm --filter @livekit/agents api:check

Ported from livekit/agents#7127

Original PR description

What

session.options in the session report carried the turn detector as its default repr:

turn_detection: "<livekit.agents.inference.eot.detector.TurnDetector object at 0x7fc5518a2a50>"

The OTel exporter stringifies any non-primitive log attribute, so anything left as an object in the options dict ends up like this.

How

  • _serialize_session_options now serializes explicitly: primitives pass through, mappings recurse, any non-string Sequence or Set is serialized elementwise (tts_text_transforms accepts any Sequence), and any other object is reported by class, module.Class. An object that wants its configuration shown implements the telemetry.DescribesOptions protocol, a describe_options() method returning the options worth reporting; it is then rendered as module.Class(k=v, ...). The object decides what is safe to show, so nothing is guessed from public attributes and credentials and endpoints stay out by construction (test included; a failing describe_options() falls back to the class name).
  • Customer-authored prompt text is never written to the report: instructions keys (the keyterm-detection prompt override) are dropped at any depth rather than emitted under an unmarked key.
  • TurnDetector implements describe_options(): model, provider, sample rate, local fallback, and the threshold overrides only when the user set any. Mode strings ("vad", "manual", ...) pass through unchanged. Third-party detectors and models opt in the same way.

Result:

livekit.agents.inference.eot.detector.TurnDetector(model=turn-detector-v1-mini, provider=livekit, sample_rate=16000, local_fallback=True)

with threshold_overrides / backchannel_threshold_overrides appended only when the user set them.

Tests

tests/test_session_options_report.py (unit): default detector description, threshold overrides, no credential leakage, mode strings, plugin-like objects, custom Sequence and Set values, omitted prompt text, nested containers and the keyterms PII alias, and a JSON-safety invariant on the whole serialized dict.

Bottom layer of the tracing coverage stack.

🤖 Generated with Claude Code

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner September 7, 2026 05:19
@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc729ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 38 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 2 potential issues.

Devin Review

Comment thread agents/src/telemetry/traces.ts
Comment thread agents/src/telemetry/traces.ts Outdated

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread agents/src/telemetry/traces.ts
@davidzhao
davidzhao merged commit 6b44bca into main Sep 7, 2026
6 checks passed
@davidzhao
davidzhao deleted the yore-gangly-darted branch September 7, 2026 07:16
@github-actions github-actions Bot mentioned this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant