Repository navigation
Config key experimental.openTelemetryChatContent keeps chat content off the AI SDK spans - #7
Merged
Conversation
…ff the AI SDK spans The AI SDK records the prompt and the response text on every ai.* span unless recordInputs and recordOutputs are exactly false, and upstream's experimental_telemetry blocks set neither. Both blocks now pass the new boolean, so a config that enables openTelemetry gets model, usage, timing and ids on its spans and nothing a user typed or the model answered, unless it also sets openTelemetryChatContent to true. Two documentor: cases in test/session/llm.test.ts run a real streamText against the mocked OpenAI endpoint with an in-memory span exporter and assert the attributes in both positions of the switch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
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
A second boolean beside
experimental.openTelemetry:experimental.openTelemetryChatContent. Bothexperimental_telemetryblocks (session/llm.ts,agent/agent.ts) pass it as the AI SDK'srecordInputs/recordOutputs.false: theai.streamText/ai.streamText.doStreamspans carry model, provider, usage, finish reason, timings,session.idand the telemetry metadata, and noai.prompt*/ai.response.text.true: upstream behaviour, full prompt and reply on the spans.Absent means off on purpose: a deployment that forgets the key loses chat content from its traces rather than leaking it.
Why
DocuMentor's prompts hold personal data about third parties. The bare upstream boolean records them on every span, which is why DocuMentor strips
ai.prompt*andai.response.textat its OTel collector today (KPG issue anomalyco#530, the OpenCode telemetry content ticket). With the switch at the source, the collector workaround can be retired once DocuMentor pins a build that carries it.Tests
Two
documentor:cases inpackages/opencode/test/session/llm.test.tsrun the realstreamTextagainst the mocked OpenAI endpoint with anInMemorySpanExporterand assert the span attributes in both positions. Without thellm.tschange the off-case fails onai.promptbeing present.Also run locally against Postgres 18.4:
llm.test.tsandconfig.test.tsin full (143 pass),bun turbo typecheckforopencodeand@opencode-ai/core, andpackages/clientcheck:generated.packages/sdk/js/src/v2/gen/types.gen.tsis regenerated (one line).documentor/FORK.mdrecords the upstream files changed.🤖 Generated with Claude Code