From f7a80037d8d7d48e309e88bf7dfb48c8206a8265 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Fri, 10 Apr 2026 12:23:48 +0200 Subject: [PATCH] test(openai): Use multi-message scenario in no-truncation test Ensures message popping doesn't occur when enableTruncation is false by testing with 3 messages instead of 1. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../suites/tracing/openai/scenario-no-truncation.mjs | 8 ++++++-- .../suites/tracing/openai/test.ts | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/openai/scenario-no-truncation.mjs b/dev-packages/node-integration-tests/suites/tracing/openai/scenario-no-truncation.mjs index f19345653c07..f7195f35befb 100644 --- a/dev-packages/node-integration-tests/suites/tracing/openai/scenario-no-truncation.mjs +++ b/dev-packages/node-integration-tests/suites/tracing/openai/scenario-no-truncation.mjs @@ -60,11 +60,15 @@ async function run() { apiKey: 'mock-api-key', }); - // Chat completion with long content (would normally be truncated) + // Multiple messages with long content (would normally be truncated and popped to last message only) const longContent = 'A'.repeat(50_000); await client.chat.completions.create({ model: 'gpt-4', - messages: [{ role: 'user', content: longContent }], + messages: [ + { role: 'user', content: longContent }, + { role: 'assistant', content: 'Some reply' }, + { role: 'user', content: 'Follow-up question' }, + ], }); // Responses API with long string input (would normally be truncated) diff --git a/dev-packages/node-integration-tests/suites/tracing/openai/test.ts b/dev-packages/node-integration-tests/suites/tracing/openai/test.ts index d3bdc0a6a80c..56b324d0de67 100644 --- a/dev-packages/node-integration-tests/suites/tracing/openai/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/openai/test.ts @@ -350,11 +350,15 @@ describe('OpenAI integration', () => { const EXPECTED_TRANSACTION_NO_TRUNCATION = { transaction: 'main', spans: expect.arrayContaining([ - // Chat completion with long content should not be truncated + // Multiple messages should all be preserved (no popping to last message only) expect.objectContaining({ data: expect.objectContaining({ - [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([{ role: 'user', content: longContent }]), - [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 1, + [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([ + { role: 'user', content: longContent }, + { role: 'assistant', content: 'Some reply' }, + { role: 'user', content: 'Follow-up question' }, + ]), + [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 3, }), }), // Responses API long string input should not be truncated or wrapped in quotes