Skip to content

fix(server-utils): Gate gen_ai.tool.definitions on dataCollection.genAI.inputs - #24088

Open
s1gr1d wants to merge 2 commits into
developfrom
sig/dc-genai-tool-definitions
Open

fix(server-utils): Gate gen_ai.tool.definitions on dataCollection.genAI.inputs#24088
s1gr1d wants to merge 2 commits into
developfrom
sig/dc-genai-tool-definitions

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 4, 2026

Copy link
Copy Markdown
Member

Spec 0.9.1 counts tool definitions as generative AI input data, next to system instructions and prompt messages. Only the Vercel AI integration treated them that way. OpenAI, Anthropic, Google GenAI, LangChain and LangGraph attached gen_ai.tool.definitions even with genAI.inputs: false, so a tool schema naming your internal endpoints still went out.

Each extractRequestAttributes now takes recordInputs and skips the attribute when it is off. An integration-level recordInputs still wins over the global option.

Fixes #24083

…genAI.inputs`

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@s1gr1d
s1gr1d marked this pull request as ready for review September 4, 2026 12:11
@s1gr1d
s1gr1d requested a review from a team as a code owner September 4, 2026 12:11
@s1gr1d
s1gr1d requested review from stephanie-anderson and removed request for a team September 4, 2026 12:11
Comment thread packages/server-utils/src/ai/langgraph/index.ts
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.69 kB added added
@sentry/browser - with treeshaking flags 26.99 kB added added
@sentry/browser - with treeshaking flags tracing without tracing 26.89 kB added added
@sentry/browser (incl. Tracing) 49.07 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 49.07 kB added added
@sentry/browser (incl. Tracing, Profiling) 51.98 kB added added
@sentry/browser (incl. Tracing, Replay) 88.62 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.85 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 93.3 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 106.24 kB added added
@sentry/browser (incl. Feedback) 46.17 kB added added
@sentry/browser (incl. sendFeedback) 33.75 kB added added
@sentry/browser (incl. FeedbackAsync) 38.85 kB added added
@sentry/browser (incl. Metrics) 29.66 kB added added
@sentry/browser (incl. Logs) 29.94 kB added added
@sentry/browser (incl. Metrics & Logs) 30.59 kB added added
@sentry/react 30.45 kB added added
@sentry/react (incl. Tracing) 51.28 kB added added
@sentry/vue 35.91 kB added added
@sentry/vue (incl. Tracing) 51.34 kB added added
@sentry/svelte 28.71 kB added added
CDN Bundle 30.43 kB added added
CDN Bundle (incl. Tracing) 49.6 kB added added
CDN Bundle (incl. Logs, Metrics) 32.66 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 51.53 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 73.31 kB added added
CDN Bundle (incl. Tracing, Replay) 87.15 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.02 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 93.08 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.03 kB added added
CDN Bundle - uncompressed 90.13 kB added added
CDN Bundle (incl. Tracing) - uncompressed 147.81 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.52 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.59 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.82 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.44 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.21 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.15 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.9 kB added added
@sentry/nextjs (client) 53.89 kB added added
@sentry/sveltekit (client) 49.51 kB added added
@sentry/core/server 40.96 kB added added
@sentry/core/browser 13.53 kB added added
@sentry/node 124.78 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB added added
@sentry/node - without tracing 88.5 kB added added
@sentry/node - without channel injection 104.1 kB added added
@sentry/aws-serverless 96.87 kB added added
@sentry/cloudflare (withSentry) - minified 201.56 kB added added
@sentry/cloudflare (withSentry) 501.37 kB added added

View base workflow run

Resolve the recording options in `instrumentStateGraphCompile` too, so the
exported entry point keeps the `dataCollection` defaults.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@s1gr1d
s1gr1d requested a review from a team as a code owner September 4, 2026 12:36
@s1gr1d
s1gr1d requested review from isaacs and mydea and removed request for a team September 4, 2026 12:36

// This is exported, so callers can hand us an options object with no recording flags set. Resolving
// here (rather than only in `instrumentStateGraph`) keeps that path on the `dataCollection` defaults.
const options = resolveAIRecordingOptions(rawOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The LangGraph integration passes unresolved options to instrumentCompiledGraphInvoke, causing recordInputs to be undefined and preventing tool extraction even when globally enabled.
Severity: MEDIUM

Suggested Fix

In packages/server-utils/src/integrations/langgraph.ts, the call to wrapCompiledGraphInvoke should pass the resolvedOptions variable instead of the original options parameter. This ensures instrumentCompiledGraphInvoke receives fully resolved recording options.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/ai/langgraph/index.ts#L48

Potential issue: In the diagnostics-channel integration for LangGraph, the
`wrapCompiledGraphInvoke` function is called with an unresolved `options` object. This
object is then passed to `instrumentCompiledGraphInvoke`, which incorrectly assumes the
options have been resolved. When `options.recordInputs` is `undefined`, the logic to
extract tool definitions from the graph instance is skipped. This prevents tool data
from being recorded, even if data collection for inputs is enabled globally via
`dataCollection.genAI.inputs`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive. Both wrapCompiledGraphInvoke calls in integrations/langgraph.ts already pass resolvedOptions (lines 58 and 87), built on line 47 from resolveAIRecordingOptions(options). The suggested fix describes what the code already does.

All three callers of instrumentCompiledGraphInvoke pass resolved options: the diagnostics-channel integration, instrumentCreateReactAgent (line 205), and instrumentStateGraphCompile since the previous commit. instrumentCompiledGraphInvoke is not exported from any package entry point, so no unresolved path is left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dataCollection.genAI.inputs does not gate gen_ai.tool.definitions

1 participant