Skip to Content
GuidesCreate an Agent

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
πŸ’‘

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

Last updated on