1010
1111from ._types import (
1212 LongRequestOptions ,
13+ SDKAgentListParams ,
1314 SDKDevboxListParams ,
1415 SDKObjectListParams ,
16+ SDKAgentCreateParams ,
1517 SDKDevboxCreateParams ,
1618 SDKObjectCreateParams ,
1719 SDKBlueprintListParams ,
2224from .._types import Timeout , NotGiven , not_given
2325from .._client import DEFAULT_MAX_RETRIES , AsyncRunloop
2426from ._helpers import detect_content_type
27+ from .async_agent import AsyncAgent
2528from .async_devbox import AsyncDevbox
2629from .async_snapshot import AsyncSnapshot
2730from .async_blueprint import AsyncBlueprint
@@ -415,6 +418,67 @@ async def upload_from_bytes(
415418 return obj
416419
417420
421+ class AsyncAgentOps :
422+ """High-level async manager for creating and managing agents.
423+
424+ Accessed via ``runloop.agent`` from :class:`AsyncRunloopSDK`, provides
425+ coroutines to create, retrieve, and list agents.
426+
427+ Example:
428+ >>> runloop = AsyncRunloopSDK()
429+ >>> agent = await runloop.agent.create(name="my-agent")
430+ >>> agents = await runloop.agent.list(limit=10)
431+ """
432+
433+ def __init__ (self , client : AsyncRunloop ) -> None :
434+ """Initialize the manager.
435+
436+ :param client: Generated AsyncRunloop client to wrap
437+ :type client: AsyncRunloop
438+ """
439+ self ._client = client
440+
441+ async def create (
442+ self ,
443+ ** params : Unpack [SDKAgentCreateParams ],
444+ ) -> AsyncAgent :
445+ """Create a new agent.
446+
447+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentCreateParams` for available parameters
448+ :return: Wrapper bound to the newly created agent
449+ :rtype: AsyncAgent
450+ """
451+ agent_view = await self ._client .agents .create (
452+ ** params ,
453+ )
454+ return AsyncAgent (self ._client , agent_view .id )
455+
456+ def from_id (self , agent_id : str ) -> AsyncAgent :
457+ """Attach to an existing agent by ID.
458+
459+ :param agent_id: Existing agent ID
460+ :type agent_id: str
461+ :return: Wrapper bound to the requested agent
462+ :rtype: AsyncAgent
463+ """
464+ return AsyncAgent (self ._client , agent_id )
465+
466+ async def list (
467+ self ,
468+ ** params : Unpack [SDKAgentListParams ],
469+ ) -> list [AsyncAgent ]:
470+ """List agents accessible to the caller.
471+
472+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentListParams` for available parameters
473+ :return: Collection of agent wrappers
474+ :rtype: list[AsyncAgent]
475+ """
476+ page = await self ._client .agents .list (
477+ ** params ,
478+ )
479+ return [AsyncAgent (self ._client , item .id ) for item in page .agents ]
480+
481+
418482class AsyncRunloopSDK :
419483 """High-level asynchronous entry point for the Runloop SDK.
420484
@@ -424,6 +488,7 @@ class AsyncRunloopSDK:
424488
425489 Attributes:
426490 api: Direct access to the generated async REST API client.
491+ agent: High-level async interface for agent management.
427492 devbox: High-level async interface for devbox management.
428493 blueprint: High-level async interface for blueprint management.
429494 snapshot: High-level async interface for snapshot management.
@@ -438,6 +503,7 @@ class AsyncRunloopSDK:
438503 """
439504
440505 api : AsyncRunloop
506+ agent : AsyncAgentOps
441507 devbox : AsyncDevboxOps
442508 blueprint : AsyncBlueprintOps
443509 snapshot : AsyncSnapshotOps
@@ -481,6 +547,7 @@ def __init__(
481547 http_client = http_client ,
482548 )
483549
550+ self .agent = AsyncAgentOps (self .api )
484551 self .devbox = AsyncDevboxOps (self .api )
485552 self .blueprint = AsyncBlueprintOps (self .api )
486553 self .snapshot = AsyncSnapshotOps (self .api )
0 commit comments