2727 list_mcp_fragments ,
2828 list_a2a_fragments ,
2929)
30- from sap_cloud_sdk .agentgateway ._models import Agent , AgentCard , MCPTool , MCPToolFilter
30+ from sap_cloud_sdk .agentgateway ._models import (
31+ Agent ,
32+ AgentCard ,
33+ AgentCardFilter ,
34+ MCPTool ,
35+ MCPToolFilter ,
36+ )
3137from sap_cloud_sdk .agentgateway ._token_cache import _GatewayUrlCache , _TokenCache
3238from sap_cloud_sdk .agentgateway .exceptions import (
3339 AgentGatewaySDKError ,
@@ -499,8 +505,7 @@ async def get_agent_cards_lob(
499505 tenant_subdomain : str ,
500506 system_token : str ,
501507 timeout : float ,
502- agent_names : list [str ] | None = None ,
503- ord_ids : list [str ] | None = None ,
508+ filter : AgentCardFilter | None = None ,
504509) -> list [Agent ]:
505510 """List A2A agents and their agent cards using LoB flow.
506511
@@ -517,15 +522,13 @@ async def get_agent_cards_lob(
517522 tenant_subdomain: Tenant subdomain for multi-tenant lookup.
518523 system_token: Pre-fetched raw system token for authentication.
519524 timeout: HTTP timeout in seconds.
520- agent_names: Optional list of agent card names to include (matched
521- against the `name` field in the fetched agent card JSON).
522- Applied after fetching. If empty or None, all are included.
523- ord_ids: Optional list of ORD IDs to include (extracted from URL).
524- Applied before fetching. If empty or None, all are included.
525+ filter: Optional AgentCardFilter narrowing results by agent card name
526+ or ORD ID. If None or empty, all A2A fragments are included.
525527
526528 Returns:
527529 List of Agent objects, each containing ORD ID and fetched AgentCard.
528530 """
531+ f = filter or AgentCardFilter ()
529532 loop = asyncio .get_running_loop ()
530533
531534 logger .info ("Listing A2A fragments for tenant '%s'" , tenant_subdomain )
@@ -538,13 +541,13 @@ async def get_agent_cards_lob(
538541 return []
539542
540543 # Pre-fetch filter: ORD ID is extractable from the URL without fetching the card
541- if ord_ids :
542- ord_ids_set = set (ord_ids )
544+ if f . ord_ids :
545+ ord_ids_set = set (f . ord_ids )
543546 fragments = [
544- f
545- for f in fragments
547+ fr
548+ for fr in fragments
546549 if _ord_id_from_url (
547- {k .lower (): v for k , v in f .properties .items ()}.get ("url" , "" )
550+ {k .lower (): v for k , v in fr .properties .items ()}.get ("url" , "" )
548551 )
549552 in ord_ids_set
550553 ]
@@ -583,8 +586,8 @@ async def get_agent_cards_lob(
583586 )
584587
585588 # Post-fetch filter: agent card name is only known after fetching
586- if agent_names :
587- agent_names_set = set (agent_names )
589+ if f . agent_names :
590+ agent_names_set = set (f . agent_names )
588591 agents = [a for a in agents if a .agent_card .raw .get ("name" ) in agent_names_set ]
589592
590593 logger .info (
0 commit comments