fix(telemetry): describe option objects in the session report - #7127
Merged
Conversation
davidzhao
force-pushed
the
dz/telemetry-session-options-describe
branch
from
September 5, 2026 21:00
2511a5c to
d7d15d6
Compare
chenghao-mou
reviewed
Sep 6, 2026
`session.options` in the session report carried the turn detector as its
default repr (`<livekit.agents.inference.eot.detector.TurnDetector object at
0x...>`), because the OTel exporter stringifies any non-primitive attribute.
Serialize option values explicitly: primitives and containers pass through,
and any other object is rendered from a whitelist of public attributes as
`ClassName(model=..., provider=..., ...)`. The whitelist keeps credentials and
internals out of the report. `TurnDetector` exposes `sample_rate`,
`local_fallback`, and the threshold overrides so the description shows its
config, e.g.
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.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
tts_text_transforms accepts any Sequence, so a user-defined one collapsed to its class name in the session report; serialize elements for every non-string Sequence and Set instead of only list and tuple. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
stt_context_options.keyterm_detection.instructions is a customer-authored prompt override and can embed anything about their business or users; the report has no use for it, so `instructions` keys are dropped at any depth rather than emitted under an unmarked key. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidzhao
force-pushed
the
dz/telemetry-session-options-describe
branch
from
September 6, 2026 16:48
d0c3596 to
e7e80a1
Compare
Replace the global attribute whitelist with a per-class protocol. An object in the session options is reported as module.Class; one that implements telemetry.DescribesOptions (a describe_options() method) as module.Class(k=v, ...). The object decides what is safe to show, so nothing is guessed from public attributes and credentials stay out by construction. TurnDetector reports model, provider, sample rate, local fallback and the threshold overrides the user set. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
chenghao-mou
approved these changes
Sep 6, 2026
u9g
reviewed
Sep 7, 2026
| if is_given(thresholds.overrides): | ||
| options["threshold_overrides"] = thresholds.overrides | ||
| if is_given(thresholds.backchannel_overrides): | ||
| options["backchannel_threshold_overrides"] = thresholds.backchannel_overrides |
Contributor
There was a problem hiding this comment.
I think it would have made sense to call this threshold_backchannel_overrides, in the style of the rest of the names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
session.optionsin the session report carried the turn detector as its default repr: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_optionsnow serializes explicitly: primitives pass through, mappings recurse, any non-stringSequenceorSetis serialized elementwise (tts_text_transformsaccepts anySequence), and any other object is reported by class,module.Class. An object that wants its configuration shown implements thetelemetry.DescribesOptionsprotocol, adescribe_options()method returning the options worth reporting; it is then rendered asmodule.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 failingdescribe_options()falls back to the class name).instructionskeys (the keyterm-detection prompt override) are dropped at any depth rather than emitted under an unmarked key.TurnDetectorimplementsdescribe_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:
with
threshold_overrides/backchannel_threshold_overridesappended 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, customSequenceandSetvalues, omitted prompt text, nested containers and thekeytermsPII alias, and a JSON-safety invariant on the whole serialized dict.Bottom layer of the tracing coverage stack.
🤖 Generated with Claude Code