Skip to content

Commit 2692738

Browse files
committed
multi-message test
1 parent 85f9cd2 commit 2692738

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

dev-packages/node-integration-tests/suites/tracing/anthropic/scenario-no-truncation.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ async function run() {
2929
const mockClient = new MockAnthropic({ apiKey: 'mock-api-key' });
3030
const client = instrumentAnthropicAiClient(mockClient, { enableTruncation: false, recordInputs: true });
3131

32-
// Long array messages (would normally be truncated)
32+
// Multiple messages with long content (would normally be truncated and popped to last message only)
3333
const longContent = 'A'.repeat(50_000);
3434
await client.messages.create({
3535
model: 'claude-3-haiku-20240307',
3636
max_tokens: 100,
37-
messages: [{ role: 'user', content: longContent }],
37+
messages: [
38+
{ role: 'user', content: longContent },
39+
{ role: 'assistant', content: 'Some reply' },
40+
{ role: 'user', content: 'Follow-up question' },
41+
],
3842
});
3943

4044
// Long string input (messagesFromParams wraps it in an array)

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,15 @@ describe('Anthropic integration', () => {
809809
const EXPECTED_TRANSACTION_NO_TRUNCATION = {
810810
transaction: 'main',
811811
spans: expect.arrayContaining([
812-
// Long array messages should not be truncated
812+
// Multiple messages should all be preserved (no popping to last message only)
813813
expect.objectContaining({
814814
data: expect.objectContaining({
815-
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([{ role: 'user', content: longContent }]),
816-
[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 1,
815+
[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: JSON.stringify([
816+
{ role: 'user', content: longContent },
817+
{ role: 'assistant', content: 'Some reply' },
818+
{ role: 'user', content: 'Follow-up question' },
819+
]),
820+
[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 3,
817821
}),
818822
}),
819823
// Long string input should not be truncated (messagesFromParams wraps it in an array)

0 commit comments

Comments
 (0)