Skip to content

tests(core): Move anthropic node integration tests to use a real client#21906

Merged
nicohrubec merged 1 commit into
developfrom
nh/anthropic-stream-real-sdk
Jul 2, 2026
Merged

tests(core): Move anthropic node integration tests to use a real client#21906
nicohrubec merged 1 commit into
developfrom
nh/anthropic-stream-real-sdk

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Jul 1, 2026

Copy link
Copy Markdown
Member

While working on the orchestrion port for the anthropic instrumentation I noticed that all of the anthropic tests use fake clients instead of the pattern openai uses with a real client and a mocked server. Since the client is what we instrument it should be much more useful to use the real one in our tests and also allows to reuse all the scenarios here for the orchestrion port, since orchestrion instruments the real library source so that doesn't work with a fake.

This PR ports all the tests to a real client. Porting this over also uncovered a minor bug where the stop reason is not being recorded correctly during streaming (will fix in a follow up).

@nicohrubec nicohrubec changed the title test(anthropic): Use the real SDK in the streaming scenario fix(core): Capture Anthropic stream stop_reason from message_delta Jul 1, 2026
Replaces the hand-written MockAnthropic classes across the anthropic
node-integration-test scenarios (streaming, tools, errors, and truncation) with
the real @anthropic-ai/sdk driven by express mock servers, matching the rest of
the suite. Removes the redundant manual-client scenario — the auto integration
already wraps clients via the same instrumentAnthropicAiClient it would exercise.

No SDK/instrumentation behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec force-pushed the nh/anthropic-stream-real-sdk branch from 5b08c83 to 3b1d083 Compare July 1, 2026 18:36
@nicohrubec nicohrubec changed the title fix(core): Capture Anthropic stream stop_reason from message_delta tests(core): Move anthropic node integration tests to use a real client Jul 1, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3b1d083. Configure here.

@@ -1,115 +0,0 @@
import { instrumentAnthropicAiClient } from '@sentry/core';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should be redundant, since the auto-instrumentation basically just calls the manual instrumentation helper internally so no need to have a separate scenario for that

@nicohrubec nicohrubec marked this pull request as ready for review July 2, 2026 06:09
@nicohrubec nicohrubec requested a review from a team as a code owner July 2, 2026 06:09
@nicohrubec nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a team July 2, 2026 06:09

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Getting rid of mocks is always great

@nicohrubec nicohrubec merged commit 81aa319 into develop Jul 2, 2026
86 of 88 checks passed
@nicohrubec nicohrubec deleted the nh/anthropic-stream-real-sdk branch July 2, 2026 10:25
nicohrubec added a commit that referenced this pull request Jul 2, 2026
… client (#21909)

similar to #21906

Using a real client should generally be more useful as this is what we
instrument and also allows us to reuse the integration suites for our
orchestrion ports since orchestrion injects the channels only in the
real client.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants