Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 1, 2026

Fix getAgentName to support both agent names and login names

Issue: https://github.com/githubnext/gh-aw/actions/runs/20647172011/job/59286360410#step:6:1

Root Cause: The getAgentName function incorrectly returned the login name value instead of the agent name key.

Changes Made:

  • Fix getAgentName to return the agent name key ("copilot") instead of login value ("copilot-swe-agent")
  • Add support for recognizing both agent names ("copilot") and login names ("copilot-swe-agent") as input
  • Simplify implementation using .find() with optional chaining pattern
  • Add tests for login name recognition
  • All 2396 tests pass

Implementation Details:

The function now handles input in both formats using a concise pattern:

function getAgentName(assignee) {
  const normalized = assignee.startsWith("@") ? assignee.slice(1) : assignee;
  
  // Check if it's a known agent by key (e.g., "copilot")
  if (normalized in AGENT_LOGIN_NAMES) {
    return normalized;
  }
  
  // Check if normalized is a login name value by finding the corresponding key
  const entry = Object.entries(AGENT_LOGIN_NAMES).find(([, loginName]) => loginName === normalized);
  return entry?.[0] || null;
}

Supported inputs:

  • Agent name: "copilot""copilot"
  • Agent name with @: "@copilot""copilot"
  • Login name: "copilot-swe-agent""copilot"
  • Login name with @: "@copilot-swe-agent""copilot"

Test Results:

  • ✅ All 116 test files pass (2396 tests, 12 skipped)
  • ✅ JavaScript formatting validated
  • ✅ JavaScript linting passed
Original prompt

Reference: https://github.com/githubnext/gh-aw/actions/runs/20647172011/job/59286360410#step:6:1

Custom agent used: debug-agentic-workflow
Debug and refine agentic workflows using gh-aw CLI tools - analyze logs, audit runs, and improve workflow performance


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in action run process Fix getAgentName to return agent key instead of login value Jan 1, 2026
Copilot AI requested a review from pelikhan January 1, 2026 23:20
const normalized = assignee.startsWith("@") ? assignee.slice(1) : assignee;

// Check if it's a known agent
return AGENT_LOGIN_NAMES[normalized] || null;
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot || normalized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added support for both agent name ("copilot") and login name ("copilot-swe-agent") recognition. The function now checks if the input is a key in the map first, then checks if it's a value (login name), returning the corresponding agent name in both cases. Commit: 7874b8e

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Fix getAgentName to return agent key instead of login value Fix getAgentName to support both agent names and login names Jan 1, 2026
Copilot AI requested a review from pelikhan January 1, 2026 23:28
Comment on lines 32 to 44
// Check if it's a known agent by key (e.g., "copilot")
if (normalized in AGENT_LOGIN_NAMES) {
return normalized;
}

// Check if it's a known agent by login name value (e.g., "copilot-swe-agent")
for (const [agentName, loginName] of Object.entries(AGENT_LOGIN_NAMES)) {
if (loginName === normalized) {
return agentName;
}
}

return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot use pattern A[key] || key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified using .find() with optional chaining pattern. The implementation now uses Object.entries(A).find(([, v]) => v === normalized)?.[0] || null for cleaner code. Commit: eb39f6a

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan January 1, 2026 23:42
@pelikhan
Copy link
Contributor

pelikhan commented Jan 1, 2026

@copilot make it simpler, single line.

@pelikhan pelikhan closed this Jan 1, 2026
Copilot stopped work on behalf of pelikhan due to an error January 1, 2026 23:44
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