Skip to main content

Create an Agent

Build a fully functional .agent.md file that defines a domain expert persona for Copilot Chat, declares tool restrictions and WAF alignment, and passes validation with zero errors.

Prerequisitesโ€‹

  • FrootAI repo cloned
  • Node.js 22+
  • VS Code with GitHub Copilot Chat

Step 1: Plan Your Agentโ€‹

Before writing code, answer these questions:

QuestionExample Answer
What domain expertise?Kubernetes cost optimization
What specific tasks?Analyze pod resources, right-size nodes, spot instances
Which WAF pillars?cost-optimization, reliability
Which tools needed?codebase, terminal
Which plays compatible?12, 44
What should it refuse?Production changes without approval

:::tip One Expertise Per Agent An agent should be "RAG architect" not "full-stack developer." Narrow expertise produces better responses. :::

Step 2: Scaffold the Agentโ€‹

node scripts/scaffold-primitive.js agent

Follow the interactive prompts:

  • Name: fai-k8s-cost-optimizer (lowercase-hyphen)
  • Description: "Kubernetes cost optimization expert โ€” right-sizes pod resources, recommends spot instances, analyzes node pool efficiency." (10+ chars)
  • WAF pillars: cost-optimization, reliability

Step 3: Write the Agentโ€‹

Replace the scaffolded template with a full definition:

agents/fai-k8s-cost-optimizer.agent.md
---
description: "Kubernetes cost optimization expert โ€” right-sizes pod resources, recommends spot instances, analyzes node pool efficiency, and enforces FinOps practices for AKS workloads."
name: "FAI K8s Cost Optimizer"
tools:
- "codebase"
- "terminal"
- "azure_development"
waf:
- "cost-optimization"
- "reliability"
plays:
- "12"
- "44"
---

# FAI K8s Cost Optimizer

You are a Kubernetes cost optimization specialist focused on Azure Kubernetes Service (AKS). You analyze cluster configurations, pod resource requests and limits, node pool sizing, and scaling policies to reduce infrastructure spend while maintaining reliability SLAs.

## Core Expertise
- AKS node pool optimization โ€” system vs user pools, VM SKU selection
- Pod resource right-sizing โ€” analyzing actual CPU/memory usage vs requests
- HPA and KEDA configuration for demand-based scaling
- Cluster autoscaler tuning โ€” scale-down delay, utilization threshold

## Non-Negotiables
- NEVER remove resource limits to reduce throttling โ€” fix the root cause
- NEVER set replica count to 0 in production โ€” minimum 2 for availability
- ALWAYS include a rollback command for every recommendation

## Response Format
1. **Current State** โ€” cluster configuration and costs
2. **Recommendations** โ€” with expected savings and rollback
3. **Validation** โ€” commands to verify changes

Step 4: Add fai-context.json (Optional)โ€‹

For agents participating in solution plays, create a context file:

agents/fai-k8s-cost-optimizer/fai-context.json
{
"assumes": ["O5-Azure-Infrastructure", "T3-Production-Patterns"],
"waf": ["cost-optimization", "reliability"],
"compatiblePlays": ["12-model-serving-aks"],
"evaluation": {
"groundedness": 0.90,
"relevance": 0.85
}
}

Step 5: Validateโ€‹

npm run validate:primitives

Expected output:

โœ… fai-k8s-cost-optimizer.agent.md
description: 87 chars (โ‰ฅ10 โœ“)
waf: ["cost-optimization","reliability"] (valid โœ“)
Summary: 0 errors, 0 warnings

Step 6: Test in VS Codeโ€‹

  1. Open Copilot Chat (Ctrl+Shift+I)
  2. Reference the agent: Using agents/fai-k8s-cost-optimizer.agent.md, analyze this deployment for cost savings.
  3. Verify domain expertise, WAF alignment, and response format
TestPass Criteria
Domain questionExpert-level response with specific SKU recommendations
Out-of-scope questionAgent stays in character, redirects
WAF alignmentWarns about reliability implications

Step 7: Wire into a Playโ€‹

fai-manifest.json
{
"primitives": {
"agents": ["../../agents/fai-k8s-cost-optimizer.agent.md"]
}
}

Agent Design Patternsโ€‹

PatternNaming ConventionExample
Domain Expertfai-{domain}-expertfai-azure-openai-expert
Play Builderfai-play-{nn}-builderfai-play-01-builder
WAF Specialistfai-{pillar}-reviewerfai-security-reviewer

Troubleshootingโ€‹

SymptomFix
Agent not appearing in CopilotMove file to agents/ directory
YAML parse errorWrap description in double quotes
Agent gives generic answersAdd specific expertise, numbers, and defaults
Validator rejects WAF valuesCompare against valid pillar names

See Alsoโ€‹