ai icon indicating copy to clipboard operation
ai copied to clipboard

telemetry: recordInputs/recordOutputs: false still deliver prompt and reply to global integrations and the ai:telemetry channel

Open MRCORD opened this issue 1 month ago • 2 comments

Description

Follow-up to #21442 / #21447 (fixed in 7.0.114), which made the ai:telemetry channel filter runtimeContext, toolsContext and toolContext. The same filtering does not seem to apply to prompt and reply content. The docs say of recordInputs: "You might want to disable input recording to avoid recording sensitive information". We build a library for agents that handle sensitive conversations and rely on that.

READ in [email protected] (dist/index.js):

  • augmentEvent copies recordInputs, recordOutputs, functionId, aiVersion onto the event; its optional filterContext argument filters only runtimeContext, toolsContext and toolContext. No content field is removed when a flag is false.
  • createTelemetryDispatcher passes augmentEvent(event, telemetryMetadata) to each integration callback; per-call integrations take precedence over globally registered ones, and isEnabled === false returns {}.
  • createRestrictedTelemetryDispatcher$3 (used by generateText) filters contexts only; onStart forwards the rest of the event unchanged.
  • In generateText, generateTextStartEvent contains instructions and messages (the prompt) and is passed to runInTracingChannelSpan, which publishes it on ai:telemetry.

So, as read: any globally registered integration, and any subscriber to the channel, receives the prompt even with both flags false; the flags are only copied onto the event as fields.

RUN (Node v26.3.1, [email protected], snippet below): with both flags false, a registerTelemetry integration's onStart event contained the prompt string (and recordInputs was false), and channel messages contained both the prompt and the reply string. Not tested: @ai-sdk/otel, or non-Node runtimes on 7.0.159.

Possible asks (any one): (1) apply the flags centrally in the dispatcher and on the channel, as #21447 did for contexts; (2) a switch that stops channel publication or global integrations without isEnabled: false; (3) document that integrations must honour the flags.

Reproduction

import { generateText, registerTelemetry } from "ai";
import { MockLanguageModelV4 } from "ai/test";
import dc from "node:diagnostics_channel";

const seen = [], chan = [];
registerTelemetry({ onStart: (e) => seen.push(e) });
dc.tracingChannel("ai:telemetry").subscribe({ start: (m) => chan.push(m) });

const model = new MockLanguageModelV4({
  doGenerate: async () => ({
    content: [{ type: "text", text: "reply-canary-7d3" }],
    finishReason: { unified: "stop", raw: "stop" },
    usage: { inputTokens: { total: 1, noCache: 1 }, outputTokens: { total: 1, text: 1 } },
    warnings: [],
  }),
});
await generateText({
  model, prompt: "prompt-canary-7d3",
  telemetry: { recordInputs: false, recordOutputs: false },
});
console.log(JSON.stringify(seen).includes("prompt-canary-7d3"));  // true
console.log(JSON.stringify(chan).includes("prompt-canary-7d3"), JSON.stringify(chan).includes("reply-canary-7d3")); // true true

AI SDK Version

ai 7.0.159

MRCORD avatar Nov 02 '26 14:11 MRCORD

Identify issue type

Identified as Bug
Confidence: High

Rationale

The issue demonstrates current telemetry behavior exposing content despite disabled input/output recording flags, contradicting the documented expectation. Suggested fixes or documentation alternatives do not supersede the concrete failure.

Evidence

  • In [email protected], the reproduction shows a globally registered telemetry integration receives the prompt despite recordInputs: false.
  • The ai:telemetry channel receives both prompt and reply content with recordInputs and recordOutputs set to false.
  • The report cites documentation describing recordInputs as a way to avoid recording sensitive information.

ai-sdk-factory[bot] avatar Nov 02 '26 14:11 ai-sdk-factory[bot]

Identify bug discovery

Discovery source: discovery:audit (high confidence).

The report presents a source-code inspection followed by a targeted mock-model test. Although the author describes building a sensitive-conversation library, no actual production failure is established.

  • The description explicitly labels its analysis “READ in [email protected] (dist/index.js)” and traces several internal telemetry functions.
  • The author derives the suspected behavior from code: “So, as read” integrations and channel subscribers receive prompts despite disabled recording flags.
  • A separately labeled “RUN” section confirms that analysis using a MockLanguageModelV4 and canary prompt/reply strings.
  • The statement “We build a library for agents that handle sensitive conversations” supplies motivation, but does not establish discovery during production use.

ai-sdk-factory[bot] avatar Nov 02 '26 14:11 ai-sdk-factory[bot]