Skip to content

Commit d07536c

Browse files
s1gr1dclaude
andcommitted
test: Drop tool definitions from the genAI-disabled openai assertions
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>
1 parent d2efd0b commit d07536c

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

  • dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls
  • packages/server-utils/src/ai/langgraph

‎dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls/test.ts‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ describe('OpenAI Tool Calls integration', () => {
105105
type: 'string',
106106
value: 'gpt-4',
107107
});
108-
expect(chatToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toEqual({
109-
type: 'string',
110-
value: WEATHER_TOOL_DEFINITION,
111-
});
108+
// Tool definitions are gen AI input data, so `genAI.inputs: false` drops them.
109+
expect(chatToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toBeUndefined();
112110
expect(chatToolsSpan!.attributes[GEN_AI_RESPONSE_MODEL]).toEqual({
113111
type: 'string',
114112
value: 'gpt-4',
@@ -164,10 +162,7 @@ describe('OpenAI Tool Calls integration', () => {
164162
type: 'boolean',
165163
value: true,
166164
});
167-
expect(streamingChatToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toEqual({
168-
type: 'string',
169-
value: WEATHER_TOOL_DEFINITION,
170-
});
165+
expect(streamingChatToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toBeUndefined();
171166
expect(streamingChatToolsSpan!.attributes[GEN_AI_RESPONSE_MODEL]).toEqual({
172167
type: 'string',
173168
value: 'gpt-4',
@@ -224,10 +219,7 @@ describe('OpenAI Tool Calls integration', () => {
224219
value: 'gpt-4',
225220
});
226221
expect(responsesToolsSpan!.attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE]).toBeUndefined();
227-
expect(responsesToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toEqual({
228-
type: 'string',
229-
value: WEATHER_TOOL_DEFINITION,
230-
});
222+
expect(responsesToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toBeUndefined();
231223
expect(responsesToolsSpan!.attributes[GEN_AI_RESPONSE_MODEL]).toEqual({
232224
type: 'string',
233225
value: 'gpt-4',
@@ -283,10 +275,7 @@ describe('OpenAI Tool Calls integration', () => {
283275
type: 'boolean',
284276
value: true,
285277
});
286-
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toEqual({
287-
type: 'string',
288-
value: WEATHER_TOOL_DEFINITION,
289-
});
278+
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_TOOL_DEFINITIONS]).toBeUndefined();
290279
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_RESPONSE_MODEL]).toEqual({
291280
type: 'string',
292281
value: 'gpt-4',

‎packages/server-utils/src/ai/langgraph/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ const SENTRY_PATCHED = '__sentry_patched__';
3737
*/
3838
export function instrumentStateGraphCompile(
3939
originalCompile: (...args: unknown[]) => CompiledGraph,
40-
options: LangGraphOptions,
40+
rawOptions: LangGraphOptions,
4141
): (...args: unknown[]) => CompiledGraph {
4242
if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {
4343
return originalCompile;
4444
}
4545

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

4851
const wrapped = new Proxy(originalCompile, {

0 commit comments

Comments
 (0)