1414
1515from ._types import (
1616 LongRequestOptions ,
17+ SDKAgentListParams ,
1718 SDKDevboxListParams ,
1819 SDKObjectListParams ,
1920 SDKScorerListParams ,
21+ SDKAgentCreateParams ,
2022 SDKDevboxCreateParams ,
2123 SDKObjectCreateParams ,
2224 SDKScorerCreateParams ,
2830from .._types import Timeout , NotGiven , not_given
2931from .._client import DEFAULT_MAX_RETRIES , AsyncRunloop
3032from ._helpers import detect_content_type
33+ from .async_agent import AsyncAgent
3134from .async_devbox import AsyncDevbox
3235from .async_scorer import AsyncScorer
3336from .async_snapshot import AsyncSnapshot
@@ -541,6 +544,66 @@ async def list(self, **params: Unpack[SDKScorerListParams]) -> list[AsyncScorer]
541544 """
542545 page = await self ._client .scenarios .scorers .list (** params )
543546 return [AsyncScorer (self ._client , item .id ) async for item in page ]
547+
548+ class AsyncAgentOps :
549+ """High-level async manager for creating and managing agents.
550+
551+ Accessed via ``runloop.agent`` from :class:`AsyncRunloopSDK`, provides
552+ coroutines to create, retrieve, and list agents.
553+
554+ Example:
555+ >>> runloop = AsyncRunloopSDK()
556+ >>> agent = await runloop.agent.create(name="my-agent")
557+ >>> agents = await runloop.agent.list(limit=10)
558+ """
559+
560+ def __init__ (self , client : AsyncRunloop ) -> None :
561+ """Initialize the manager.
562+
563+ :param client: Generated AsyncRunloop client to wrap
564+ :type client: AsyncRunloop
565+ """
566+ self ._client = client
567+
568+ async def create (
569+ self ,
570+ ** params : Unpack [SDKAgentCreateParams ],
571+ ) -> AsyncAgent :
572+ """Create a new agent.
573+
574+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentCreateParams` for available parameters
575+ :return: Wrapper bound to the newly created agent
576+ :rtype: AsyncAgent
577+ """
578+ agent_view = await self ._client .agents .create (
579+ ** params ,
580+ )
581+ return AsyncAgent (self ._client , agent_view .id )
582+
583+ def from_id (self , agent_id : str ) -> AsyncAgent :
584+ """Attach to an existing agent by ID.
585+
586+ :param agent_id: Existing agent ID
587+ :type agent_id: str
588+ :return: Wrapper bound to the requested agent
589+ :rtype: AsyncAgent
590+ """
591+ return AsyncAgent (self ._client , agent_id )
592+
593+ async def list (
594+ self ,
595+ ** params : Unpack [SDKAgentListParams ],
596+ ) -> list [AsyncAgent ]:
597+ """List agents accessible to the caller.
598+
599+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKAgentListParams` for available parameters
600+ :return: Collection of agent wrappers
601+ :rtype: list[AsyncAgent]
602+ """
603+ page = await self ._client .agents .list (
604+ ** params ,
605+ )
606+ return [AsyncAgent (self ._client , item .id ) for item in page .agents ]
544607
545608
546609class AsyncRunloopSDK :
@@ -552,6 +615,8 @@ class AsyncRunloopSDK:
552615
553616 :ivar api: Direct access to the generated async REST API client
554617 :vartype api: AsyncRunloop
618+ :ivar agent: High-level async interface for agent management.
619+ :vartype agent: AsyncAgentOps
555620 :ivar devbox: High-level async interface for devbox management
556621 :vartype devbox: AsyncDevboxOps
557622 :ivar blueprint: High-level async interface for blueprint management
@@ -572,6 +637,7 @@ class AsyncRunloopSDK:
572637 """
573638
574639 api : AsyncRunloop
640+ agent : AsyncAgentOps
575641 devbox : AsyncDevboxOps
576642 blueprint : AsyncBlueprintOps
577643 scorer : AsyncScorerOps
@@ -616,6 +682,7 @@ def __init__(
616682 http_client = http_client ,
617683 )
618684
685+ self .agent = AsyncAgentOps (self .api )
619686 self .devbox = AsyncDevboxOps (self .api )
620687 self .blueprint = AsyncBlueprintOps (self .api )
621688 self .scorer = AsyncScorerOps (self .api )
0 commit comments