Debian Codegraph @

tests/api_resources/beta/test_agents.py

raw
1 from __future__ import annotations
2
3 import os
4 from typing import Any, cast
5
6 import pytest
7
8 from anthropic import Anthropic, AsyncAnthropic
9 from tests.utils import assert_matches_type
10 from anthropic._utils import parse_datetime
11 from anthropic.pagination import SyncPageCursor, AsyncPageCursor
12 from anthropic.types.beta import (
13 BetaManagedAgentsAgent,
14 )
15
16 base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
17
18
19 class TestAgents:
20 parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
21
22 @parametrize
23 def test_method_create(self, client: Anthropic) -> None:
24 agent = client.beta.agents.create(
25 model="claude-opus-5",
26 name="My First Agent",
27 )
28 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
29
30 @parametrize
31 def test_method_create_with_all_params(self, client: Anthropic) -> None:
32 agent = client.beta.agents.create(
33 model="claude-opus-5",
34 name="My First Agent",
35 description="A general-purpose starter agent.",
36 mcp_servers=[
37 {
38 "name": "example-mcp",
39 "type": "url",
40 "url": "https://example-server.modelcontextprotocol.io/sse",
41 }
42 ],
43 metadata={"foo": "bar"},
44 multiagent={
45 "agents": ["agent_011CZkYqphY8vELVzwCUpqiQ", {"type": "self"}],
46 "type": "coordinator",
47 },
48 skills=[
49 {
50 "skill_id": "xlsx",
51 "type": "anthropic",
52 "version": "1",
53 }
54 ],
55 system="You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
56 tools=[
57 {
58 "type": "agent_toolset_20260401",
59 "configs": [
60 {
61 "name": "bash",
62 "enabled": True,
63 "permission_policy": {"type": "always_allow"},
64 "type": "bash",
65 }
66 ],
67 "default_config": {
68 "enabled": True,
69 "permission_policy": {"type": "always_allow"},
70 },
71 }
72 ],
73 betas=["message-batches-2024-09-24"],
74 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
75 )
76 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
77
78 @parametrize
79 def test_raw_response_create(self, client: Anthropic) -> None:
80 response = client.beta.agents.with_raw_response.create(
81 model="claude-opus-5",
82 name="My First Agent",
83 )
84
85 assert response.is_closed is True
86 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
87 agent = response.parse()
88 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
89
90 @parametrize
91 def test_streaming_response_create(self, client: Anthropic) -> None:
92 with client.beta.agents.with_streaming_response.create(
93 model="claude-opus-5",
94 name="My First Agent",
95 ) as response:
96 assert not response.is_closed
97 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
98
99 agent = response.parse()
100 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
101
102 assert cast(Any, response.is_closed) is True
103
104 @pytest.mark.skip(reason="buildURL drops path-level query params")
105 @parametrize
106 def test_method_retrieve(self, client: Anthropic) -> None:
107 agent = client.beta.agents.retrieve(
108 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
109 )
110 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
111
112 @pytest.mark.skip(reason="buildURL drops path-level query params")
113 @parametrize
114 def test_method_retrieve_with_all_params(self, client: Anthropic) -> None:
115 agent = client.beta.agents.retrieve(
116 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
117 version=0,
118 betas=["message-batches-2024-09-24"],
119 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
120 )
121 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
122
123 @pytest.mark.skip(reason="buildURL drops path-level query params")
124 @parametrize
125 def test_raw_response_retrieve(self, client: Anthropic) -> None:
126 response = client.beta.agents.with_raw_response.retrieve(
127 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
128 )
129
130 assert response.is_closed is True
131 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
132 agent = response.parse()
133 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
134
135 @pytest.mark.skip(reason="buildURL drops path-level query params")
136 @parametrize
137 def test_streaming_response_retrieve(self, client: Anthropic) -> None:
138 with client.beta.agents.with_streaming_response.retrieve(
139 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
140 ) as response:
141 assert not response.is_closed
142 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
143
144 agent = response.parse()
145 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
146
147 assert cast(Any, response.is_closed) is True
148
149 @pytest.mark.skip(reason="buildURL drops path-level query params")
150 @parametrize
151 def test_path_params_retrieve(self, client: Anthropic) -> None:
152 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
153 client.beta.agents.with_raw_response.retrieve(
154 agent_id="",
155 )
156
157 @parametrize
158 def test_method_update(self, client: Anthropic) -> None:
159 agent = client.beta.agents.update(
160 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
161 )
162 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
163
164 @parametrize
165 def test_method_update_with_all_params(self, client: Anthropic) -> None:
166 agent = client.beta.agents.update(
167 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
168 description="updated",
169 mcp_servers=[
170 {
171 "name": "example-mcp",
172 "type": "url",
173 "url": "https://example-server.modelcontextprotocol.io/sse",
174 }
175 ],
176 metadata={"foo": "string"},
177 model={
178 "id": "claude-opus-5",
179 "effort": "low",
180 "inference_geo": "inference_geo",
181 "speed": "standard",
182 },
183 multiagent={
184 "agents": ["agent_011CZkYqphY8vELVzwCUpqiQ", {"type": "self"}],
185 "type": "coordinator",
186 },
187 name="name",
188 skills=[
189 {
190 "skill_id": "xlsx",
191 "type": "anthropic",
192 "version": "1",
193 }
194 ],
195 system="You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
196 tools=[
197 {
198 "type": "agent_toolset_20260401",
199 "configs": [
200 {
201 "name": "bash",
202 "enabled": True,
203 "permission_policy": {"type": "always_allow"},
204 "type": "bash",
205 }
206 ],
207 "default_config": {
208 "enabled": True,
209 "permission_policy": {"type": "always_allow"},
210 },
211 }
212 ],
213 version=1,
214 betas=["message-batches-2024-09-24"],
215 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
216 )
217 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
218
219 @parametrize
220 def test_raw_response_update(self, client: Anthropic) -> None:
221 response = client.beta.agents.with_raw_response.update(
222 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
223 )
224
225 assert response.is_closed is True
226 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
227 agent = response.parse()
228 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
229
230 @parametrize
231 def test_streaming_response_update(self, client: Anthropic) -> None:
232 with client.beta.agents.with_streaming_response.update(
233 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
234 ) as response:
235 assert not response.is_closed
236 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
237
238 agent = response.parse()
239 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
240
241 assert cast(Any, response.is_closed) is True
242
243 @parametrize
244 def test_path_params_update(self, client: Anthropic) -> None:
245 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
246 client.beta.agents.with_raw_response.update(
247 agent_id="",
248 )
249
250 @pytest.mark.skip(reason="buildURL drops path-level query params")
251 @parametrize
252 def test_method_list(self, client: Anthropic) -> None:
253 agent = client.beta.agents.list()
254 assert_matches_type(SyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
255
256 @pytest.mark.skip(reason="buildURL drops path-level query params")
257 @parametrize
258 def test_method_list_with_all_params(self, client: Anthropic) -> None:
259 agent = client.beta.agents.list(
260 created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"),
261 created_at_lte=parse_datetime("2019-12-27T18:11:19.117Z"),
262 include_archived=True,
263 limit=0,
264 page="page",
265 betas=["message-batches-2024-09-24"],
266 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
267 )
268 assert_matches_type(SyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
269
270 @pytest.mark.skip(reason="buildURL drops path-level query params")
271 @parametrize
272 def test_raw_response_list(self, client: Anthropic) -> None:
273 response = client.beta.agents.with_raw_response.list()
274
275 assert response.is_closed is True
276 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
277 agent = response.parse()
278 assert_matches_type(SyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
279
280 @pytest.mark.skip(reason="buildURL drops path-level query params")
281 @parametrize
282 def test_streaming_response_list(self, client: Anthropic) -> None:
283 with client.beta.agents.with_streaming_response.list() as response:
284 assert not response.is_closed
285 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
286
287 agent = response.parse()
288 assert_matches_type(SyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
289
290 assert cast(Any, response.is_closed) is True
291
292 @parametrize
293 def test_method_archive(self, client: Anthropic) -> None:
294 agent = client.beta.agents.archive(
295 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
296 )
297 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
298
299 @parametrize
300 def test_method_archive_with_all_params(self, client: Anthropic) -> None:
301 agent = client.beta.agents.archive(
302 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
303 betas=["message-batches-2024-09-24"],
304 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
305 )
306 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
307
308 @parametrize
309 def test_raw_response_archive(self, client: Anthropic) -> None:
310 response = client.beta.agents.with_raw_response.archive(
311 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
312 )
313
314 assert response.is_closed is True
315 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
316 agent = response.parse()
317 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
318
319 @parametrize
320 def test_streaming_response_archive(self, client: Anthropic) -> None:
321 with client.beta.agents.with_streaming_response.archive(
322 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
323 ) as response:
324 assert not response.is_closed
325 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
326
327 agent = response.parse()
328 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
329
330 assert cast(Any, response.is_closed) is True
331
332 @parametrize
333 def test_path_params_archive(self, client: Anthropic) -> None:
334 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
335 client.beta.agents.with_raw_response.archive(
336 agent_id="",
337 )
338
339
340 class TestAsyncAgents:
341 parametrize = pytest.mark.parametrize(
342 "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
343 )
344
345 @parametrize
346 async def test_method_create(self, async_client: AsyncAnthropic) -> None:
347 agent = await async_client.beta.agents.create(
348 model="claude-opus-5",
349 name="My First Agent",
350 )
351 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
352
353 @parametrize
354 async def test_method_create_with_all_params(self, async_client: AsyncAnthropic) -> None:
355 agent = await async_client.beta.agents.create(
356 model="claude-opus-5",
357 name="My First Agent",
358 description="A general-purpose starter agent.",
359 mcp_servers=[
360 {
361 "name": "example-mcp",
362 "type": "url",
363 "url": "https://example-server.modelcontextprotocol.io/sse",
364 }
365 ],
366 metadata={"foo": "bar"},
367 multiagent={
368 "agents": ["agent_011CZkYqphY8vELVzwCUpqiQ", {"type": "self"}],
369 "type": "coordinator",
370 },
371 skills=[
372 {
373 "skill_id": "xlsx",
374 "type": "anthropic",
375 "version": "1",
376 }
377 ],
378 system="You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
379 tools=[
380 {
381 "type": "agent_toolset_20260401",
382 "configs": [
383 {
384 "name": "bash",
385 "enabled": True,
386 "permission_policy": {"type": "always_allow"},
387 "type": "bash",
388 }
389 ],
390 "default_config": {
391 "enabled": True,
392 "permission_policy": {"type": "always_allow"},
393 },
394 }
395 ],
396 betas=["message-batches-2024-09-24"],
397 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
398 )
399 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
400
401 @parametrize
402 async def test_raw_response_create(self, async_client: AsyncAnthropic) -> None:
403 response = await async_client.beta.agents.with_raw_response.create(
404 model="claude-opus-5",
405 name="My First Agent",
406 )
407
408 assert response.is_closed is True
409 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
410 agent = await response.parse()
411 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
412
413 @parametrize
414 async def test_streaming_response_create(self, async_client: AsyncAnthropic) -> None:
415 async with async_client.beta.agents.with_streaming_response.create(
416 model="claude-opus-5",
417 name="My First Agent",
418 ) as response:
419 assert not response.is_closed
420 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
421
422 agent = await response.parse()
423 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
424
425 assert cast(Any, response.is_closed) is True
426
427 @pytest.mark.skip(reason="buildURL drops path-level query params")
428 @parametrize
429 async def test_method_retrieve(self, async_client: AsyncAnthropic) -> None:
430 agent = await async_client.beta.agents.retrieve(
431 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
432 )
433 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
434
435 @pytest.mark.skip(reason="buildURL drops path-level query params")
436 @parametrize
437 async def test_method_retrieve_with_all_params(self, async_client: AsyncAnthropic) -> None:
438 agent = await async_client.beta.agents.retrieve(
439 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
440 version=0,
441 betas=["message-batches-2024-09-24"],
442 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
443 )
444 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
445
446 @pytest.mark.skip(reason="buildURL drops path-level query params")
447 @parametrize
448 async def test_raw_response_retrieve(self, async_client: AsyncAnthropic) -> None:
449 response = await async_client.beta.agents.with_raw_response.retrieve(
450 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
451 )
452
453 assert response.is_closed is True
454 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
455 agent = await response.parse()
456 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
457
458 @pytest.mark.skip(reason="buildURL drops path-level query params")
459 @parametrize
460 async def test_streaming_response_retrieve(self, async_client: AsyncAnthropic) -> None:
461 async with async_client.beta.agents.with_streaming_response.retrieve(
462 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
463 ) as response:
464 assert not response.is_closed
465 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
466
467 agent = await response.parse()
468 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
469
470 assert cast(Any, response.is_closed) is True
471
472 @pytest.mark.skip(reason="buildURL drops path-level query params")
473 @parametrize
474 async def test_path_params_retrieve(self, async_client: AsyncAnthropic) -> None:
475 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
476 await async_client.beta.agents.with_raw_response.retrieve(
477 agent_id="",
478 )
479
480 @parametrize
481 async def test_method_update(self, async_client: AsyncAnthropic) -> None:
482 agent = await async_client.beta.agents.update(
483 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
484 )
485 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
486
487 @parametrize
488 async def test_method_update_with_all_params(self, async_client: AsyncAnthropic) -> None:
489 agent = await async_client.beta.agents.update(
490 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
491 description="updated",
492 mcp_servers=[
493 {
494 "name": "example-mcp",
495 "type": "url",
496 "url": "https://example-server.modelcontextprotocol.io/sse",
497 }
498 ],
499 metadata={"foo": "string"},
500 model={
501 "id": "claude-opus-5",
502 "effort": "low",
503 "inference_geo": "inference_geo",
504 "speed": "standard",
505 },
506 multiagent={
507 "agents": ["agent_011CZkYqphY8vELVzwCUpqiQ", {"type": "self"}],
508 "type": "coordinator",
509 },
510 name="name",
511 skills=[
512 {
513 "skill_id": "xlsx",
514 "type": "anthropic",
515 "version": "1",
516 }
517 ],
518 system="You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
519 tools=[
520 {
521 "type": "agent_toolset_20260401",
522 "configs": [
523 {
524 "name": "bash",
525 "enabled": True,
526 "permission_policy": {"type": "always_allow"},
527 "type": "bash",
528 }
529 ],
530 "default_config": {
531 "enabled": True,
532 "permission_policy": {"type": "always_allow"},
533 },
534 }
535 ],
536 version=1,
537 betas=["message-batches-2024-09-24"],
538 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
539 )
540 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
541
542 @parametrize
543 async def test_raw_response_update(self, async_client: AsyncAnthropic) -> None:
544 response = await async_client.beta.agents.with_raw_response.update(
545 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
546 )
547
548 assert response.is_closed is True
549 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
550 agent = await response.parse()
551 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
552
553 @parametrize
554 async def test_streaming_response_update(self, async_client: AsyncAnthropic) -> None:
555 async with async_client.beta.agents.with_streaming_response.update(
556 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
557 ) as response:
558 assert not response.is_closed
559 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
560
561 agent = await response.parse()
562 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
563
564 assert cast(Any, response.is_closed) is True
565
566 @parametrize
567 async def test_path_params_update(self, async_client: AsyncAnthropic) -> None:
568 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
569 await async_client.beta.agents.with_raw_response.update(
570 agent_id="",
571 )
572
573 @pytest.mark.skip(reason="buildURL drops path-level query params")
574 @parametrize
575 async def test_method_list(self, async_client: AsyncAnthropic) -> None:
576 agent = await async_client.beta.agents.list()
577 assert_matches_type(AsyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
578
579 @pytest.mark.skip(reason="buildURL drops path-level query params")
580 @parametrize
581 async def test_method_list_with_all_params(self, async_client: AsyncAnthropic) -> None:
582 agent = await async_client.beta.agents.list(
583 created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"),
584 created_at_lte=parse_datetime("2019-12-27T18:11:19.117Z"),
585 include_archived=True,
586 limit=0,
587 page="page",
588 betas=["message-batches-2024-09-24"],
589 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
590 )
591 assert_matches_type(AsyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
592
593 @pytest.mark.skip(reason="buildURL drops path-level query params")
594 @parametrize
595 async def test_raw_response_list(self, async_client: AsyncAnthropic) -> None:
596 response = await async_client.beta.agents.with_raw_response.list()
597
598 assert response.is_closed is True
599 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
600 agent = await response.parse()
601 assert_matches_type(AsyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
602
603 @pytest.mark.skip(reason="buildURL drops path-level query params")
604 @parametrize
605 async def test_streaming_response_list(self, async_client: AsyncAnthropic) -> None:
606 async with async_client.beta.agents.with_streaming_response.list() as response:
607 assert not response.is_closed
608 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
609
610 agent = await response.parse()
611 assert_matches_type(AsyncPageCursor[BetaManagedAgentsAgent], agent, path=["response"])
612
613 assert cast(Any, response.is_closed) is True
614
615 @parametrize
616 async def test_method_archive(self, async_client: AsyncAnthropic) -> None:
617 agent = await async_client.beta.agents.archive(
618 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
619 )
620 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
621
622 @parametrize
623 async def test_method_archive_with_all_params(self, async_client: AsyncAnthropic) -> None:
624 agent = await async_client.beta.agents.archive(
625 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
626 betas=["message-batches-2024-09-24"],
627 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
628 )
629 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
630
631 @parametrize
632 async def test_raw_response_archive(self, async_client: AsyncAnthropic) -> None:
633 response = await async_client.beta.agents.with_raw_response.archive(
634 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
635 )
636
637 assert response.is_closed is True
638 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
639 agent = await response.parse()
640 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
641
642 @parametrize
643 async def test_streaming_response_archive(self, async_client: AsyncAnthropic) -> None:
644 async with async_client.beta.agents.with_streaming_response.archive(
645 agent_id="agent_011CZkYpogX7uDKUyvBTophP",
646 ) as response:
647 assert not response.is_closed
648 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
649
650 agent = await response.parse()
651 assert_matches_type(BetaManagedAgentsAgent, agent, path=["response"])
652
653 assert cast(Any, response.is_closed) is True
654
655 @parametrize
656 async def test_path_params_archive(self, async_client: AsyncAnthropic) -> None:
657 with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"):
658 await async_client.beta.agents.with_raw_response.archive(
659 agent_id="",
660 )