@ai-sdk/anthropic 3.0.20 → 3.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +77 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -34
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +57 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +57 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.2.json +65 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.chunks.txt +115 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.2.json +69 -0
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.chunks.txt +119 -0
- package/src/anthropic-messages-language-model.test.ts +198 -0
- package/src/anthropic-messages-language-model.ts +38 -5
- package/src/anthropic-provider.test.ts +36 -0
- package/src/anthropic-provider.ts +32 -7
- package/src/tool/tool-search-bm25_20251119.ts +1 -0
- package/src/tool/tool-search-regex_20251119.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"tsup": "^8",
|
|
41
41
|
"typescript": "5.8.3",
|
|
42
42
|
"zod": "3.25.76",
|
|
43
|
-
"@ai-
|
|
44
|
-
"@
|
|
43
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
44
|
+
"@ai-sdk/test-server": "1.0.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
3
|
+
"id": "msg_01SyorFoaYHS6homn4ntwKWk",
|
|
4
|
+
"type": "message",
|
|
5
|
+
"role": "assistant",
|
|
6
|
+
"content": [
|
|
7
|
+
{
|
|
8
|
+
"type": "tool_search_tool_result",
|
|
9
|
+
"tool_use_id": "srvtoolu_01Daym2FbLXTL2hg6bVwCcoj",
|
|
10
|
+
"content": {
|
|
11
|
+
"type": "tool_search_tool_search_result",
|
|
12
|
+
"tool_references": [
|
|
13
|
+
{
|
|
14
|
+
"type": "tool_reference",
|
|
15
|
+
"tool_name": "executeEditorOperation"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "text",
|
|
22
|
+
"text": "Perfect! I can see the current structure has one bulleted list item with the text \"hi\". Now I need to add a new bullet point with \"bye\" after it. Let me use the `executeEditorOperation` tool to insert a new bulleted list item."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "tool_use",
|
|
26
|
+
"id": "toolu_019oFKxH7xzoKZtBX1mBGHeJ",
|
|
27
|
+
"name": "executeEditorOperation",
|
|
28
|
+
"input": {
|
|
29
|
+
"noteId": "d10aa585-982b-4bd9-984e-420f9b3717f7",
|
|
30
|
+
"operations": [
|
|
31
|
+
{
|
|
32
|
+
"op": "insert_node",
|
|
33
|
+
"at": {
|
|
34
|
+
"type": "path",
|
|
35
|
+
"path": [
|
|
36
|
+
1
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"type": "bulletedListItem",
|
|
40
|
+
"text": "bye"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"caller": {
|
|
45
|
+
"type": "direct"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"stop_reason": "tool_use",
|
|
50
|
+
"stop_sequence": null,
|
|
51
|
+
"usage": {
|
|
52
|
+
"input_tokens": 1398,
|
|
53
|
+
"cache_creation_input_tokens": 0,
|
|
54
|
+
"cache_read_input_tokens": 0,
|
|
55
|
+
"cache_creation": {
|
|
56
|
+
"ephemeral_5m_input_tokens": 0,
|
|
57
|
+
"ephemeral_1h_input_tokens": 0
|
|
58
|
+
},
|
|
59
|
+
"output_tokens": 213,
|
|
60
|
+
"service_tier": "standard",
|
|
61
|
+
"server_tool_use": {
|
|
62
|
+
"web_search_requests": 0
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_01WUP4eZFC22KbkesuJGqVAw","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":879,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":5,"service_tier":"standard"}}}
|
|
2
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
3
|
+
{"type":"ping"}
|
|
4
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"I'll help you with"}}
|
|
5
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" this"}}
|
|
6
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" task"}}
|
|
7
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":". Let me start by reading the note"}}
|
|
8
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" tree to see"}}
|
|
9
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the current structure, and then search"}}
|
|
10
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" for the right tools to add a"}}
|
|
11
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" bullet"}}
|
|
12
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" point"}}
|
|
13
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"."}}
|
|
14
|
+
{"type":"content_block_stop","index":0}
|
|
15
|
+
{"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01U8pzAHj2vNdPCA2Kf8JjeN","name":"readNoteTree","input":{},"caller":{"type":"direct"}}}
|
|
16
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
17
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{\"noteId\": \"d10aa585-982b"}}
|
|
18
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"-4bd9-984e-"}}
|
|
19
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"420f9b3717f7"}}
|
|
20
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"\"}"}}
|
|
21
|
+
{"type":"content_block_stop","index":1}
|
|
22
|
+
{"type":"content_block_start","index":2,"content_block":{"type":"server_tool_use","id":"srvtoolu_01FjZe9o4YXXJjGxLmfj44Rf","name":"tool_search_tool_bm25","input":{},"caller":{"type":"direct"}}}
|
|
23
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
24
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"{\"query\": \"ad"}}
|
|
25
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"d bullet"}}
|
|
26
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":" point insert"}}
|
|
27
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":" text"}}
|
|
28
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":" editor"}}
|
|
29
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\", \"limit\": 5"}}
|
|
30
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"}"}}
|
|
31
|
+
{"type":"content_block_stop","index":2}
|
|
32
|
+
{"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"input_tokens":879,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":177}}
|
|
33
|
+
{"type":"message_stop"}
|
|
34
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_014CbStN8SFzjGbDkZzTtD7i","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1398,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard"}}}
|
|
35
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"tool_search_tool_result","tool_use_id":"srvtoolu_01FjZe9o4YXXJjGxLmfj44Rf","content":{"type":"tool_search_tool_search_result","tool_references":[{"type":"tool_reference","tool_name":"executeEditorOperation"}]}}}
|
|
36
|
+
{"type":"content_block_stop","index":0}
|
|
37
|
+
{"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
|
|
38
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"Perfect"}}
|
|
39
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"! I can"}}
|
|
40
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" see the current"}}
|
|
41
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" note structure has"}}
|
|
42
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" one"}}
|
|
43
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" bull"}}
|
|
44
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"eted list item with"}}
|
|
45
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" the"}}
|
|
46
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" text \"hi\". Now I nee"}}
|
|
47
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"d to ad"}}
|
|
48
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"d a"}}
|
|
49
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" new bullet with"}}
|
|
50
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" \"bye\" after it"}}
|
|
51
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":". Let me use"}}
|
|
52
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" the `"}}
|
|
53
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"executeEditorOperation` tool"}}
|
|
54
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" to"}}
|
|
55
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" insert"}}
|
|
56
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" a"}}
|
|
57
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" new bull"}}
|
|
58
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"eted list item."}}
|
|
59
|
+
{"type":"content_block_stop","index":1}
|
|
60
|
+
{"type":"content_block_start","index":2,"content_block":{"type":"tool_use","id":"toolu_01QoRrvXNv6w4vZSyo9cnxP2","name":"executeEditorOperation","input":{},"caller":{"type":"direct"}}}
|
|
61
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
62
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"{\"noteId\": \"d10aa"}}
|
|
63
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"585-982b-4bd9"}}
|
|
64
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"-984e-420f9b"}}
|
|
65
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"3717f7"}}
|
|
66
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\", \"operations\": [\n {\n \"op"}}
|
|
67
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": \"insert_"}}
|
|
68
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"node"}}
|
|
69
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\",\n \"type"}}
|
|
70
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": \"bulletedListItem\","}}
|
|
71
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n \"text\": \"bye\","}}
|
|
72
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n \"at"}}
|
|
73
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": {\n \"type\": \""}}
|
|
74
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"path"}}
|
|
75
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\",\n \"path\": [1"}}
|
|
76
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"]\n }\n }"}}
|
|
77
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n]"}}
|
|
78
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"}"}}
|
|
79
|
+
{"type":"content_block_stop","index":2}
|
|
80
|
+
{"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"input_tokens":1398,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":213,"server_tool_use":{"web_search_requests":0}}}
|
|
81
|
+
{"type":"message_stop"}
|
|
82
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_01XnBpTaw23kf2UnGUdkKfey","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1639,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":6,"service_tier":"standard"}}}
|
|
83
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
84
|
+
{"type":"ping"}
|
|
85
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Great! I've successfully complete"}}
|
|
86
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d the task. Here"}}
|
|
87
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'s what I did:\n\n1."}}
|
|
88
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" **Read the note tree**:"}}
|
|
89
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" The"}}
|
|
90
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" note"}}
|
|
91
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" ha"}}
|
|
92
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d one"}}
|
|
93
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" bulleted list item containing"}}
|
|
94
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" \"hi\""}}
|
|
95
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n2. **Adde"}}
|
|
96
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d a"}}
|
|
97
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" new bullet**: I"}}
|
|
98
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" inserted a"}}
|
|
99
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" new bulleted list item with the"}}
|
|
100
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" text \"bye\" at"}}
|
|
101
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" position"}}
|
|
102
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" ["}}
|
|
103
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"1],"}}
|
|
104
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" which places"}}
|
|
105
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" it right"}}
|
|
106
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" after the \"hi\" bullet"}}
|
|
107
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n\nThe note now"}}
|
|
108
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" contains"}}
|
|
109
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":":\n- hi"}}
|
|
110
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n- bye\n\nThe operation"}}
|
|
111
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" was successful"}}
|
|
112
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"!"}}
|
|
113
|
+
{"type":"content_block_stop","index":0}
|
|
114
|
+
{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":1639,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":95}}
|
|
115
|
+
{"type":"message_stop"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
3
|
+
"id": "msg_01AyVh7iTyYup5o85hpFmYC1",
|
|
4
|
+
"type": "message",
|
|
5
|
+
"role": "assistant",
|
|
6
|
+
"content": [
|
|
7
|
+
{
|
|
8
|
+
"type": "tool_search_tool_result",
|
|
9
|
+
"tool_use_id": "srvtoolu_01WD1PoedV47LMZdJrsVNZtM",
|
|
10
|
+
"content": {
|
|
11
|
+
"type": "tool_search_tool_search_result",
|
|
12
|
+
"tool_references": [
|
|
13
|
+
{
|
|
14
|
+
"type": "tool_reference",
|
|
15
|
+
"tool_name": "readNoteTree"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "tool_reference",
|
|
19
|
+
"tool_name": "executeEditorOperation"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "text",
|
|
26
|
+
"text": "Good! I can see the current note structure has one bulleted list item with the text \"hi\". Now I need to add a new bullet point with \"bye\" after it. Let me use the `executeEditorOperation` tool to insert a new bulleted list item."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "tool_use",
|
|
30
|
+
"id": "toolu_01Vif37vPguXdx5yxixnpvpM",
|
|
31
|
+
"name": "executeEditorOperation",
|
|
32
|
+
"input": {
|
|
33
|
+
"noteId": "d10aa585-982b-4bd9-984e-420f9b3717f7",
|
|
34
|
+
"operations": [
|
|
35
|
+
{
|
|
36
|
+
"op": "insert_node",
|
|
37
|
+
"at": {
|
|
38
|
+
"type": "path",
|
|
39
|
+
"path": [
|
|
40
|
+
1
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"type": "bulletedListItem",
|
|
44
|
+
"text": "bye"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"caller": {
|
|
49
|
+
"type": "direct"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"stop_reason": "tool_use",
|
|
54
|
+
"stop_sequence": null,
|
|
55
|
+
"usage": {
|
|
56
|
+
"input_tokens": 1520,
|
|
57
|
+
"cache_creation_input_tokens": 0,
|
|
58
|
+
"cache_read_input_tokens": 0,
|
|
59
|
+
"cache_creation": {
|
|
60
|
+
"ephemeral_5m_input_tokens": 0,
|
|
61
|
+
"ephemeral_1h_input_tokens": 0
|
|
62
|
+
},
|
|
63
|
+
"output_tokens": 203,
|
|
64
|
+
"service_tier": "standard",
|
|
65
|
+
"server_tool_use": {
|
|
66
|
+
"web_search_requests": 0
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_01MCmfPn2yQ8Nfqz1cGmHe6K","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":904,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":5,"service_tier":"standard"}}}
|
|
2
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
3
|
+
{"type":"ping"}
|
|
4
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"I'll help you with"}}
|
|
5
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" this task. Let me start"}}
|
|
6
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" by reading the note tree to see"}}
|
|
7
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the current structure,"}}
|
|
8
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" an"}}
|
|
9
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d then search"}}
|
|
10
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" for the appropriate"}}
|
|
11
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" tools to add a"}}
|
|
12
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" bullet"}}
|
|
13
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"."}}
|
|
14
|
+
{"type":"content_block_stop","index":0}
|
|
15
|
+
{"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01WPkY6CkyJnFsaCqY7SZ9FX","name":"readNoteTree","input":{},"caller":{"type":"direct"}}}
|
|
16
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
17
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{\"noteId\": \"d10aa585-982b"}}
|
|
18
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"-4bd9-984e-"}}
|
|
19
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"420f9b3717f7"}}
|
|
20
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"\"}"}}
|
|
21
|
+
{"type":"content_block_stop","index":1}
|
|
22
|
+
{"type":"content_block_start","index":2,"content_block":{"type":"server_tool_use","id":"srvtoolu_01H4HgrFsi9xizPtvnx1Tm7D","name":"tool_search_tool_regex","input":{},"caller":{"type":"direct"}}}
|
|
23
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
24
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"{\"pattern\": \"ad"}}
|
|
25
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"d|"}}
|
|
26
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"insert"}}
|
|
27
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"|bullet"}}
|
|
28
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"|create"}}
|
|
29
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\", \"limit\": 10"}}
|
|
30
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"}"}}
|
|
31
|
+
{"type":"content_block_stop","index":2}
|
|
32
|
+
{"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"input_tokens":904,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":175}}
|
|
33
|
+
{"type":"message_stop"}
|
|
34
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_017tMyttPYQeSLKYEe8V9BN5","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1519,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard"}}}
|
|
35
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"tool_search_tool_result","tool_use_id":"srvtoolu_01H4HgrFsi9xizPtvnx1Tm7D","content":{"type":"tool_search_tool_search_result","tool_references":[{"type":"tool_reference","tool_name":"readNoteTree"},{"type":"tool_reference","tool_name":"executeEditorOperation"}]}}}
|
|
36
|
+
{"type":"content_block_stop","index":0}
|
|
37
|
+
{"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
|
|
38
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"Perfect"}}
|
|
39
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"! I can"}}
|
|
40
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" see the current"}}
|
|
41
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" note structure"}}
|
|
42
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" has"}}
|
|
43
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" one"}}
|
|
44
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" bull"}}
|
|
45
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"eted list"}}
|
|
46
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" item with"}}
|
|
47
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" the"}}
|
|
48
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" text \"hi\". Now I nee"}}
|
|
49
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"d to add \"bye\" as a new"}}
|
|
50
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" bullet after it"}}
|
|
51
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"."}}
|
|
52
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" Let"}}
|
|
53
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" me use"}}
|
|
54
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" the `"}}
|
|
55
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"executeEditorOperation` tool"}}
|
|
56
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" to insert"}}
|
|
57
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" a"}}
|
|
58
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":" new bull"}}
|
|
59
|
+
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"eted list item."}}
|
|
60
|
+
{"type":"content_block_stop","index":1}
|
|
61
|
+
{"type":"content_block_start","index":2,"content_block":{"type":"tool_use","id":"toolu_01UFHf8D27JBYu9FmrcjJk1p","name":"executeEditorOperation","input":{},"caller":{"type":"direct"}}}
|
|
62
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":""}}
|
|
63
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"{\"noteId\": \"d10aa585-982b"}}
|
|
64
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"-4bd9-984e-"}}
|
|
65
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"420f9b3717f7"}}
|
|
66
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\", \"operations\": ["}}
|
|
67
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n "}}
|
|
68
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"{\n \"op\": \"insert"}}
|
|
69
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\",\n \"type"}}
|
|
70
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": \"bulletedListItem\","}}
|
|
71
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n \"text"}}
|
|
72
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": \"bye\","}}
|
|
73
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n \"at"}}
|
|
74
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": {"}}
|
|
75
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n \"type"}}
|
|
76
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\": \"after"}}
|
|
77
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\",\n \"path\": [0"}}
|
|
78
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"]\n }\n }"}}
|
|
79
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"\n]"}}
|
|
80
|
+
{"type":"content_block_delta","index":2,"delta":{"type":"input_json_delta","partial_json":"}"}}
|
|
81
|
+
{"type":"content_block_stop","index":2}
|
|
82
|
+
{"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"input_tokens":1519,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":211,"server_tool_use":{"web_search_requests":0}}}
|
|
83
|
+
{"type":"message_stop"}
|
|
84
|
+
{"type":"message_start","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_01B2PApN3MtQ8zF4Xvnw6pvY","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1758,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":3,"service_tier":"standard"}}}
|
|
85
|
+
{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
|
|
86
|
+
{"type":"ping"}
|
|
87
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Great! I"}}
|
|
88
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'ve successfully complete"}}
|
|
89
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d the task. Here"}}
|
|
90
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'s what I did:\n\n1."}}
|
|
91
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" **Rea"}}
|
|
92
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d the note tree**:"}}
|
|
93
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" The"}}
|
|
94
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" note containe"}}
|
|
95
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d one"}}
|
|
96
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" bulleted list item with the"}}
|
|
97
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" text \"hi\""}}
|
|
98
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" at"}}
|
|
99
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" path"}}
|
|
100
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" [0]"}}
|
|
101
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n2. **Added \"bye\""}}
|
|
102
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" as a new bullet**: I"}}
|
|
103
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" use"}}
|
|
104
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"d the `executeEditorOperation` tool"}}
|
|
105
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" to insert a new bulleted list item"}}
|
|
106
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" with"}}
|
|
107
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the text \"bye\" after"}}
|
|
108
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the \"hi\" bullet"}}
|
|
109
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" ("}}
|
|
110
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"at path [0])\n\nThe operation"}}
|
|
111
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" was successful"}}
|
|
112
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":","}}
|
|
113
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" and the note now contains"}}
|
|
114
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" two bulleted list items:"}}
|
|
115
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n- hi"}}
|
|
116
|
+
{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n- bye"}}
|
|
117
|
+
{"type":"content_block_stop","index":0}
|
|
118
|
+
{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":1758,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":118}}
|
|
119
|
+
{"type":"message_stop"}
|
|
@@ -3020,6 +3020,104 @@ describe('AnthropicMessagesLanguageModel', () => {
|
|
|
3020
3020
|
expect(result.content).toMatchSnapshot();
|
|
3021
3021
|
});
|
|
3022
3022
|
});
|
|
3023
|
+
|
|
3024
|
+
describe('deferred result - bm25 variant', () => {
|
|
3025
|
+
it('should correctly map tool_search_tool_result when result comes without server_tool_use in same response', async () => {
|
|
3026
|
+
prepareJsonFixtureResponse('anthropic-tool-search-deferred-bm25.2');
|
|
3027
|
+
|
|
3028
|
+
const result = await provider('claude-sonnet-4-5').doGenerate({
|
|
3029
|
+
prompt: [
|
|
3030
|
+
{
|
|
3031
|
+
role: 'user',
|
|
3032
|
+
content: [
|
|
3033
|
+
{
|
|
3034
|
+
type: 'text',
|
|
3035
|
+
text: 'What is the weather in San Francisco?',
|
|
3036
|
+
},
|
|
3037
|
+
],
|
|
3038
|
+
},
|
|
3039
|
+
],
|
|
3040
|
+
tools: [
|
|
3041
|
+
{
|
|
3042
|
+
type: 'provider',
|
|
3043
|
+
id: 'anthropic.tool_search_bm25_20251119',
|
|
3044
|
+
name: 'tool_search',
|
|
3045
|
+
args: {},
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
type: 'function',
|
|
3049
|
+
name: 'get_weather',
|
|
3050
|
+
description: 'Get the current weather at a specific location',
|
|
3051
|
+
inputSchema: {
|
|
3052
|
+
type: 'object',
|
|
3053
|
+
properties: {
|
|
3054
|
+
location: { type: 'string' },
|
|
3055
|
+
},
|
|
3056
|
+
},
|
|
3057
|
+
providerOptions: {
|
|
3058
|
+
anthropic: { deferLoading: true },
|
|
3059
|
+
},
|
|
3060
|
+
},
|
|
3061
|
+
],
|
|
3062
|
+
});
|
|
3063
|
+
|
|
3064
|
+
// The tool result should be correctly mapped to 'tool_search' (the user's custom name)
|
|
3065
|
+
// even though serverToolCalls map is empty (no server_tool_use in this response)
|
|
3066
|
+
const toolResult = result.content.find(
|
|
3067
|
+
part => part.type === 'tool-result',
|
|
3068
|
+
);
|
|
3069
|
+
expect(toolResult).toBeDefined();
|
|
3070
|
+
expect(toolResult?.toolName).toBe('tool_search');
|
|
3071
|
+
});
|
|
3072
|
+
});
|
|
3073
|
+
|
|
3074
|
+
describe('deferred result - regex variant', () => {
|
|
3075
|
+
it('should correctly map tool_search_tool_result when result comes without server_tool_use in same response', async () => {
|
|
3076
|
+
prepareJsonFixtureResponse('anthropic-tool-search-deferred-regex.2');
|
|
3077
|
+
|
|
3078
|
+
const result = await provider('claude-sonnet-4-5').doGenerate({
|
|
3079
|
+
prompt: [
|
|
3080
|
+
{
|
|
3081
|
+
role: 'user',
|
|
3082
|
+
content: [
|
|
3083
|
+
{
|
|
3084
|
+
type: 'text',
|
|
3085
|
+
text: 'Find weather data in NYC',
|
|
3086
|
+
},
|
|
3087
|
+
],
|
|
3088
|
+
},
|
|
3089
|
+
],
|
|
3090
|
+
tools: [
|
|
3091
|
+
{
|
|
3092
|
+
type: 'provider',
|
|
3093
|
+
id: 'anthropic.tool_search_regex_20251119',
|
|
3094
|
+
name: 'tool_search',
|
|
3095
|
+
args: {},
|
|
3096
|
+
},
|
|
3097
|
+
{
|
|
3098
|
+
type: 'function',
|
|
3099
|
+
name: 'get_temp_data',
|
|
3100
|
+
description: 'For a location',
|
|
3101
|
+
inputSchema: {
|
|
3102
|
+
type: 'object',
|
|
3103
|
+
properties: {
|
|
3104
|
+
location: { type: 'string' },
|
|
3105
|
+
},
|
|
3106
|
+
},
|
|
3107
|
+
providerOptions: {
|
|
3108
|
+
anthropic: { deferLoading: true },
|
|
3109
|
+
},
|
|
3110
|
+
},
|
|
3111
|
+
],
|
|
3112
|
+
});
|
|
3113
|
+
|
|
3114
|
+
const toolResult = result.content.find(
|
|
3115
|
+
part => part.type === 'tool-result',
|
|
3116
|
+
);
|
|
3117
|
+
expect(toolResult).toBeDefined();
|
|
3118
|
+
expect(toolResult?.toolName).toBe('tool_search');
|
|
3119
|
+
});
|
|
3120
|
+
});
|
|
3023
3121
|
});
|
|
3024
3122
|
|
|
3025
3123
|
describe('mcp servers', () => {
|
|
@@ -6845,6 +6943,106 @@ describe('AnthropicMessagesLanguageModel', () => {
|
|
|
6845
6943
|
).toMatchSnapshot();
|
|
6846
6944
|
});
|
|
6847
6945
|
});
|
|
6946
|
+
|
|
6947
|
+
describe('deferred result - bm25 variant', () => {
|
|
6948
|
+
it('should correctly map tool_search_tool_result when result comes without server_tool_use in same response', async () => {
|
|
6949
|
+
prepareChunksFixtureResponse('anthropic-tool-search-deferred-bm25');
|
|
6950
|
+
|
|
6951
|
+
const result = await provider('claude-sonnet-4-5').doStream({
|
|
6952
|
+
prompt: [
|
|
6953
|
+
{
|
|
6954
|
+
role: 'user',
|
|
6955
|
+
content: [
|
|
6956
|
+
{
|
|
6957
|
+
type: 'text',
|
|
6958
|
+
text: 'What is the weather in San Francisco?',
|
|
6959
|
+
},
|
|
6960
|
+
],
|
|
6961
|
+
},
|
|
6962
|
+
],
|
|
6963
|
+
tools: [
|
|
6964
|
+
{
|
|
6965
|
+
type: 'provider',
|
|
6966
|
+
id: 'anthropic.tool_search_bm25_20251119',
|
|
6967
|
+
name: 'tool_search',
|
|
6968
|
+
args: {},
|
|
6969
|
+
},
|
|
6970
|
+
{
|
|
6971
|
+
type: 'function',
|
|
6972
|
+
name: 'get_weather',
|
|
6973
|
+
description: 'Get the current weather at a specific location',
|
|
6974
|
+
inputSchema: {
|
|
6975
|
+
type: 'object',
|
|
6976
|
+
properties: {
|
|
6977
|
+
location: { type: 'string' },
|
|
6978
|
+
},
|
|
6979
|
+
},
|
|
6980
|
+
providerOptions: {
|
|
6981
|
+
anthropic: { deferLoading: true },
|
|
6982
|
+
},
|
|
6983
|
+
},
|
|
6984
|
+
],
|
|
6985
|
+
});
|
|
6986
|
+
|
|
6987
|
+
const chunks = await convertReadableStreamToArray(result.stream);
|
|
6988
|
+
|
|
6989
|
+
const toolResultChunk = chunks.find(
|
|
6990
|
+
chunk => chunk.type === 'tool-result',
|
|
6991
|
+
);
|
|
6992
|
+
expect(toolResultChunk).toBeDefined();
|
|
6993
|
+
expect(toolResultChunk?.toolName).toBe('tool_search');
|
|
6994
|
+
});
|
|
6995
|
+
});
|
|
6996
|
+
|
|
6997
|
+
describe('deferred result - regex variant', () => {
|
|
6998
|
+
it('should correctly map tool_search_tool_result when result comes without server_tool_use in same response', async () => {
|
|
6999
|
+
prepareChunksFixtureResponse('anthropic-tool-search-deferred-regex');
|
|
7000
|
+
|
|
7001
|
+
const result = await provider('claude-sonnet-4-5').doStream({
|
|
7002
|
+
prompt: [
|
|
7003
|
+
{
|
|
7004
|
+
role: 'user',
|
|
7005
|
+
content: [
|
|
7006
|
+
{
|
|
7007
|
+
type: 'text',
|
|
7008
|
+
text: 'Find weather data in NYC',
|
|
7009
|
+
},
|
|
7010
|
+
],
|
|
7011
|
+
},
|
|
7012
|
+
],
|
|
7013
|
+
tools: [
|
|
7014
|
+
{
|
|
7015
|
+
type: 'provider',
|
|
7016
|
+
id: 'anthropic.tool_search_regex_20251119',
|
|
7017
|
+
name: 'tool_search',
|
|
7018
|
+
args: {},
|
|
7019
|
+
},
|
|
7020
|
+
{
|
|
7021
|
+
type: 'function',
|
|
7022
|
+
name: 'get_temp_data',
|
|
7023
|
+
description: 'For a location',
|
|
7024
|
+
inputSchema: {
|
|
7025
|
+
type: 'object',
|
|
7026
|
+
properties: {
|
|
7027
|
+
location: { type: 'string' },
|
|
7028
|
+
},
|
|
7029
|
+
},
|
|
7030
|
+
providerOptions: {
|
|
7031
|
+
anthropic: { deferLoading: true },
|
|
7032
|
+
},
|
|
7033
|
+
},
|
|
7034
|
+
],
|
|
7035
|
+
});
|
|
7036
|
+
|
|
7037
|
+
const chunks = await convertReadableStreamToArray(result.stream);
|
|
7038
|
+
|
|
7039
|
+
const toolResultChunk = chunks.find(
|
|
7040
|
+
chunk => chunk.type === 'tool-result',
|
|
7041
|
+
);
|
|
7042
|
+
expect(toolResultChunk).toBeDefined();
|
|
7043
|
+
expect(toolResultChunk?.toolName).toBe('tool_search');
|
|
7044
|
+
});
|
|
7045
|
+
});
|
|
6848
7046
|
});
|
|
6849
7047
|
|
|
6850
7048
|
it('should throw an api error when the server is returning a 529 overloaded error', async () => {
|