Improve agent file missing error message with actionable frontmatter guidance#19966
Improve agent file missing error message with actionable frontmatter guidance#19966
Conversation
…atter example Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
| 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) |
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.goto reference the frontmatteragent:field directly and include a concrete example path:💡 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.