fix(server-utils): Gate gen_ai.tool.definitions on dataCollection.genAI.inputs - #24088
fix(server-utils): Gate gen_ai.tool.definitions on dataCollection.genAI.inputs#24088s1gr1d wants to merge 2 commits into
gen_ai.tool.definitions on dataCollection.genAI.inputs#24088Conversation
…genAI.inputs` Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
size-limit report 📦
|
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>
|
|
||
| // 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); |
There was a problem hiding this comment.
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`.
There was a problem hiding this comment.
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.
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.definitionseven withgenAI.inputs: false, so a tool schema naming your internal endpoints still went out.Each
extractRequestAttributesnow takesrecordInputsand skips the attribute when it is off. An integration-levelrecordInputsstill wins over the global option.Fixes #24083