Skip to content

Commit 9f4c05d

Browse files
Qardclaude
andcommitted
test(e2e): add extended thinking coverage to anthropic-instrumentation scenario
Add a streaming extended thinking operation (`anthropic-stream-thinking-operation`) to the anthropic-instrumentation e2e scenario, covering the `thinking_delta` event handling and `thinking` content block preservation fixed in this PR. - Enable `supportsThinking` for SDK versions v0712, v0730, v0780, v0800 - Use `claude-sonnet-4-5` with `thinking: { type: "enabled", budget_tokens: 1024 }` - Assert that thinking and text blocks both appear in captured output - Normalize thinking content and variable token counts for stable snapshots - Update span/payload snapshots for all four thinking-capable versions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f937a64 commit 9f4c05d

19 files changed

+536
-31
lines changed

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0712.log-payloads.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,56 @@
302302
},
303303
"type": "llm"
304304
},
305+
{
306+
"metadata": {
307+
"operation": "stream-thinking"
308+
},
309+
"metrics": {
310+
"end": 0,
311+
"start": 0
312+
},
313+
"name": "anthropic-stream-thinking-operation",
314+
"type": null
315+
},
316+
{
317+
"input": [
318+
{
319+
"content": "What is 2+2? Reply with the number only.",
320+
"role": "user"
321+
}
322+
],
323+
"metadata": {
324+
"model": "claude-sonnet-4-5",
325+
"provider": "anthropic",
326+
"stop_reason": "end_turn",
327+
"stop_sequence": null
328+
},
329+
"metrics": {
330+
"completion_tokens": 0,
331+
"end": 0,
332+
"prompt_cache_creation_tokens": 0,
333+
"prompt_cached_tokens": 0,
334+
"prompt_tokens": 49,
335+
"start": 0,
336+
"time_to_first_token": 0,
337+
"tokens": 0
338+
},
339+
"name": "anthropic.messages.create",
340+
"output": {
341+
"content": [
342+
{
343+
"thinking": "<thinking-content>",
344+
"type": "thinking"
345+
},
346+
{
347+
"text": "<thinking-answer>",
348+
"type": "text"
349+
}
350+
],
351+
"role": "assistant"
352+
},
353+
"type": "llm"
354+
},
305355
{
306356
"metadata": {
307357
"operation": "beta-create"

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0712.span-events.json

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@
244244
"has_input": false,
245245
"has_output": false,
246246
"metadata": {
247-
"operation": "beta-create"
247+
"operation": "stream-thinking"
248248
},
249249
"metric_keys": [],
250-
"name": "anthropic-beta-create-operation",
250+
"name": "anthropic-stream-thinking-operation",
251251
"root_span_id": "<span:1>",
252252
"span_id": "<span:14>",
253253
"span_parents": [
@@ -259,7 +259,7 @@
259259
"has_input": true,
260260
"has_output": true,
261261
"metadata": {
262-
"model": "claude-3-haiku-20240307",
262+
"model": "claude-sonnet-4-5",
263263
"provider": "anthropic"
264264
},
265265
"metric_keys": [
@@ -282,10 +282,10 @@
282282
"has_input": false,
283283
"has_output": false,
284284
"metadata": {
285-
"operation": "beta-stream"
285+
"operation": "beta-create"
286286
},
287287
"metric_keys": [],
288-
"name": "anthropic-beta-stream-operation",
288+
"name": "anthropic-beta-create-operation",
289289
"root_span_id": "<span:1>",
290290
"span_id": "<span:16>",
291291
"span_parents": [
@@ -315,5 +315,43 @@
315315
"<span:16>"
316316
],
317317
"type": "llm"
318+
},
319+
{
320+
"has_input": false,
321+
"has_output": false,
322+
"metadata": {
323+
"operation": "beta-stream"
324+
},
325+
"metric_keys": [],
326+
"name": "anthropic-beta-stream-operation",
327+
"root_span_id": "<span:1>",
328+
"span_id": "<span:18>",
329+
"span_parents": [
330+
"<span:1>"
331+
],
332+
"type": null
333+
},
334+
{
335+
"has_input": true,
336+
"has_output": true,
337+
"metadata": {
338+
"model": "claude-3-haiku-20240307",
339+
"provider": "anthropic"
340+
},
341+
"metric_keys": [
342+
"completion_tokens",
343+
"prompt_cache_creation_tokens",
344+
"prompt_cached_tokens",
345+
"prompt_tokens",
346+
"time_to_first_token",
347+
"tokens"
348+
],
349+
"name": "anthropic.messages.create",
350+
"root_span_id": "<span:1>",
351+
"span_id": "<span:19>",
352+
"span_parents": [
353+
"<span:18>"
354+
],
355+
"type": "llm"
318356
}
319357
]

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0730.log-payloads.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,56 @@
302302
},
303303
"type": "llm"
304304
},
305+
{
306+
"metadata": {
307+
"operation": "stream-thinking"
308+
},
309+
"metrics": {
310+
"end": 0,
311+
"start": 0
312+
},
313+
"name": "anthropic-stream-thinking-operation",
314+
"type": null
315+
},
316+
{
317+
"input": [
318+
{
319+
"content": "What is 2+2? Reply with the number only.",
320+
"role": "user"
321+
}
322+
],
323+
"metadata": {
324+
"model": "claude-sonnet-4-5",
325+
"provider": "anthropic",
326+
"stop_reason": "end_turn",
327+
"stop_sequence": null
328+
},
329+
"metrics": {
330+
"completion_tokens": 0,
331+
"end": 0,
332+
"prompt_cache_creation_tokens": 0,
333+
"prompt_cached_tokens": 0,
334+
"prompt_tokens": 49,
335+
"start": 0,
336+
"time_to_first_token": 0,
337+
"tokens": 0
338+
},
339+
"name": "anthropic.messages.create",
340+
"output": {
341+
"content": [
342+
{
343+
"thinking": "<thinking-content>",
344+
"type": "thinking"
345+
},
346+
{
347+
"text": "<thinking-answer>",
348+
"type": "text"
349+
}
350+
],
351+
"role": "assistant"
352+
},
353+
"type": "llm"
354+
},
305355
{
306356
"metadata": {
307357
"operation": "beta-create"

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0730.span-events.json

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@
244244
"has_input": false,
245245
"has_output": false,
246246
"metadata": {
247-
"operation": "beta-create"
247+
"operation": "stream-thinking"
248248
},
249249
"metric_keys": [],
250-
"name": "anthropic-beta-create-operation",
250+
"name": "anthropic-stream-thinking-operation",
251251
"root_span_id": "<span:1>",
252252
"span_id": "<span:14>",
253253
"span_parents": [
@@ -259,7 +259,7 @@
259259
"has_input": true,
260260
"has_output": true,
261261
"metadata": {
262-
"model": "claude-3-haiku-20240307",
262+
"model": "claude-sonnet-4-5",
263263
"provider": "anthropic"
264264
},
265265
"metric_keys": [
@@ -282,10 +282,10 @@
282282
"has_input": false,
283283
"has_output": false,
284284
"metadata": {
285-
"operation": "beta-stream"
285+
"operation": "beta-create"
286286
},
287287
"metric_keys": [],
288-
"name": "anthropic-beta-stream-operation",
288+
"name": "anthropic-beta-create-operation",
289289
"root_span_id": "<span:1>",
290290
"span_id": "<span:16>",
291291
"span_parents": [
@@ -315,5 +315,43 @@
315315
"<span:16>"
316316
],
317317
"type": "llm"
318+
},
319+
{
320+
"has_input": false,
321+
"has_output": false,
322+
"metadata": {
323+
"operation": "beta-stream"
324+
},
325+
"metric_keys": [],
326+
"name": "anthropic-beta-stream-operation",
327+
"root_span_id": "<span:1>",
328+
"span_id": "<span:18>",
329+
"span_parents": [
330+
"<span:1>"
331+
],
332+
"type": null
333+
},
334+
{
335+
"has_input": true,
336+
"has_output": true,
337+
"metadata": {
338+
"model": "claude-3-haiku-20240307",
339+
"provider": "anthropic"
340+
},
341+
"metric_keys": [
342+
"completion_tokens",
343+
"prompt_cache_creation_tokens",
344+
"prompt_cached_tokens",
345+
"prompt_tokens",
346+
"time_to_first_token",
347+
"tokens"
348+
],
349+
"name": "anthropic.messages.create",
350+
"root_span_id": "<span:1>",
351+
"span_id": "<span:19>",
352+
"span_parents": [
353+
"<span:18>"
354+
],
355+
"type": "llm"
318356
}
319357
]

e2e/scenarios/anthropic-instrumentation/__snapshots__/anthropic-v0780.log-payloads.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,56 @@
302302
},
303303
"type": "llm"
304304
},
305+
{
306+
"metadata": {
307+
"operation": "stream-thinking"
308+
},
309+
"metrics": {
310+
"end": 0,
311+
"start": 0
312+
},
313+
"name": "anthropic-stream-thinking-operation",
314+
"type": null
315+
},
316+
{
317+
"input": [
318+
{
319+
"content": "What is 2+2? Reply with the number only.",
320+
"role": "user"
321+
}
322+
],
323+
"metadata": {
324+
"model": "claude-sonnet-4-5",
325+
"provider": "anthropic",
326+
"stop_reason": "end_turn",
327+
"stop_sequence": null
328+
},
329+
"metrics": {
330+
"completion_tokens": 0,
331+
"end": 0,
332+
"prompt_cache_creation_tokens": 0,
333+
"prompt_cached_tokens": 0,
334+
"prompt_tokens": 49,
335+
"start": 0,
336+
"time_to_first_token": 0,
337+
"tokens": 0
338+
},
339+
"name": "anthropic.messages.create",
340+
"output": {
341+
"content": [
342+
{
343+
"thinking": "<thinking-content>",
344+
"type": "thinking"
345+
},
346+
{
347+
"text": "<thinking-answer>",
348+
"type": "text"
349+
}
350+
],
351+
"role": "assistant"
352+
},
353+
"type": "llm"
354+
},
305355
{
306356
"metadata": {
307357
"operation": "beta-create"

0 commit comments

Comments
 (0)