Skip to content

Optimize spec-enforcer prompt with inline small-model sub-agents#32641

Merged
pelikhan merged 3 commits into
mainfrom
copilot/subagent-optimizer-optimize-spec-enforcer
May 16, 2026
Merged

Optimize spec-enforcer prompt with inline small-model sub-agents#32641
pelikhan merged 3 commits into
mainfrom
copilot/subagent-optimizer-optimize-spec-enforcer

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

spec-enforcer was consuming very high Claude tokens without using inline sub-agents, despite having separable extractive/classification phases. This updates the workflow prompt to offload bounded tasks to small-model inline agents while preserving main-model ownership of test generation and PR authoring.

  • Phase 0: rotation recovery delegated

    • Replaced inlined regex/parsing instructions with a call to rotation-state-recoverer.
    • Updated PR fetch shape to include mergedAt and clarified fallback rotation state handling.
  • Phase 2: README extraction parallelized

    • Replaced direct README-reading/extraction instructions with parallel calls to readme-spec-extractor per selected package.
    • Declared extractor JSON output as the source of truth for Phase 3 test generation inputs.
  • Phase 4: test/build failure triage delegated

    • Replaced manual failure interpretation flow with test-output-classifier output-driven actions:
      • fix_test
      • flag_spec_ambiguity
      • flag_spec_mismatch
      • investigate
  • Inline sub-agent definitions added

    • Appended three inline agent blocks to .github/workflows/spec-enforcer.md:
      • rotation-state-recoverer (model: small)
      • readme-spec-extractor (model: small)
      • test-output-classifier (model: small)
### Step 1: Extract the specification

For each selected package, invoke the `readme-spec-extractor` agent in parallel — pass it the contents of `pkg/<package>/README.md`. Use the returned JSON as the source of truth when generating tests in Phase 3.

Copilot AI and others added 2 commits May 16, 2026 15:05
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] Optimize spec-enforcer with inline sub-agents Optimize spec-enforcer prompt with inline small-model sub-agents May 16, 2026
Copilot AI requested a review from pelikhan May 16, 2026 15:11
@pelikhan pelikhan marked this pull request as ready for review May 16, 2026 15:11
Copilot AI review requested due to automatic review settings May 16, 2026 15:11
@pelikhan pelikhan merged commit 25e631e into main May 16, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/subagent-optimizer-optimize-spec-enforcer branch May 16, 2026 15:11
Copy link
Copy Markdown
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

Updates the spec-enforcer workflow prompt to reduce token usage by delegating bounded parsing/extraction/classification steps to inline small-model sub-agents, while keeping the main model responsible for test generation and PR authoring.

Changes:

  • Delegates rotation recovery to a new rotation-state-recoverer inline agent (and fetches mergedAt in PR list output).
  • Parallelizes README specification extraction via readme-spec-extractor and uses its JSON as the Phase 3 test-generation source of truth.
  • Delegates build/test failure triage to test-output-classifier with a fixed action taxonomy.
Show a summary per file
File Description
.github/workflows/spec-enforcer.md Refactors prompt phases to invoke inline sub-agents for rotation recovery, README spec extraction, and test output classification.
.github/workflows/pr-sous-chef.lock.yml Regenerates the workflow lockfile to reflect updated prompt/heredoc identifiers and minor formatting deltas.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines +137 to +146
3. If `rotation.json` is missing or empty, fetch the most recently merged PR with:
- `gh pr list --repo ${{ github.repository }} --state merged --label pkg-specifications --limit 1 --json number,body,mergedAt`
Then use the `rotation-state-recoverer` agent — pass it the PR body text and the eligible package list — to produce the rotation JSON. Write the agent's output to `rotation.json` (set `last_run` to the PR's `mergedAt` UTC date). If no matching PR exists, write fallback state:
```json
{
"last_index": -1,
"last_packages": [],
"last_run": "unknown",
"total_eligible": N
}
Comment on lines +425 to +426
Output JSON only:
`{"last_index": <int>, "last_packages": ["..."], "total_eligible": <int>}`
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.

[subagent-optimizer] Optimize spec-enforcer — 2026-05-16

3 participants