Skip to content

Improve agent file missing error message with actionable frontmatter guidance#19966

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/improve-agent-file-validation-message
Closed

Improve agent file missing error message with actionable frontmatter guidance#19966
Copilot wants to merge 2 commits intomainfrom
copilot/improve-agent-file-validation-message

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

The error shown when an agent file doesn't exist used vague language ("properly imported") that gave users no indication of where to configure agent paths or what format to use.

Change

Updated the error message in pkg/workflow/agent_validation.go to reference the frontmatter agent: field directly and include a concrete example path:

// Before
fmt.Sprintf("agent file '%s' does not exist. Ensure the file exists in the repository and is properly imported.", agentPath)

// After
fmt.Sprintf("agent file '%s' does not exist. Check your workflow frontmatter: the 'agent:' field should reference a valid file path (e.g., '.github/agents/custom.agent.md')", agentPath)

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

…atter example

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve agent file validation error message with examples Improve agent file missing error message with actionable frontmatter guidance Mar 7, 2026
@pelikhan pelikhan marked this pull request as ready for review March 7, 2026 15:26
Copilot AI review requested due to automatic review settings March 7, 2026 15:26
@pelikhan pelikhan closed this Mar 7, 2026
Copy link
Contributor

Copilot AI left a comment

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 updates the error message shown when a referenced agent file doesn't exist during compilation. The intent is to replace vague guidance ("properly imported") with actionable frontmatter guidance.

Changes:

  • Updated the error message in validateAgentFile() to mention the frontmatter field and include an example path.

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

You can also share your feedback on Copilot code review. Take the survey.

if os.IsNotExist(err) {
return formatCompilerError(markdownPath, "error",
fmt.Sprintf("agent file '%s' does not exist. Ensure the file exists in the repository and is properly imported.", agentPath), nil)
fmt.Sprintf("agent file '%s' does not exist. Check your workflow frontmatter: the 'agent:' field should reference a valid file path (e.g., '.github/agents/custom.agent.md')", agentPath), nil)
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The error message refers to "the 'agent:' field" in the workflow frontmatter, but there is no top-level agent: frontmatter field. The AgentFile is actually populated through the imports: frontmatter field when a file under .github/agents/ is imported (see pkg/parser/import_bfs.go:180-198 and pkg/workflow/frontmatter_types.go:164). The engine.agent field in frontmatter (pkg/workflow/engine.go:206-212) is for specifying an agent identifier string, not a file path.

The message should reference the imports: field instead, and the example should show the imports syntax (e.g., imports: ['.github/agents/custom.agent.md']). The current wording will mislead users into looking for a non-existent agent: frontmatter key.

Suggested change
fmt.Sprintf("agent file '%s' does not exist. Check your workflow frontmatter: the 'agent:' field should reference a valid file path (e.g., '.github/agents/custom.agent.md')", agentPath), nil)
fmt.Sprintf("agent file '%s' does not exist. Check your workflow frontmatter: ensure the 'imports:' field includes a valid agent file path (for example: imports: ['.github/agents/custom.agent.md'])", agentPath), nil)

Copilot uses AI. Check for mistakes.
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.

Improve agent file validation error message with explicit examples

3 participants