Files
Holocron/plugins/kyberforge/docs/research/docs/microsoft-apm/agent-primitive-schema.md
T
Defame1297 96bc946030 docs(kyberforge): fix provenance chain gap in agent-primitive-schema.md
The file's body cites APM's Python source directly (apm_cli/models/validation.py,
apm_cli/primitives/models.py) to support its "no dedicated Agent validation"
claim, but source_keys only listed context7-microsoft-apm — the apm-github-repo
source_key was missing, and sources.md's apm-github-repo entry didn't list this
file under Contributing files either. The three sibling schema files from the
same commit (prompt/instructions/hooks) all cited both sources correctly.

Found via post-implementation review of issue #89.
2026-08-11 18:34:36 +00:00

9.3 KiB

topic, source_keys
topic source_keys
agent-primitive-schema
context7-microsoft-apm
apm-github-repo

Agent frontmatter is not a fixed APM-defined schema

APM's design principle (PRINCIPLES.md, P1 "No invented primitive frontmatter") is that APM emits to the canonical schema of each upstream harness and does not invent its own frontmatter keys. Consequently there is no single APM-owned "complete field list" for .apm/agents/*.agent.md the way there is for apm.yml. The docs describe six fields as commonly used, and treat everything else as pass-through content the author writes for whichever harness(es) they target:

Field Required Purpose Recognized by
name Recommended Display identifier; falls back to the filename stem if omitted Universal, but Kiro derives identity from the deployed file path instead and strips this field
description Yes Used for agent discovery (e.g. by Cascade/Copilot) Universal
model Optional Model the harness switches to when the agent is invoked Copilot, Claude, Grok Build, Cursor, OpenCode (not Kiro's runtime behavior beyond passthrough; not meaningfully supported by Codex)
tools Optional Whitelist of callable tools/capabilities Copilot, Claude, Grok Build, Cursor, OpenCode, Kiro (each with different accepted value shapes — see below)
color Optional Display color in harness UI Copilot, Claude, OpenCode only
handoffs Optional Named agents (or structured objects) this agent can delegate to Universal in principle; concretely modeled as a field on the internal Chatmode primitive (list[str | dict] | None), suggesting .agent.md is treated as a thin transform target rather than a fully independent, strongly-typed primitive internally

Claude Code fields NOT documented anywhere in APM's corpus: isolation, maxTurns, effort, memory, permissionMode, disallowedTools, background, initialPrompt. Copilot CLI tool-alias shorthand (execute/read/edit/search/agent/web) is also undocumented in APM's material — Copilot's agent tools are documented only as the ToolName: true/false map form. This is a genuine documentation gap, not an oversight on our part: APM's stated philosophy is to stay out of the way of harness-specific fields, so anything beyond the six-field table above is simply not modeled, validated, or discussed by APM — it would ride through compilation as opaque frontmatter for "verbatim" targets (see below) and be silently dropped for targets that do field-level reconstruction (Codex, Kiro).

Compile-time mapping per target

apm compile reads .apm/agents/*.agent.md and reconciles per-target output according to the targets/compilation block in apm.yml. Behavior is verbatim-copy for most targets, with three targets doing real field-level transformation:

Target Output path Field treatment
Copilot .github/agents/<name>.agent.md Verbatim
Claude .claude/agents/<name>.md Verbatim
Grok Build .grok/agents/<name>.md Verbatim
Cursor .cursor/agents/<name>.md Verbatim
OpenCode .opencode/agents/<name>.md Verbatim, but gated by strict validation (see below)
Codex .codex/agents/<name>.toml Reconstructed: only name and description map into TOML fields; the markdown body becomes developer_instructions. model/tools are not yet translated into Codex's MCP/tool transport config — effectively dropped
Kiro .kiro/agents/<relative-stem>.md Reconstructed: keeps only description, model, tools; strips name and any unknown field; identity comes from the file's path, not frontmatter
Windsurf Not deployed as an agent No agents primitive exists for Windsurf — Cascade auto-invokes skills by description, so a separate agent construct would collide; author as a skill instead
Gemini Not deployed as an agent Gemini has no agents primitive either; content is folded into GEMINI.md context instead

No claude:/copilot: provider-override or passthrough sub-key exists anywhere in APM's schema or docs. This was checked specifically (frontmatter reference doc, manifest schema, compile reference, prompts pitfalls page) — the only analogous behavior found is for the prompts primitive, where APM documents that only five frontmatter keys are preserved across all targets and provider-only keys (author, mcp, parameters) are silently stripped on every provider except Copilot. No equivalent table exists for the agent primitive beyond the six-field summary above and the per-target rows in this table. There is no way for a single vendor-neutral .agent.md to carry a provider-only setting (e.g. Claude Code's isolation or permissionMode) through compilation to just one target — the field would either pass through verbatim (Claude/Copilot/Grok/Cursor, since those are unvalidated copies) or get silently dropped (Codex, Kiro, and OpenCode if it fails that target's strict shape check).

The tools: field's shape is target-dependent, not fixed

APM does not enforce one canonical shape. Different targets expect different shapes, and since APM doesn't invent or normalize frontmatter (P1), the author is effectively writing in whichever shape their primary target consumes:

  • Map of booleans — tools: {Read: true, Grep: true} — the form shown in APM's own canonical example and the form required by OpenCode's strict validator (apm install -t opencode warns at install time if tools is anything else, e.g. a list).
  • List of strings — tools: ["file-manager", "git-analysis"] — appears in APM's own reference examples page; not glob-based and not mcp__*-namespaced in any example found.
  • Kiro capability tags — a closed vocabulary distinct from tool names: read, write, shell, web, subagent, knowledge, context, todo_list, @mcp, @builtin, *. Kiro fails closed (refuses the whole write, no partial deploy) if any value in tools falls outside this set.
  • No documented support for glob patterns or mcp__*-prefixed tool-name patterns as a tools: value shape anywhere in the corpus.

Net effect for retargeting agent-author: there's no single tools: normalization APM performs for you. If the skill needs to emit a .apm/agents/*.agent.md that survives compilation to both Claude Code and Copilot CLI cleanly, it should use the {ToolName: true} map form (both targets treat agents as verbatim copies, so whatever is written is what each harness receives directly — meaning the shape must already match what Claude Code's own agent frontmatter and Copilot's agent frontmatter expect natively, since APM performs no translation for either).

Validation, naming, and size constraints

There is no dedicated Agent/AgentPrimitive validation function or dataclass in APM's own codebase (apm_cli/models/validation.py, apm_cli/primitives/models.py) — validation logic exists for apm.yml, SKILL.md, plugin.json, hooks, and other primitives, but .agent.md is not independently modeled or validated by generic APM code. What constraints exist are documented as authoring guidance rather than enforced checks, plus the per-target strict checks already covered above (OpenCode's tools/color shape check, Kiro's fail-closed tool allowlist):

  • Naming: avoid the names default or start — they collide with apm run script name resolution.
  • Body size: keep the markdown body under ~300 lines to preserve context window budget.
  • Body structure guidance: open with role and scope in two sentences; define boundaries and expected output artifacts; don't duplicate global/workspace instructions the agent already inherits — override or extend only.
  • File location/extension: must live at .apm/agents/<name>.agent.md.
  • No documented uniqueness enforcement, required-field enforcement, or file-size hard limit beyond the above authoring guidance — this is a real gap, not an omission on our part: it simply isn't implemented as a checked rule anywhere in the source.

Skill primitive: compilation is a straight copy, confirmed

apm install/apm compile never rewrite or rename SKILL.md per target — deployment is a literal directory copy (shutil.copytree) of the whole skill folder (SKILL.md plus scripts/, references/, assets/, examples/), with symlinks and cache markers filtered out. SKILL.md's content is treated as immutable; only its placement varies by target. This is on top of, not a contradiction of, what's already in configuration.md/examples.md.

The one nuance not previously captured: path routing changed via a "skills convergence." Most targets (Copilot, Cursor, Codex, Gemini, OpenCode, Windsurf, and the explicit agent-skills target) now converge on a single shared .agents/skills/<name>/SKILL.md location to avoid duplicate copies across harnesses. Three targets still use harness-native paths because their default file scan looks only in their own directory: Claude (.claude/skills/), Kiro (.kiro/skills/), and Grok Build (.grok/skills/). The pre-convergence, per-harness-copy behavior can be restored with --legacy-skill-paths or APM_LEGACY_SKILL_PATHS=1. includes:/compilation.placement: (as already documented in configuration.md) apply to instructions/prompts placement, not to skills — no skill-specific effect from those keys was found anywhere in the corpus.