Replace engine.custom-agent field with imports-based agent files#2838
Replace engine.custom-agent field with imports-based agent files#2838
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Remove custom-agent field from engine configuration - Add support for .agent.md files in imports - Only one agent file allowed per workflow - Agent files detected by .agent.md extension - Update all engines to use AgentFile from WorkflowData - Update tests to reflect new import-based approach - Update technical-doc-writer workflow to use imports - Update JSON schema to remove custom-agent field Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Update custom-agents.instructions.md to reflect imports approach - Remove custom-agent references from frontmatter docs - Document .agent.md extension requirement - Document one agent file per workflow limitation - Update example workflows to use imports Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot any markdown file under .github/agents is considered an custom agent. .agent.md is not required. |
… an agent Changed agent file detection from checking .agent.md extension to checking if the file is under .github/agents/ directory. This matches the expected behavior where any markdown file under .github/agents is treated as a custom agent file. Changes: - Updated detection logic in ProcessImportsFromFrontmatterWithManifest - Renamed technical-doc-writer.agent.md -> technical-doc-writer.md - Updated all documentation to reflect directory-based detection - Updated schema examples and descriptions - Updated tests to use .md extension Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit 2188b18. Changed agent file detection from |
|
Agentic Changeset Generator triggered by this pull request. |
There was a problem hiding this comment.
Pull Request Overview
This PR removes the engine.custom-agent field and replaces it with an imports-based approach for custom agent files. Agent files are now detected automatically when markdown files under .github/agents/ directory are imported via the imports field.
Key changes:
- Removed
custom-agentfield from engine configuration with no legacy support - Agent files now imported through standard
importsmechanism with validation for single agent per workflow - All engines (copilot, claude, codex) updated to read agent path from
WorkflowData.AgentFileinstead ofEngineConfig.CustomAgent
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/validation.go | Simplified agent file validation to check existence without complex path resolution |
| pkg/workflow/engine_agent_import_test.go | Updated test names and removed engine config extraction tests, focused on imports-based agent testing |
| pkg/workflow/engine.go | Removed CustomAgent field from EngineConfig struct and related extraction logic |
| pkg/workflow/copilot_engine.go | Updated to use WorkflowData.AgentFile instead of EngineConfig.CustomAgent |
| pkg/workflow/compiler_jobs.go | Updated checkout step logic to check WorkflowData.AgentFile |
| pkg/workflow/compiler.go | Added AgentFile field to WorkflowData and populated from imports result |
| pkg/workflow/codex_engine.go | Updated to use WorkflowData.AgentFile for agent file handling |
| pkg/workflow/claude_engine.go | Updated to use WorkflowData.AgentFile for agent file handling |
| pkg/parser/schemas/main_workflow_schema.json | Removed custom-agent field from schema and updated imports description |
| pkg/parser/frontmatter.go | Added agent file detection logic in imports processing with single agent validation |
| docs/src/content/docs/reference/frontmatter-full.md | Updated documentation to reflect imports-based agent configuration |
| .github/workflows/unbloat-docs.lock.yml | Updated Node.js action version (unrelated change) |
| .github/workflows/technical-doc-writer.md | Migrated from custom-agent field to imports-based configuration |
| .github/workflows/technical-doc-writer.lock.yml | Updated generated workflow to use full agent file path |
| .github/instructions/custom-agents.instructions.md | Updated documentation to reflect new imports-based agent configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| processedFiles = append(processedFiles, importPath) | ||
|
|
||
| // Check if this is a custom agent file (any markdown file under .github/agents) | ||
| isAgentFile := strings.Contains(fullPath, "/.github/agents/") && strings.HasSuffix(strings.ToLower(fullPath), ".md") |
There was a problem hiding this comment.
The agent file detection logic may fail for Windows paths or paths that don't use Unix-style separators. Consider using filepath.Separator or strings.Contains(filepath.ToSlash(fullPath), \"/.github/agents/\") for cross-platform compatibility.
| isAgentFile := strings.Contains(fullPath, "/.github/agents/") && strings.HasSuffix(strings.ToLower(fullPath), ".md") | |
| isAgentFile := strings.Contains(filepath.ToSlash(fullPath), "/.github/agents/") && strings.HasSuffix(strings.ToLower(fullPath), ".md") |
| if isAgentFile { | ||
| if agentFile != "" { | ||
| // Multiple agent files found - error | ||
| return nil, fmt.Errorf("multiple agent files found in imports: '%s' and '%s'. Only one agent file is allowed per workflow", agentFile, importPath) |
There was a problem hiding this comment.
The error message uses importPath but should use fullPath for consistency with how agentFile is set on line 452. This could show incorrect path information in the error message.
| return nil, fmt.Errorf("multiple agent files found in imports: '%s' and '%s'. Only one agent file is allowed per workflow", agentFile, importPath) | |
| return nil, fmt.Errorf("multiple agent files found in imports: '%s' and '%s'. Only one agent file is allowed per workflow", agentFile, fullPath) |
This PR updates the documentation based on features merged in the last 24 hours. ## Documentation Updates ### Custom Agent Files (PR #2838, #2837) - Added comprehensive documentation for custom agent files in the AI Engines reference - Documented the new imports-based approach for agent files - Provided migration guide from deprecated `engine.custom-agent` field - Included examples of creating and using custom agents ### Permission Validation (PR #2843) - Documented new permission validation behavior in non-strict mode - Added examples of warning messages when permissions are under-provisioned - Explained the difference between non-strict and strict mode validation - Provided actionable guidance for resolving permission warnings ### Agent File Imports (PR #2838) - Updated Imports reference to explain agent file imports - Clarified that only one agent file can be imported per workflow - Cross-referenced Custom Agent Files documentation in Engines reference ## Changes Made - Updated `docs/src/content/docs/reference/engines.md`: - Added "Custom Agent Files" section with creation and usage examples - Documented agent file requirements and constraints - Provided migration guide from `engine.custom-agent` to `imports` - Updated `docs/src/content/docs/reference/frontmatter.md`: - Added "Permission Validation" subsection under Permissions - Documented non-strict mode warning behavior - Documented strict mode error behavior - Included example warning messages - Updated `docs/src/content/docs/reference/imports.md`: - Added "Agent Files" section - Updated "Frontmatter Merging" to mention agent file fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The
engine.custom-agentfield is removed. Agent files are now imported via theimportsfield. Any markdown file under.github/agents/directory is treated as a custom agent file.Changes
custom-agentfrom engine configuration.github/agents/directory are treated as agent filesWorkflowData.AgentFileinstead ofEngineConfig.CustomAgenttechnical-doc-writer.mdmoved to.github/agents/, workflow now uses importsMigration
Before:
After:
No legacy support - clean break.
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.