Skip to content

Config key experimental.openTelemetryChatContent keeps chat content off the AI SDK spans - #7

Merged
TheFabFab merged 1 commit into
documentor-pgfrom
documentor-otel-chat-content
Oct 13, 2026
Merged

TheFabFab merged 1 commit into
documentor-pgfrom
documentor-otel-chat-content

Conversation

@TheFabFab

Copy link
Copy Markdown
Owner

What

A second boolean beside experimental.openTelemetry: experimental.openTelemetryChatContent. Both experimental_telemetry blocks (session/llm.ts, agent/agent.ts) pass it as the AI SDK's recordInputs / recordOutputs.

  • Absent or false: the ai.streamText / ai.streamText.doStream spans carry model, provider, usage, finish reason, timings, session.id and the telemetry metadata, and no ai.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* and ai.response.text at 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 in packages/opencode/test/session/llm.test.ts run the real streamText against the mocked OpenAI endpoint with an InMemorySpanExporter and assert the span attributes in both positions. Without the llm.ts change the off-case fails on ai.prompt being present.

Also run locally against Postgres 18.4: llm.test.ts and config.test.ts in full (143 pass), bun turbo typecheck for opencode and @opencode-ai/core, and packages/client check:generated. packages/sdk/js/src/v2/gen/types.gen.ts is regenerated (one line). documentor/FORK.md records the upstream files changed.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

Copy link
Copy Markdown

Hey! Your PR title Config key experimental.openTelemetryChatContent keeps chat content off the AI SDK spans doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@TheFabFab
TheFabFab merged commit fd92f17 into documentor-pg Oct 13, 2026
6 of 11 checks passed
@TheFabFab
TheFabFab deleted the documentor-otel-chat-content branch October 13, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant