{"record":{"id":"df0ddfaf2f40c516","repo":"continuedev/continue","slug":"agent-file-must-contain-yaml-frontmatter-with-a-n","errorCode":null,"errorMessage":"Agent file must contain YAML frontmatter with a 'name' field","messagePattern":"Agent file must contain YAML frontmatter with a 'name' field","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/config-yaml/src/markdown/agentFiles.ts","lineNumber":52,"sourceCode":" */\nexport interface ParsedAgentTools {\n  /** All tool references */\n  tools: AgentToolReference[];\n  /** Unique MCP server slugs that need to be added to config */\n  mcpServers: string[];\n  /** Whether all built-in tools are allowed */\n  allBuiltIn: boolean;\n}\n\n/**\n * Parses and validates an agent file from markdown content\n * Agent files must have frontmatter with at least a name\n */\nexport function parseAgentFile(content: string): AgentFile {\n  const { frontmatter, markdown } = parseMarkdownRule(content);\n\n  if (!frontmatter.name) {\n    throw new Error(\n      \"Agent file must contain YAML frontmatter with a 'name' field\",\n    );\n  }\n\n  const validationResult = agentFileFrontmatterSchema.safeParse(frontmatter);\n\n  if (!validationResult.success) {\n    const errorDetails = validationResult.error.issues\n      .map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n      .join(\", \");\n    throw new Error(`Invalid agent file frontmatter: ${errorDetails}`);\n  }\n\n  return {\n    ...validationResult.data,\n    prompt: markdown,\n  };\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/config-yaml/src/markdown/agentFiles.ts#L34-L70","documentation":"parseAgentFile splits an agent markdown file into frontmatter and prompt; if the YAML frontmatter lacks a 'name' key, the file is rejected before schema validation even runs.","triggerScenarios":"parseAgentFile(content) where content has no frontmatter block, empty frontmatter (---\\n---), or frontmatter without a name field.","commonSituations":"Writing an agent file as plain markdown without frontmatter, malformed frontmatter delimiters so the parser returns an empty object, or trimming the file and losing the header.","solutions":["Add YAML frontmatter at the top delimited by --- with at least 'name: your-agent-name'","Verify the delimiters: opening --- must be the very first line","Confirm the frontmatter is valid YAML (no tabs)"],"exampleFix":"# before\nYou are a helpful agent.\n# after\n---\nname: my-agent\n---\nYou are a helpful agent.","handlingStrategy":"validation","validationCode":"function hasNameFrontmatter(content: string): boolean {\n  const m = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/);\n  return !!m && /^name\\s*:/m.test(m[1]);\n}","typeGuard":null,"tryCatchPattern":"try { parseAgentFile(content); } catch (e) { if (e.message.includes('name')) { /* add frontmatter */ } }","preventionTips":["Start every agent file with ---\\nname: ...\\n---","Template new agent files from a valid one"],"tags":["agent-file","frontmatter","markdown","validation"],"backgroundTag":"missing-frontmatter-field","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}