Skip to content

fix: Consistent agent display names across UI #1064

Open
Akhileswara-Microsoft wants to merge 3 commits into
devfrom
AgentName_Fix47839
Open

fix: Consistent agent display names across UI #1064
Akhileswara-Microsoft wants to merge 3 commits into
devfrom
AgentName_Fix47839

Conversation

@Akhileswara-Microsoft

Copy link
Copy Markdown
Contributor

Purpose

This pull request introduces a utility function to consistently format agent display names across the backend, ensuring that agent names are human-readable and match frontend conventions. The new formatting logic is applied throughout agent response handling and orchestration, replacing ad-hoc string manipulation with a centralized approach.

Agent Display Name Formatting Improvements:

  • Added format_agent_display_name to response_handlers.py, converting raw agent IDs (like HRHelperAgent or hr_helper_agent) into human-readable names (like "HR Helper Agent"), mirroring frontend logic for consistency.
  • Updated agent_response_callback and streaming_agent_response_callback to use format_agent_display_name, ensuring all agent names in responses and streaming updates are properly formatted.

Orchestration Consistency:

  • Modified _process_event_stream in orchestration_manager.py to use format_agent_display_name for agent headers and streaming messages, replacing previous underscore-to-space logic.

Imports and Code Organization:

  • Added import of format_agent_display_name in orchestration_manager.py to support the new formatting logic.

Does this introduce a breaking change?

  • Yes
  • No

What to Check

This pull request introduces a utility function to standardize the formatting of agent display names across the backend, ensuring consistency with the frontend's naming conventions. The new function is integrated into several response handling and orchestration flows, so agent names are now presented in a more human-readable format throughout the application.

Key changes:

Agent display name formatting:

  • Added a new format_agent_display_name function to response_handlers.py that converts raw agent identifiers (e.g., HRHelperAgent, hr_helper_agent) into human-readable display names (e.g., HR Helper Agent). This mirrors frontend logic for consistency.
  • Updated agent_response_callback and streaming_agent_response_callback to use format_agent_display_name when setting agent names, ensuring all agent messages and tool calls display formatted names.

Orchestration integration:

  • Imported and used format_agent_display_name in orchestration_manager.py to format agent names in streaming event headers and message payloads, replacing previous ad-hoc formatting.

Other Information

This pull request introduces a utility function to standardize the formatting of agent display names, ensuring consistency across backend and frontend components. The function is integrated into multiple places where agent names are shown to users, replacing previous ad-hoc formatting logic.

Key changes include:

Agent Display Name Formatting:

  • Added a new format_agent_display_name function in src/backend/callbacks/response_handlers.py to convert raw agent IDs (e.g., hr_helper_agent, HRHelperAgent) into human-readable display names (e.g., "HR Helper Agent"), mirroring frontend logic for consistent naming.

Integration of Formatting Utility:

  • Updated agent_response_callback and streaming_agent_response_callback in src/backend/callbacks/response_handlers.py to use format_agent_display_name when rendering agent names, ensuring all agent messages display standardized names.

  • Modified _process_event_stream in src/backend/orchestration/orchestration_manager.py to use format_agent_display_name for agent section headers and streaming messages, replacing previous underscore-based formatting.

  • Updated imports in src/backend/orchestration/orchestration_manager.py to include the new formatting function.

Add format_agent_display_name() utility that converts raw agent IDs
(e.g. 'HRHelperAgent', 'hr_helper_agent') to human-readable names
(e.g. 'HR Helper Agent'). Applied to all WebSocket agent_name payloads
and markdown headers in the streaming buffer.

Fixes inconsistent naming where agents showed as 'HRHelperAgent' in
AI Thinking but 'HR Helper Agent' in message headers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes agent display-name formatting in the backend so that agent names shown in streaming headers, messages, and tool-call updates are consistently human-readable and aligned with frontend naming conventions.

Changes:

  • Added format_agent_display_name() in src/backend/callbacks/response_handlers.py.
  • Updated agent message callbacks to emit formatted agent_name values for both final and streaming payloads.
  • Updated orchestration streaming headers to use the shared formatting utility.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/backend/orchestration/orchestration_manager.py Uses the shared formatter for per-agent streaming section headers and sets the streamed agent_name to the formatted display value.
src/backend/callbacks/response_handlers.py Introduces format_agent_display_name() and applies it to final/streaming agent messages and tool-call messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/callbacks/response_handlers.py Outdated
Comment thread src/backend/callbacks/response_handlers.py
Comment thread src/backend/callbacks/response_handlers.py Outdated
Comment thread src/backend/callbacks/response_handlers.py
Comment thread src/backend/callbacks/response_handlers.py Outdated

@Akhileswara-Microsoft Akhileswara-Microsoft left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 5 Copilot review comments addressed in commit 2be207c:

  1. str.replace substring bug - Replaced with word-boundary regex
    e.sub(r'\b...\b', ...). Added test verifying \HabitAgent\ -> \Habit Agent\ (not \HabIT Agent).
  2. Inaccurate comment - Updated to \HelperAgent -> Helper Agent\ matching actual regex behavior.
  3. Missing unit tests - Added 11 tests in \TestFormatAgentDisplayName\ (empty/None, PascalCase, snake_case, acronyms, word-boundary safety, etc.).
  4. Breaking existing tests - Updated all assertions: \TestAgent\ -> \Test Agent, \�gent_123\ -> \Agent 123. 52 tests pass.
  5. Docstring mismatch - Updated to clarify function does NOT strip 'Agent' suffix (frontend handles that separately).

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