Skip to content

Commit 4e87648

Browse files
committed
test(anthropic): add test for merging custom anthropic-beta header
1 parent 80f210f commit 4e87648

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/anthropic/src/anthropic-messages-language-model.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,34 @@ describe('AnthropicMessagesLanguageModel', () => {
36783678
`);
36793679
});
36803680

3681+
it('should merge custom anthropic-beta header with fine-grained-tool-streaming beta', async () => {
3682+
server.urls['https://api.anthropic.com/v1/messages'].response = {
3683+
type: 'stream-chunks',
3684+
chunks: [
3685+
`data: {"type":"message_start","message":{"id":"msg_01KfpJoAEabmH2iHRRFjQMAG","type":"message","role":"assistant","content":[],"model":"claude-3-haiku-20240307","stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":17,"output_tokens":1}}}\n\n`,
3686+
`data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}\n\n`,
3687+
`data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello, World!"}}\n\n`,
3688+
`data: {"type":"content_block_stop","index":0}\n\n`,
3689+
`data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":227}}\n\n`,
3690+
`data: {"type":"message_stop"}\n\n`,
3691+
],
3692+
};
3693+
3694+
const provider = createAnthropic({
3695+
apiKey: 'test-api-key',
3696+
headers: {
3697+
'anthropic-beta': 'context-1m-2025-08-07',
3698+
},
3699+
});
3700+
3701+
await provider('claude-3-haiku-20240307').doStream({
3702+
prompt: TEST_PROMPT,
3703+
});
3704+
3705+
expect(server.calls[0].requestHeaders['anthropic-beta']).toContain('fine-grained-tool-streaming-2025-05-14');
3706+
expect(server.calls[0].requestHeaders['anthropic-beta']).toContain('context-1m-2025-08-07');
3707+
});
3708+
36813709
it('should support cache control', async () => {
36823710
server.urls['https://api.anthropic.com/v1/messages'].response = {
36833711
type: 'stream-chunks',

0 commit comments

Comments
 (0)