Skip to content

Commit 4236d96

Browse files
authored
chore(ai): update ai-sdk tests for recent version (#7234)
* add test fixes * missing cassettes
1 parent 05e6e69 commit 4236d96

13 files changed

Lines changed: 1556 additions & 32 deletions

packages/datadog-plugin-ai/test/index.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ describe('Plugin', () => {
273273
age: { type: 'number' },
274274
height: { type: 'string' }
275275
},
276-
required: ['name', 'age', 'height']
276+
required: ['name', 'age', 'height'],
277+
additionalProperties: false
277278
})
278279

279280
const result = await ai.generateObject({
@@ -429,7 +430,8 @@ describe('Plugin', () => {
429430
age: { type: 'number' },
430431
height: { type: 'string' }
431432
},
432-
required: ['name', 'age', 'height']
433+
required: ['name', 'age', 'height'],
434+
additionalProperties: false
433435
})
434436

435437
const result = await ai.streamObject({
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
interactions:
2+
- request:
3+
body: '{"model":"gpt-4o-mini","temperature":0,"messages":[{"role":"user","content":"Invent
4+
a character for a video game"}],"tool_choice":{"type":"function","function":{"name":"json"}},"tools":[{"type":"function","function":{"name":"json","description":"Respond
5+
with a JSON object.","parameters":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"number"},"height":{"type":"string"}},"required":["name","age","height"],"additionalProperties":false}}}]}'
6+
headers:
7+
? !!python/object/apply:multidict._multidict.istr
8+
- Accept
9+
: - '*/*'
10+
? !!python/object/apply:multidict._multidict.istr
11+
- Accept-Encoding
12+
: - gzip, deflate
13+
? !!python/object/apply:multidict._multidict.istr
14+
- Accept-Language
15+
: - '*'
16+
? !!python/object/apply:multidict._multidict.istr
17+
- Connection
18+
: - keep-alive
19+
Content-Length:
20+
- '464'
21+
? !!python/object/apply:multidict._multidict.istr
22+
- Content-Type
23+
: - application/json
24+
? !!python/object/apply:multidict._multidict.istr
25+
- User-Agent
26+
: - node
27+
? !!python/object/apply:multidict._multidict.istr
28+
- sec-fetch-mode
29+
: - cors
30+
method: POST
31+
uri: https://api.openai.com/v1/chat/completions
32+
response:
33+
body:
34+
string: "{\n \"id\": \"chatcmpl-Cxc8cvHFMENkylaqycEpNYMl7MiPs\",\n \"object\":
35+
\"chat.completion\",\n \"created\": 1768323990,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
36+
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
37+
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
38+
\ \"id\": \"call_sdrxtylGQJySVuv8ODVMOTTl\",\n \"type\":
39+
\"function\",\n \"function\": {\n \"name\": \"json\",\n
40+
\ \"arguments\": \"{\\\"name\\\":\\\"Zara Nightshade\\\",\\\"age\\\":28,\\\"height\\\":\\\"5'7\\\\\\\"\\\"}\"\n
41+
\ }\n }\n ],\n \"refusal\": null,\n \"annotations\":
42+
[]\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
43+
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 65,\n \"completion_tokens\":
44+
19,\n \"total_tokens\": 84,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
45+
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
46+
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
47+
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
48+
\"default\",\n \"system_fingerprint\": \"fp_29330a9688\"\n}\n"
49+
headers:
50+
CF-RAY:
51+
- 9bd67c088c742093-IAD
52+
Connection:
53+
- keep-alive
54+
Content-Encoding:
55+
- gzip
56+
Content-Type:
57+
- application/json
58+
Date:
59+
- Tue, 13 Jan 2026 17:06:30 GMT
60+
Server:
61+
- cloudflare
62+
Set-Cookie:
63+
- __cf_bm=Fqc_F7Rowrqreuix92cKbv1MPAO_neQepyE3CrD5g_8-1768323990-1.0.1.1-Fc.8BXyuNvFRX.aZZ0zD9zthOFqFYZhRfPZIk32.baYB7Q_lFFVj8gsMzMwcTrLTWJGuSXTLjMUMzkdxMqeYmGiEpldK.jJbQRBMyWfG2_c;
64+
path=/; expires=Tue, 13-Jan-26 17:36:30 GMT; domain=.api.openai.com; HttpOnly;
65+
Secure; SameSite=None
66+
- _cfuvid=97XA0.6ERmaHlYbP4D_97VfE_UzuDrBMZbUItMAT5FE-1768323990918-0.0.1.1-604800000;
67+
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
68+
Strict-Transport-Security:
69+
- max-age=31536000; includeSubDomains; preload
70+
Transfer-Encoding:
71+
- chunked
72+
X-Content-Type-Options:
73+
- nosniff
74+
access-control-expose-headers:
75+
- X-Request-ID
76+
alt-svc:
77+
- h3=":443"; ma=86400
78+
cf-cache-status:
79+
- DYNAMIC
80+
openai-organization:
81+
- datadog-staging
82+
openai-processing-ms:
83+
- '881'
84+
openai-project:
85+
- proj_gt6TQZPRbZfoY2J9AQlEJMpd
86+
openai-version:
87+
- '2020-10-01'
88+
x-envoy-upstream-service-time:
89+
- '896'
90+
x-openai-proxy-wasm:
91+
- v0.1
92+
x-ratelimit-limit-requests:
93+
- '30000'
94+
x-ratelimit-limit-tokens:
95+
- '150000000'
96+
x-ratelimit-remaining-requests:
97+
- '29999'
98+
x-ratelimit-remaining-tokens:
99+
- '149999987'
100+
x-ratelimit-reset-requests:
101+
- 2ms
102+
x-ratelimit-reset-tokens:
103+
- 0s
104+
x-request-id:
105+
- req_7c8b95f20ebd40c48d7cf16926c4f211
106+
status:
107+
code: 200
108+
message: OK
109+
version: 1
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
interactions:
2+
- request:
3+
body: '{"model":"gpt-4o-mini","temperature":0,"messages":[{"role":"user","content":"Invent
4+
a character for a video game"}],"tool_choice":{"type":"function","function":{"name":"json"}},"tools":[{"type":"function","function":{"name":"json","description":"Respond
5+
with a JSON object.","parameters":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"number"},"height":{"type":"string"}},"required":["name","age","height"],"additionalProperties":false}}}],"stream":true,"stream_options":{"include_usage":true}}'
6+
headers:
7+
? !!python/object/apply:multidict._multidict.istr
8+
- Accept
9+
: - '*/*'
10+
? !!python/object/apply:multidict._multidict.istr
11+
- Accept-Encoding
12+
: - gzip, deflate
13+
? !!python/object/apply:multidict._multidict.istr
14+
- Accept-Language
15+
: - '*'
16+
? !!python/object/apply:multidict._multidict.istr
17+
- Connection
18+
: - keep-alive
19+
Content-Length:
20+
- '518'
21+
? !!python/object/apply:multidict._multidict.istr
22+
- Content-Type
23+
: - application/json
24+
? !!python/object/apply:multidict._multidict.istr
25+
- User-Agent
26+
: - node
27+
? !!python/object/apply:multidict._multidict.istr
28+
- sec-fetch-mode
29+
: - cors
30+
method: POST
31+
uri: https://api.openai.com/v1/chat/completions
32+
response:
33+
body:
34+
string: 'data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_O3NCxnSPqpfNJSbyGZ5TprnX","type":"function","function":{"name":"json","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"EVikkqZ9g7g"}
35+
36+
37+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Qc1FIvqm2L7Jz3"}
38+
39+
40+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"name"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"2j8DsF7lK84MF"}
41+
42+
43+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"RpwvB5kMO1RD"}
44+
45+
46+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Z"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":""}
47+
48+
49+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ara"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"p48KmfzRHGcL2N"}
50+
51+
52+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
53+
Wind"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"kFS1OrPTBXeK"}
54+
55+
56+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"r"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":""}
57+
58+
59+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ider"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"u1G3vP26il6Tr"}
60+
61+
62+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"dyxlDAvaad6o"}
63+
64+
65+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"age"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"On2U2q6hoqqtnP"}
66+
67+
68+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Ig4tYbRAWjzMUn"}
69+
70+
71+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"28"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Z73S6eRQlvt8q30"}
72+
73+
74+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"73QYFzW0YDfvE5"}
75+
76+
77+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"height"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"wYqQSZENkaw"}
78+
79+
80+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"6Nq8cxSlE9op"}
81+
82+
83+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"5"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":""}
84+
85+
86+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"''"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":""}
87+
88+
89+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"7"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":""}
90+
91+
92+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\\\""}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ViZdGZ6i85HVR"}
93+
94+
95+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"GIi7VnNE95XoKz"}
96+
97+
98+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null,"obfuscation":"RSIrV"}
99+
100+
101+
data: {"id":"chatcmpl-Cxc9Rr7xSrEtVgoph8jxJl7twoiid","object":"chat.completion.chunk","created":1768324041,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_29330a9688","choices":[],"usage":{"prompt_tokens":65,"completion_tokens":20,"total_tokens":85,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}},"obfuscation":"tJm017bY6q"}
102+
103+
104+
data: [DONE]
105+
106+
107+
'
108+
headers:
109+
CF-RAY:
110+
- 9bd67d4a0e5f82f6-IAD
111+
Connection:
112+
- keep-alive
113+
Content-Type:
114+
- text/event-stream; charset=utf-8
115+
Date:
116+
- Tue, 13 Jan 2026 17:07:21 GMT
117+
Server:
118+
- cloudflare
119+
Set-Cookie:
120+
- __cf_bm=7LjIwA0zXbQJNpkJNVcOUwKkl7Vtim6q73sAR_EgS0k-1768324041-1.0.1.1-6cHwErIUCaM.INoq4x2.Ch3IxfQfK1KvUskkrPSR1rhhA2zEbRQP7ri3D7yvP700N8bkzlW5FZT5Y1tz.YmmcnnlWfxgYQNbCbxS7gw5lxE;
121+
path=/; expires=Tue, 13-Jan-26 17:37:21 GMT; domain=.api.openai.com; HttpOnly;
122+
Secure; SameSite=None
123+
- _cfuvid=3zPKmerOeIEOylHrOuK2ZIaBmD_uKdKTThcW5tdieu0-1768324041898-0.0.1.1-604800000;
124+
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
125+
Strict-Transport-Security:
126+
- max-age=31536000; includeSubDomains; preload
127+
Transfer-Encoding:
128+
- chunked
129+
X-Content-Type-Options:
130+
- nosniff
131+
access-control-expose-headers:
132+
- X-Request-ID
133+
alt-svc:
134+
- h3=":443"; ma=86400
135+
cf-cache-status:
136+
- DYNAMIC
137+
openai-organization:
138+
- datadog-staging
139+
openai-processing-ms:
140+
- '349'
141+
openai-project:
142+
- proj_gt6TQZPRbZfoY2J9AQlEJMpd
143+
openai-version:
144+
- '2020-10-01'
145+
x-envoy-upstream-service-time:
146+
- '364'
147+
x-openai-proxy-wasm:
148+
- v0.1
149+
x-ratelimit-limit-requests:
150+
- '30000'
151+
x-ratelimit-limit-tokens:
152+
- '150000000'
153+
x-ratelimit-remaining-requests:
154+
- '29999'
155+
x-ratelimit-remaining-tokens:
156+
- '149999990'
157+
x-ratelimit-reset-requests:
158+
- 2ms
159+
x-ratelimit-reset-tokens:
160+
- 0s
161+
x-request-id:
162+
- req_90a96caaad7541d4b04bba0f4a74ea6a
163+
status:
164+
code: 200
165+
message: OK
166+
version: 1

0 commit comments

Comments
 (0)