telemetry: recordInputs/recordOutputs: false still deliver prompt and reply to global integrations and the ai:telemetry channel
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):
augmentEventcopiesrecordInputs,recordOutputs,functionId,aiVersiononto the event; its optionalfilterContextargument filters onlyruntimeContext,toolsContextandtoolContext. No content field is removed when a flag isfalse.createTelemetryDispatcherpassesaugmentEvent(event, telemetryMetadata)to each integration callback; per-callintegrationstake precedence over globally registered ones, andisEnabled === falsereturns{}.createRestrictedTelemetryDispatcher$3(used bygenerateText) filters contexts only;onStartforwards the rest of the event unchanged.- In
generateText,generateTextStartEventcontainsinstructionsandmessages(the prompt) and is passed torunInTracingChannelSpan, which publishes it onai: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
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.
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.