Skip to content

Conversation

@Hugo-Pare
Copy link
Collaborator

What is the purpose of this change?

Implements alphabetical sorting for agent cards returned by the /api/v1/agentCards endpoint. This ensures that agent dropdowns and lists in the frontend display agents in a consistent, user-friendly alphabetical order based on their display names.

How was this change implemented?

Backend Changes:

  • Modified src/solace_agent_mesh/gateway/http_sse/routers/agent_cards.py
    • Added DISPLAY_NAME_EXTENSION_URI constant for the display name extension
    • Created _get_agent_display_name() helper function to extract display names from agent card extensions, falling back to agent name if not present
    • Added case-insensitive alphabetical sorting before returning agent cards (lines 204-207)

Test Assets:

  • Created examples/agents/test_sorting_agents.yaml with 12 test agents featuring diverse display names (numbers, emojis, special characters, mixed case) for manual testing
  • Created tests/integration/apis/test_agent_cards_sorting.py integration test covering 20 edge cases including:
    • Leading spaces, numbers, special characters (@, &, _, -, .)
    • Mixed case and all-caps names
    • International characters (accented letters, Spanish ñ, Chinese characters)
    • Emojis and Unicode symbols

Key Design Decisions

  • Sorting at API level: Implemented sorting in the backend API endpoint rather than frontend to ensure consistency across all consumers of the API
  • Case-insensitive sorting: Uses Python's .lower() for case-insensitive comparison, so "Apple Agent" and "ALPHA AGENT" sort logically together
  • Display name extraction: Properly handles the A2A protocol's display name extension while gracefully falling back to internal agent names

How was this change tested?

  • Unit tests: Created comprehensive integration test with 20 edge cases covering numbers, special characters, international characters, emojis, and various Unicode edge cases
  • Integration tests: test_agent_cards_endpoint_returns_alphabetically_sorted_agents tests the full flow: creates test agents → registers in agent registry → calls API endpoint → verifies alphabetical order
  • Manual testing: Created examples/agents/test_sorting_agents.yaml with 12 sample agents for visual verification in the frontend
  • Known limitations: Sorting behavior for emojis and non-Latin scripts follows Python's default string sorting (Unicode code point order)

Is there anything the reviewers should focus on/be aware of?

  • The sort order for special characters follows Python's default string comparison (e.g., underscore _ sorts before letters, emojis sort after ASCII)
  • The integration test sets up its own AgentRegistry instance rather than using a fixture, as the WebUIBackendFactory doesn't pre-configure an agent registry - reviewers should verify this approach aligns with testing patterns
  • Display names are extracted from the https://solace.com/a2a/extensions/display-name extension; agents without this extension fall back to using their internal name field

References

Default agent in Projects

image

Agent selection in Chat

image

@Hugo-Pare Hugo-Pare self-assigned this Feb 8, 2026
@sonarqube-solacecloud
Copy link

@Hugo-Pare Hugo-Pare merged commit 421d7af into main Feb 8, 2026
26 checks passed
@Hugo-Pare Hugo-Pare deleted the hugo/agent-card-alphabetical-order branch February 8, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants