From 776a948eff52c89cc1b1c9bfc2c17807e87c9e1a Mon Sep 17 00:00:00 2001 From: Patrick Ribbsaeter Date: Sun, 26 Jul 2026 22:31:57 +0200 Subject: [PATCH] fix: use a stable SDK user agent --- tests/index.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/index.test.ts b/tests/index.test.ts index 5aa8b84..3472592 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -49,6 +49,19 @@ describe('instantiate client', () => { }); expect(req.headers.has('x-my-default-header')).toBe(false); }); + + test('uses a stable user agent for subclasses', async () => { + class MinifiedClient extends Anthropic {} + + const subclassedClient = new MinifiedClient({ + baseURL: 'http://localhost:5000/', + apiKey: 'my-anthropic-api-key', + }); + const { req } = await subclassedClient.buildRequest({ path: '/foo', method: 'post' }); + + expect(req.headers.get('user-agent')).toMatch(/^Anthropic\/JS /); + expect(req.headers.get('user-agent')).not.toContain('MinifiedClient'); + }); }); describe('logging', () => { const env = process.env; -- 2.55.0.windows.3