1414
1515from ._types import (
1616 LongRequestOptions ,
17+ SDKAgentListParams ,
1718 SDKDevboxListParams ,
1819 SDKObjectListParams ,
20+ SDKAgentCreateParams ,
1921 SDKDevboxCreateParams ,
2022 SDKObjectCreateParams ,
2123 SDKBlueprintListParams ,
2628from .._types import Timeout , NotGiven , not_given
2729from .._client import DEFAULT_MAX_RETRIES , AsyncRunloop
2830from ._helpers import detect_content_type
31+ from .async_agent import AsyncAgent
2932from .async_devbox import AsyncDevbox
3033from .async_snapshot import AsyncSnapshot
3134from .async_blueprint import AsyncBlueprint
@@ -475,6 +478,67 @@ async def upload_from_bytes(
475478 return obj
476479
477480
481+ class AsyncAgentOps :
482+ """High-level async manager for creating and managing agents.
483+
484+ Accessed via ``runloop.agent`` from :class:`AsyncRunloopSDK`, provides
485+ coroutines to create, retrieve, and list agents.
486+
487+ Example:
488+ >>> runloop = AsyncRunloopSDK()
489+ >>> agent = await runloop.agent.create(name="my-agent")
490+ >>> agents = await runloop.agent.list(limit=10)
491+ """
492+
493+ def __init__ (self , client : AsyncRunloop ) -> None :
494+ """Initialize the manager.
495+
496+ :param client: Generated AsyncRunloop client to wrap
497+ :type client: AsyncRunloop
498+ """
499+ self ._client = client
500+
501+ async def create (
502+ self ,
503+ ** params : Unpack [SDKAgentCreateParams ],
504+ ) -> AsyncAgent :
505+ """Create a new agent.
506+
507+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentCreateParams` for available parameters
508+ :return: Wrapper bound to the newly created agent
509+ :rtype: AsyncAgent
510+ """
511+ agent_view = await self ._client .agents .create (
512+ ** params ,
513+ )
514+ return AsyncAgent (self ._client , agent_view .id )
515+
516+ def from_id (self , agent_id : str ) -> AsyncAgent :
517+ """Attach to an existing agent by ID.
518+
519+ :param agent_id: Existing agent ID
520+ :type agent_id: str
521+ :return: Wrapper bound to the requested agent
522+ :rtype: AsyncAgent
523+ """
524+ return AsyncAgent (self ._client , agent_id )
525+
526+ async def list (
527+ self ,
528+ ** params : Unpack [SDKAgentListParams ],
529+ ) -> list [AsyncAgent ]:
530+ """List agents accessible to the caller.
531+
532+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentListParams` for available parameters
533+ :return: Collection of agent wrappers
534+ :rtype: list[AsyncAgent]
535+ """
536+ page = await self ._client .agents .list (
537+ ** params ,
538+ )
539+ return [AsyncAgent (self ._client , item .id ) for item in page .agents ]
540+
541+
478542class AsyncRunloopSDK :
479543 """High-level asynchronous entry point for the Runloop SDK.
480544
@@ -484,6 +548,8 @@ class AsyncRunloopSDK:
484548
485549 :ivar api: Direct access to the generated async REST API client
486550 :vartype api: AsyncRunloop
551+ :ivar agent: High-level async interface for agent management.
552+ :vartype agent: AsyncAgentOps
487553 :ivar devbox: High-level async interface for devbox management
488554 :vartype devbox: AsyncDevboxOps
489555 :ivar blueprint: High-level async interface for blueprint management
@@ -502,6 +568,7 @@ class AsyncRunloopSDK:
502568 """
503569
504570 api : AsyncRunloop
571+ agent : AsyncAgentOps
505572 devbox : AsyncDevboxOps
506573 blueprint : AsyncBlueprintOps
507574 snapshot : AsyncSnapshotOps
@@ -545,6 +612,7 @@ def __init__(
545612 http_client = http_client ,
546613 )
547614
615+ self .agent = AsyncAgentOps (self .api )
548616 self .devbox = AsyncDevboxOps (self .api )
549617 self .blueprint = AsyncBlueprintOps (self .api )
550618 self .snapshot = AsyncSnapshotOps (self .api )
0 commit comments