Skip to content

Preserve inline sub-agent frontmatter during extraction#39577

Merged
pelikhan merged 9 commits into
mainfrom
copilot/fix-sub-agent-model-override
Jun 16, 2026
Merged

Preserve inline sub-agent frontmatter during extraction#39577
pelikhan merged 9 commits into
mainfrom
copilot/fix-sub-agent-model-override

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Inline sub-agents can declare their own frontmatter, including model: overrides and additional engine-specific fields. The extraction path should preserve that frontmatter exactly as authored instead of filtering unsupported keys or corrupting nested YAML.

  • Runtime extractor fix

    • Stop filtering inline sub-agent frontmatter during extraction.
    • Preserve the entire authored frontmatter block as-is in the emitted sub-agent file.
  • Regression coverage

    • Add JS regression coverage for an inline sub-agent frontmatter block where tools: appears between description: and model:.
    • Assert that the emitted sub-agent file preserves the full frontmatter exactly as written.
  • Parser coverage

    • Add a Go parser test that verifies inline sub-agent extraction preserves the full frontmatter exactly in the extracted agent content.
    • Update parser validation coverage so inline sub-agent frontmatter is accepted as long as it remains parseable.
---
description: Helper
tools:
  github:
    toolsets: [issues]
model: claude-haiku-4.5
engine: copilot
---
Prompt.

Now extracts as:

---
description: Helper
tools:
  github:
    toolsets: [issues]
model: claude-haiku-4.5
engine: copilot
---
Prompt.

Copilot AI and others added 2 commits June 16, 2026 15:52
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sub-agent model frontmatter being ignored Preserve inline sub-agent model: frontmatter during extraction Jun 16, 2026
Copilot AI requested a review from pelikhan June 16, 2026 15:59
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the entire frontmatter should be preserved as is

Copilot AI and others added 3 commits June 16, 2026 16:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the entire frontmatter should be preserved as is

Addressed in 952be38. Inline sub-agent extraction now preserves the entire authored frontmatter as-is, and the JS/Go coverage was updated to lock in that behavior.

Copilot AI changed the title Preserve inline sub-agent model: frontmatter during extraction Preserve inline sub-agent frontmatter during extraction Jun 16, 2026
@pelikhan pelikhan marked this pull request as ready for review June 16, 2026 16:42
Copilot AI review requested due to automatic review settings June 16, 2026 16:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 inline sub-agent handling so authored YAML frontmatter blocks are preserved (rather than filtered) during extraction, and adjusts validation/tests to accept arbitrary sub-agent frontmatter as long as it remains parseable.

Changes:

  • Remove runtime filtering of inline sub-agent frontmatter and keep emitted agent content intact.
  • Relax Go sub-agent frontmatter validation to only warn on parse/extraction errors (not unknown keys).
  • Add Go + JS regression tests to ensure nested YAML and field ordering are preserved.
Show a summary per file
File Description
pkg/parser/sub_agent_validation_test.go Updates validation expectations to allow arbitrary sub-agent frontmatter and adds a malformed-frontmatter warning test.
pkg/parser/sub_agent_extractor.go Removes unknown-field validation and validates only frontmatter parseability for inline sub-agents.
pkg/parser/sub_agent_extractor_test.go Adds a regression test asserting extracted sub-agent content preserves the authored frontmatter block.
actions/setup/js/extract_inline_sub_agents.test.cjs Updates JS tests to assert frontmatter is preserved (including order and nested YAML).
actions/setup/js/extract_inline_sub_agents.cjs Removes frontmatter filtering logic and preserves agent content when writing extracted agent files.

Copilot's findings

Tip

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

  • Files reviewed: 5/5 changed files
  • Comments generated: 3

Comment on lines 199 to 203
"---",
"engine: copilot",
"on:",
" workflow_dispatch:",
"---",
`description: "unterminated string`,
"model: claude-haiku-4.5",
"Do work.",
}, "\n")
Comment thread pkg/parser/sub_agent_extractor.go Outdated
// - description: Human-readable description of the sub-agent's role.
// - model: AI model to use. Default is "inherited" (uses the parent
// workflow's model when not set).
// Sub-agent frontmatter is preserved exactly as authored.
// description Human-readable description of the sub-agent's role.
// model AI model to use. Default is "inherited" (uses the parent
// workflow's model when not set).
// Sub-agent frontmatter is preserved exactly as authored.
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

…omments

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Done. Addressed all three open review threads in the latest commit:

  • ParseError fixture (sub_agent_validation_test.go) — added the missing closing --- delimiter so the test now exercises a real YAML parse error (unterminated string) rather than "frontmatter not properly closed".
  • Comment wording (sub_agent_extractor.go and extract_inline_sub_agents.cjs) — softened "preserved exactly as authored" to "keys and order are preserved without filtering; boundary whitespace is trimmed" in both files.

Local make agent-report-progress (build + fmt + lint + test-unit) passes cleanly.

@pelikhan pelikhan merged commit c90da21 into main Jun 16, 2026
37 checks passed
@pelikhan pelikhan deleted the copilot/fix-sub-agent-model-override branch June 16, 2026 17:42
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.

3 participants