@@ -478,27 +478,29 @@ async def get_agent_cards_lob(
478478 tenant_subdomain : str ,
479479 system_token : str ,
480480 timeout : float ,
481- names : list [str ] | None = None ,
481+ agent_names : list [str ] | None = None ,
482482 ord_ids : list [str ] | None = None ,
483483) -> list [Agent ]:
484484 """List A2A agents and their agent cards using LoB flow.
485485
486- Discovers A2A fragments (label agw.a2a.server), optionally filters them,
487- then fetches the agent card for each from the fragment's URL property.
486+ Discovers A2A fragments (label agw.a2a.server), optionally filters by
487+ ORD ID before fetching, fetches each agent card, then optionally filters
488+ by agent card name.
488489
489490 Fragment properties used:
490491 URL: Base URL of the A2A agent (required).
491492 The agent card is fetched at {URL}/.well-known/agent-card.json.
492- ordId: ORD ID of the A2A agent (required) .
493+ The ORD ID is extracted from the second-to-last URL path segment .
493494
494495 Args:
495496 tenant_subdomain: Tenant subdomain for multi-tenant lookup.
496497 system_token: Pre-fetched raw system token for authentication.
497498 timeout: HTTP timeout in seconds.
498- names: Optional list of fragment names to include. If empty or None,
499- all fragments are included.
500- ord_ids: Optional list of ORD IDs to include. If empty or None,
501- all fragments are included.
499+ agent_names: Optional list of agent card names to include (matched
500+ against the `name` field in the fetched agent card JSON).
501+ Applied after fetching. If empty or None, all are included.
502+ ord_ids: Optional list of ORD IDs to include (extracted from URL).
503+ Applied before fetching. If empty or None, all are included.
502504
503505 Returns:
504506 List of Agent objects, each containing ORD ID and fetched AgentCard.
@@ -514,10 +516,7 @@ async def get_agent_cards_lob(
514516 )
515517 return []
516518
517- # Apply optional filters
518- if names :
519- names_set = set (names )
520- fragments = [f for f in fragments if f .name in names_set ]
519+ # Pre-fetch filter: ORD ID is extractable from the URL without fetching the card
521520 if ord_ids :
522521 ord_ids_set = set (ord_ids )
523522 fragments = [
@@ -562,6 +561,11 @@ async def get_agent_cards_lob(
562561 "Failed to fetch agent card for fragment '%s' — skipping" , fragment_name
563562 )
564563
564+ # Post-fetch filter: agent card name is only known after fetching
565+ if agent_names :
566+ agent_names_set = set (agent_names )
567+ agents = [a for a in agents if a .agent_card .raw .get ("name" ) in agent_names_set ]
568+
565569 logger .info (
566570 "Fetched %d agent card(s) from %d A2A fragment(s)" , len (agents ), len (fragments )
567571 )
0 commit comments