Skip to content

Commit 75738e6

Browse files
committed
Flatten available tools in google-genai
1 parent 7efb1d2 commit 75738e6

File tree

2 files changed

+6
-3
lines changed
  • dev-packages/node-integration-tests/suites/tracing/google-genai
  • packages/core/src/tracing/google-genai

2 files changed

+6
-3
lines changed

dev-packages/node-integration-tests/suites/tracing/google-genai/test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ describe('Google GenAI integration', () => {
204204
});
205205
});
206206

207+
const EXPECTED_AVAILABLE_TOOLS_JSON =
208+
'[{\"name\":\"controlLight\",\"parametersJsonSchema\":{\"type\":\"object\",\"properties\":{\"brightness\":{\"type\":\"number\"},\"colorTemperature\":{\"type\":\"string\"}},\"required\":[\"brightness\",\"colorTemperature\"]}}]';
209+
207210
const EXPECTED_TRANSACTION_TOOLS = {
208211
transaction: 'main',
209212
spans: expect.arrayContaining([
@@ -215,7 +218,7 @@ describe('Google GenAI integration', () => {
215218
'sentry.origin': 'auto.ai.google_genai',
216219
'gen_ai.system': 'google_genai',
217220
'gen_ai.request.model': 'gemini-2.0-flash-001',
218-
'gen_ai.request.available_tools': expect.any(String), // Should include tools
221+
'gen_ai.request.available_tools': EXPECTED_AVAILABLE_TOOLS_JSON,
219222
'gen_ai.request.messages': expect.any(String), // Should include contents
220223
'gen_ai.response.text': expect.any(String), // Should include response text
221224
'gen_ai.response.tool_calls': expect.any(String), // Should include tool calls
@@ -236,7 +239,7 @@ describe('Google GenAI integration', () => {
236239
'sentry.origin': 'auto.ai.google_genai',
237240
'gen_ai.system': 'google_genai',
238241
'gen_ai.request.model': 'gemini-2.0-flash-001',
239-
'gen_ai.request.available_tools': expect.any(String), // Should include tools
242+
'gen_ai.request.available_tools': EXPECTED_AVAILABLE_TOOLS_JSON,
240243
'gen_ai.request.messages': expect.any(String), // Should include contents
241244
'gen_ai.response.streaming': true,
242245
'gen_ai.response.text': expect.any(String), // Should include response text

packages/core/src/tracing/google-genai/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function extractRequestAttributes(
115115

116116
// Extract available tools from config
117117
if ('tools' in config && Array.isArray(config.tools)) {
118-
const functionDeclarations = config.tools.map(
118+
const functionDeclarations = config.tools.flatMap(
119119
(tool: { functionDeclarations: unknown[] }) => tool.functionDeclarations,
120120
);
121121
attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(functionDeclarations);

0 commit comments

Comments
 (0)