Skip to content

Fix copilot agent discovery when running through AWF firewall#4434

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/investigate-agent-path-issue
Closed

Fix copilot agent discovery when running through AWF firewall#4434
Copilot wants to merge 5 commits intomainfrom
copilot/investigate-agent-path-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 20, 2025

Copilot CLI couldn't find custom agent files when wrapped by AWF because agent files in ${GITHUB_WORKSPACE}/.github/agents/ were inaccessible to the containerized process.

Changes

  • Copy agent files to copilot's expected location: When firewall is enabled with a custom agent, copy from AWF's mounted host filesystem (/host${GITHUB_WORKSPACE}/<agent-path>) to /home/runner/.copilot/agents/<identifier>.md
  • Conditional execution: Only applies when both isFirewallEnabled(workflowData) and workflowData.AgentFile != ""

Implementation

In pkg/workflow/copilot_engine.go:

// When firewall is enabled and a custom agent is specified, copy the agent file
// to where Copilot CLI expects to find it (/home/runner/.copilot/agents/)
// AWF mounts the host filesystem to /host, so we access the workspace via /host${GITHUB_WORKSPACE}
if isFirewallEnabled(workflowData) && workflowData.AgentFile != "" {
    agentIdentifier := ExtractAgentIdentifier(workflowData.AgentFile)
    
    yaml.WriteString("          mkdir -p /home/runner/.copilot/agents\n")
    yaml.WriteString(fmt.Sprintf("          cp \"/host${GITHUB_WORKSPACE}/%s\" \"/home/runner/.copilot/agents/%s.md\"\n", 
        workflowData.AgentFile, agentIdentifier))
}

Testing

Added pkg/workflow/copilot_agent_firewall_test.go covering:

  • Firewall + agent → copies file
  • Firewall without agent → no copy
  • No firewall + agent → no copy
  • Path transformation validation

Fixes https://github.com/githubnext/gh-aw/actions/runs/19542635233/job/55952916706

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>copilot confused about finding custom agents when running through ghafw/npx</issue_title>
<issue_description>In this run, copilot fails to find the custom agent https://github.com/githubnext/gh-aw/actions/runs/19542635233/job/55952916706 . It does find it locally so I am wondering what is the current folder for the agent.</issue_description>

Comments on the Issue (you are @copilot in this section)

@Mossaka @copilot can you investigate if the awf firwall has changed the path for the agent process? the awf should grant the entire filesystem and mount host filesystem to /host.

💡 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.

Copilot AI and others added 3 commits November 20, 2025 19:58
- When AWF wraps copilot, agent files from ${GITHUB_WORKSPACE} are not accessible
- AWF mounts host filesystem to /host, so we copy agent files from /host${GITHUB_WORKSPACE}
- Copy agent file to /home/runner/.copilot/agents/ where copilot CLI expects to find it
- Only applies when both firewall and custom agent are enabled
- Add integration tests to verify the fix

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
…sts passing

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix agent path resolution in ghafw/npx execution Fix copilot agent discovery when running through AWF firewall Nov 20, 2025
Copilot AI requested a review from Mossaka November 20, 2025 20:08
@Mossaka
Copy link
Copy Markdown
Collaborator

Mossaka commented Nov 24, 2025

#4693 should fix it

@Mossaka Mossaka closed this Nov 24, 2025
@pelikhan pelikhan deleted the copilot/investigate-agent-path-issue branch December 1, 2025 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copilot confused about finding custom agents when running through ghafw/npx

2 participants