Fix Copilot agent path to use identifier instead of full path#3686
Conversation
- Change ResolveAgentFilePath to wrap entire path in double quotes
- Previously: "${GITHUB_WORKSPACE}"/.github/agents/test.md (broken)
- Now: "${GITHUB_WORKSPACE}/.github/agents/test.md" (working)
- Update all affected tests to expect correct format
- Fixes shell variable expansion issue in Copilot engine
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add TestShellVariableExpansionInAgentPath to verify correct quoting
- Add TestShellEscapeArgWithFullyQuotedAgentPath to verify no re-escaping
- Tests validate that ${GITHUB_WORKSPACE} will be expanded by shell
- Tests verify no single quotes are added that would prevent expansion
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the |
- Add ExtractAgentIdentifier() to extract filename without extension
- Update Copilot engine to pass agent identifier, not full path
- Keep Claude/Codex engines using full path for file reading
- Add comprehensive tests for agent identifier extraction
- Update Copilot engine test to expect agent identifier
Copilot CLI expects agent identifiers like "cli-consistency-checker",
not paths like "${GITHUB_WORKSPACE}/.github/agents/cli-consistency-checker.md"
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
... Fixed in 0e4255e. The Copilot CLI now receives the agent identifier Claude and Codex engines continue using the full path since they read file content with |
…://github.com/githubnext/gh-aw into copilot/investigate-github-workspace-encoding
There was a problem hiding this comment.
Pull Request Overview
This PR fixes how the Copilot CLI agent path is passed by using the agent identifier (filename without extension) instead of the full file path. The Copilot CLI auto-discovers agents and expects identifiers, while Claude and Codex engines need full paths to read file content.
Key Changes
- Added
ExtractAgentIdentifier()function to extract filename without extension from agent file paths - Updated
ResolveAgentFilePath()to properly quote full paths with${GITHUB_WORKSPACE}for Claude/Codex - Updated Copilot engine to use agent identifier instead of full path
- Updated tests to match new expectations
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/engine_helpers.go |
Added ExtractAgentIdentifier() function and updated ResolveAgentFilePath() quoting |
pkg/workflow/copilot_engine.go |
Changed to use ExtractAgentIdentifier() for Copilot CLI --agent flag |
pkg/workflow/engine_helpers_test.go |
Added tests for identifier extraction and updated path format tests |
pkg/workflow/engine_agent_import_test.go |
Updated Copilot test to expect identifier, Claude/Codex tests updated for new quoting |
.github/workflows/technical-doc-writer.lock.yml |
Regenerated lock file (appears incomplete - see bug below) |
.github/workflows/cli-consistency-checker.md |
Removed agent import, inlined agent instructions |
.github/workflows/cli-consistency-checker.lock.yml |
Regenerated lock file after removing agent import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Copilot CLI's
--agentflag expects an agent identifier (filename without extension), not a full file path. This fix extracts the identifier from the agent file path for Copilot while maintaining full path usage for Claude and Codex engines that need to read file content.Root Cause
The Copilot CLI discovers agents automatically and references them by identifier:
Changes
pkg/workflow/engine_helpers.go:ExtractAgentIdentifier()to extract filename without extensionResolveAgentFilePath()to properly quote full paths for Claude/Codexpkg/workflow/copilot_engine.go: Updated to use agent identifier instead of full pathpkg/workflow/engine_helpers_test.go: Added tests for identifier extraction and updated existing testspkg/workflow/engine_agent_import_test.go: Updated Copilot test to expect agent identifierResult
Copilot engine: Uses agent identifier
Claude/Codex engines: Use full path with proper quoting for file reading
"${GITHUB_WORKSPACE}/.github/agents/test-agent.md"Original prompt
💡 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.