Clean up agent system: fix orchestrator.yaml schema compliance, unify validation paths#28
Conversation
…cripts, add unified check-agents.py Co-authored-by: peternicholls <519525+peternicholls@users.noreply.github.com>
|
@copilot Objective:
Hard requirements:
Deliverables:
|
There was a problem hiding this comment.
Pull request overview
This PR resolves validation inconsistencies in the PaperKit agent system by fixing schema compliance issues, correcting path references, and adding unified validation tooling.
Key changes:
- Fixed
orchestrator.yamlto comply with agent schema (added requiredidentityandpathfields, removed non-standard fields) - Corrected hardcoded
.paper/paths to.paperkit/across validation scripts - Added unified
check-agents.pytool for comprehensive agent system validation
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.paperkit/_cfg/agents/orchestrator.yaml |
Completely restructured to match schema requirements with proper identity, capabilities, constraints, and input/output schemas |
.paperkit/_cfg/agent-manifest.yaml |
Added orchestrator entry and updated statistics (11 total agents, 7 core) |
.paperkit/tools/validate.py |
Fixed all hardcoded paths from .paper/ to .paperkit/ for schemas, agents, workflows, tools, and manifests |
.paperkit/tools/validate-agent-schema.py |
Updated default path documentation and hardcoded defaults from .paper/ to .paperkit/ |
.paperkit/tools/check-agents.py |
New unified validation tool that checks YAML schema compliance, duplicate names, path references, manifest consistency, and MD file coverage |
.github/workflows/validate-agent-metadata.yml |
Added unified check step and path triggers for core/specialist agent directories |
docs/dev/agent-audit/baseline.txt |
Documents pre-fix validation state showing orchestrator as invalid |
docs/dev/agent-audit/inventory.md |
Catalogs dual agent system (YAML metadata + MD definitions) |
docs/dev/agent-audit/runtime-paths.md |
Analyzes runtime loading paths and identifies path inconsistencies |
docs/dev/agent-audit/decision.md |
Documents rationale for keeping dual system and implementation plan |
docs/dev/agent-audit/how-agents-are-structured.md |
Comprehensive guide explaining agent structure and validation |
docs/dev/agent-audit/paperkit-tree.txt |
Directory tree snapshot for reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/dev/agent-audit/decision.md
Outdated
| ### Phase 1: Fix Schema Compliance | ||
| - [ ] Update `orchestrator.yaml` to be schema-compliant | ||
| - [ ] Verify all YAML files pass validation | ||
|
|
||
| ### Phase 2: Fix Validation Scripts | ||
| - [ ] Update `validate.py` to use `.paperkit/` paths | ||
|
|
||
| ### Phase 3: Update Manifest | ||
| - [ ] Add orchestrator to `agent-manifest.yaml` | ||
|
|
||
| ### Phase 4: Add Unified Check | ||
| - [ ] Create `tools/check-agents.sh` that: | ||
| - Validates all YAML files against schema | ||
| - Validates all MD frontmatter against schema | ||
| - Checks for name mismatches | ||
| - Ensures path references exist | ||
| - Detects duplicate agent names | ||
|
|
||
| ### Phase 5: Documentation | ||
| - [ ] Create "How agents are structured" guide |
There was a problem hiding this comment.
The implementation plan shows all tasks as unchecked, but based on the PR changes, these tasks appear to have been completed. The checkboxes should be marked as complete to accurately reflect the work done in this PR.
.paperkit/tools/check-agents.py
Outdated
| """ | ||
|
|
||
| import sys | ||
| import os |
There was a problem hiding this comment.
Import of 'os' is not used.
| import os |
.paperkit/tools/check-agents.py
Outdated
| import yaml | ||
| import argparse | ||
| from pathlib import Path | ||
| from typing import Dict, List, Tuple, Optional, Set |
There was a problem hiding this comment.
Import of 'Set' is not used.
| from typing import Dict, List, Tuple, Optional, Set | |
| from typing import Dict, List, Tuple, Optional |
|
@copilot apply changes based on the comments in this thread |
…ter), update decision.md with correct canonical design Co-authored-by: peternicholls <519525+peternicholls@users.noreply.github.com>
... Addressed in commit
|
Co-authored-by: peternicholls <519525+peternicholls@users.noreply.github.com>
Fixed in commit
Note: The |
|
@copilot apply changes based on the comments in this thread |
These changes were already applied in commit
All review comments have been addressed. |
Summary
Clean up PaperKit's agent system to establish the canonical two-file split:
.paperkit/_cfg/agents/*.yaml) = schema-validated metadata ONLY.paperkit/{core,specialist}/agents/*.md) = behavioural instructions ONLYChanges
orchestrator.yaml
agent-schema.jsonrequirementspathpoints to.paperkit/core/agents/orchestrator.mdorchestrator.md
Documentation
docs/dev/agent-audit/decision.mdwith correct canonical designdocs/dev/agent-audit/how-agents-are-structured.mdto clarify the splitCode Quality
os,Set) fromcheck-agents.pyValidation Results
Original prompt
Copilot Agent Mission Brief: PaperKit .paperkit/ cleanup and de-duplication
Goal
Clean up PaperKit’s agent system so there is one canonical agent definition system that:
• matches the agent-schema.json rules
• is what the runtime actually uses to load/run agents
• has no duplicated “second system” lingering in parallel (or, if backward-compat is required, duplicates are replaced with a deliberate compatibility layer)
Non-negotiables
• Do not break existing PaperKit workflows/CLI behaviour.
• Do not change the schema unless you can prove the schema is wrong (it looks good).
• Preserve academic integrity constraints in agent instructions (don’t accidentally weaken them during migration).
• Every change must be backed by repo evidence (grep + file inspection), not assumptions.
⸻
Phase 0 — Safety + Baseline
1. Create a branch: chore/agent-system-unification.
2. Record a baseline:
• Run existing validation command(s) and save output to docs/dev/agent-audit/baseline.txt.
• Run whatever tests/lints exist (or make test / pytest / etc.), save output too.
3. Make a “do no harm” inventory snapshot:
• Save tree -a .paperkit > docs/dev/agent-audit/paperkit-tree.txt (or equivalent on Windows).
⸻
Phase 1 — Forensic Discovery (find the two systems and who uses what)
1.1 Locate the schema + validator
• Find the schema file in repo:
• rg -n "agent-schema.json|PaperKit Agent Definition Schema" -S .paperkit
• Find the validator script referenced by the manifest comment:
• rg -n "validate-agent-schema|agent-schema" -S .paperkit open-agent-system tools
1.2 Enumerate “agent definition” locations
Collect counts and lists:
• .paperkit/core/agents/*
• .paperkit/specialist/agents/*
• any _cfg agents: .paperkit/_cfg/agents/* (or .paperkit/_cfg/...)
Commands:
• find .paperkit -maxdepth 4 -type f | rg "/agents/"
• find .paperkit -type f -name ".yaml" | rg "agents"
• find .paperkit -type f -name ".md" | rg "agents"
Write a short report to docs/dev/agent-audit/inventory.md listing:
• all agent definition files (path + extension)
• which look canonical (match schema path pattern vs not)
• any “manifest” index files (like your YAML manifest)
1.3 Determine runtime loading path (the key question)
Search code for references to:
• .paperkit/_cfg/agents
• .paperkit/core/agents
• .paperkit/specialist/agents
• “manifest”, “agent registry”, “agent loader”, “open-agent-system”
Commands:
• rg -n "_cfg/agents|core/agents|specialist/agents|agent manifest|agent loader|load.*agent" -S .
Identify:
• The code path(s) that load agents at runtime
• The expected file format (MD? YAML? front matter?)
• Whether the runtime uses the schema validator or bypasses it
Document findings in docs/dev/agent-audit/runtime-paths.md with:
• file + function names
• what directories are scanned
• how agent metadata is parsed
⸻
Phase 2 — Decide Canonical System (based on evidence)
Decision rule
Prefer the system that:
• matches agent-schema.json without hacks
• is already aligned with the repo structure (.paperkit/core and .paperkit/specialist)
• is easiest to keep stable long-term
Likely outcome (verify in repo):
• Canonical agent definitions = .paperkit/{core|specialist}/agents/.md
• _cfg/agents/.yaml is legacy OR internal config that got mistaken for canonical
But do not assume — prove by runtime loader.
Write the decision and rationale to docs/dev/agent-audit/decision.md.
⸻
Phase 3 — Unification Plan (choose one of these and implement)
Option A (preferred): Make MD agents canonical, retire YAML agents
Do this if runtime already supports MD agents or can easily be made to.
Steps:
1. Ensure every active agent in the manifest exists as a .paperkit/{core|specialist}/agents/.md
2. If YAML-only agents exist, migrate them to .md:
• Convert YAML fields → schema fields:
• name, displayName, title, icon, module, path
• identity.role, identity.description, identity.communicationStyle
• capabilities, constraints, principles, examplePrompts
• Put the operational prompt/instructions into the Markdown body.
3. Update the runtime loader to scan only:
• .paperkit/core/agents/.md
• .paperkit/specialist/agents/.md
4. Add a compatibility shim ONLY if needed:
• If parts of PaperKit still expect _cfg/agents/*.yaml, replace them with either:
• symlinks (if supported), or
• a generated file step, or
• a tiny adapter that reads YAML and emits in-memory schema objects
• BUT: the adapter should be explicitly marked “legacy” and have a deprecation path.
Option B: Make YAML canonical and update schema
Only do this if runtime is deeply YAML-based and MD agents don’t actually exist / aren’t used.
If you choose this, you must:
• update the schema’s path regex to match reality
• ensure schema validation still blocks drift
• update repo structure to remove misleading core/agents expectations
Given your screenshot and schema, Option A is probably right — but again: confirm.
⸻
Phase 4 — Remove duplica...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.