Skill — AI Agent Deployment
When this skill activates
Any task involving deploying AI agents to production, versioning agent configurations,
A/B testing agent variants, monitoring agent quality in production,
or managing the operational lifecycle of AI agents.
Mandatory actions when this skill is active
Before writing any code
- Define the agent version tuple: model + prompt + tools + config (all pinned together).
- Identify success metrics (quality, latency, cost, user satisfaction).
- Plan rollback strategy (instant version pointer switch).
- Design monitoring (token usage, error rate, quality signal).
During implementation
- Package agent as a versioned, immutable deployment artifact.
- Implement health check endpoint (synthetic task probe).
- Add structured logging for every agent action (input, output, tools used, tokens).
- Build traffic splitting capability for A/B and canary.
- Instrument cost tracking per-task and per-user.
- Implement graceful degradation (fallback to simpler model on failure).
After implementation
- Verify shadow test shows no regression vs current version.
- Confirm monitoring dashboards capture all key metrics.
- Test rollback procedure end-to-end.
- Validate cost projections against actual usage.
- Run synthetic probes for health verification.
Versioning Strategy
Agent Version = Immutable Tuple
{
"version": "agent-v2.3.1",
"model": "claude-sonnet-4-20250514",
"prompt_hash": "sha256:abc123...",
"tools": ["search_v2", "code_exec_v1", "web_browse_v3"],
"config": {
"temperature": 0.3,
"max_tokens": 4096,
"timeout_ms": 30000
}
}
Rules
- Changing ANY component = new version.
- Never mutate a deployed version in place.
- Keep previous N versions warm for instant rollback.
- Version string includes all components for traceability.
Hosting Patterns
Containerized (Recommended)
- Docker container with model client, prompt, tool implementations.
- Auto-scale on queue depth (not CPU — agents are I/O bound).
- GPU allocation only if running local inference.
- Isolate per-tenant for data separation.
Scaling Signals
| Signal |
Scale Direction |
Reason |
| Queue depth increasing |
Scale up |
Work is backing up |
| P95 latency rising |
Scale up |
Capacity insufficient |
| Queue empty for 5min |
Scale down |
Over-provisioned |
| Error rate > 5% |
Pause scaling |
Fix errors first |
A/B Testing
Setup
- Define hypothesis (e.g., "new prompt reduces hallucination by 20%").
- Split traffic (e.g., 90/10 control/experiment).
- Run for statistical significance (typically 1000+ samples per variant).
- Measure: quality score, latency, cost, user feedback.
Metrics to Compare
- Task success rate (did the agent complete the task correctly?).
- Token usage (cost proxy).
- Latency p50/p95/p99.
- Tool failure rate.
- User satisfaction signal (thumbs up/down, follow-up corrections).
- Hallucination rate (if measurable via ground truth).
Graduation Criteria
- Improvement statistically significant (p < 0.05).
- No regression in any critical metric.
- Cost increase acceptable (<20% for same quality).
Shadow Testing
Pattern
User Request → Production Agent (responds to user)
→ Shadow Agent (runs silently, output logged)
Purpose
- Test new version against real traffic without user impact.
- Compare outputs offline (human eval or automated scoring).
- Detect regressions before any user sees them.
Rules
- Shadow agent output never reaches the user.
- Shadow uses same input but may have different model/prompt/tools.
- Compare at scale (1000+ requests) before promoting.
- Track divergence rate and categorize differences.
Monitoring
Key Metrics (Real-Time Dashboard)
| Metric |
Alert Threshold |
Action |
| Token usage/task |
>2x baseline |
Check for loops/verbose output |
| Latency p95 |
>30s |
Scale up or investigate bottleneck |
| Tool failure rate |
>5% |
Check tool availability |
| Hallucination rate |
>3% |
Rollback, investigate prompt |
| User negative feedback |
>10% |
Investigate, consider rollback |
| Cost per task |
>$0.50 |
Check for inefficiency |
Structured Logging
Every agent invocation must log:
- Request ID, user ID, agent version.
- Input (sanitized of PII).
- Output summary.
- Tools invoked and their results.
- Token counts (input, output, total).
- Latency breakdown (thinking, tool calls, generation).
- Success/failure determination.
Rollback
Instant Rollback
- Version pointer in config store (not redeployment).
- Switch pointer → immediate traffic to previous version.
- Keep N previous versions warm (containers running, ready).
- Rollback decision within 5 minutes of detecting regression.
Rollback Triggers (Automatic)
- Error rate > 10% for 3 consecutive minutes.
- P95 latency > 60s for 5 minutes.
- User negative feedback spike (3x normal rate).
Health Checks
Synthetic Probes
- Run a known-good task against the agent every 5 minutes.
- Verify output matches expected structure.
- Check latency within bounds.
- Alert if probe fails 2 consecutive times.
Probe Design
- Task must be deterministic (or have verifiable structure).
- Must exercise core capabilities (reasoning + at least one tool).
- Must complete within health check timeout (10s recommended).
- Results logged for trend analysis.
Self-check
1---2name: ai-agent-deployment3description: Skill — AI Agent Deployment4---56# Skill — AI Agent Deployment78## When this skill activates9Any task involving deploying AI agents to production, versioning agent configurations,10A/B testing agent variants, monitoring agent quality in production,11or managing the operational lifecycle of AI agents.1213## Mandatory actions when this skill is active1415### Before writing any code161. Define the agent version tuple: model + prompt + tools + config (all pinned together).172. Identify success metrics (quality, latency, cost, user satisfaction).183. Plan rollback strategy (instant version pointer switch).194. Design monitoring (token usage, error rate, quality signal).2021### During implementation22- Package agent as a versioned, immutable deployment artifact.23- Implement health check endpoint (synthetic task probe).24- Add structured logging for every agent action (input, output, tools used, tokens).25- Build traffic splitting capability for A/B and canary.26- Instrument cost tracking per-task and per-user.27- Implement graceful degradation (fallback to simpler model on failure).2829### After implementation30- Verify shadow test shows no regression vs current version.31- Confirm monitoring dashboards capture all key metrics.32- Test rollback procedure end-to-end.33- Validate cost projections against actual usage.34- Run synthetic probes for health verification.3536## Versioning Strategy3738### Agent Version = Immutable Tuple39```json40{41 "version": "agent-v2.3.1",42 "model": "claude-sonnet-4-20250514",43 "prompt_hash": "sha256:abc123...",44 "tools": ["search_v2", "code_exec_v1", "web_browse_v3"],45 "config": {46 "temperature": 0.3,47 "max_tokens": 4096,48 "timeout_ms": 3000049 }50}51```5253### Rules54- Changing ANY component = new version.55- Never mutate a deployed version in place.56- Keep previous N versions warm for instant rollback.57- Version string includes all components for traceability.5859## Hosting Patterns6061### Containerized (Recommended)62- Docker container with model client, prompt, tool implementations.63- Auto-scale on queue depth (not CPU — agents are I/O bound).64- GPU allocation only if running local inference.65- Isolate per-tenant for data separation.6667### Scaling Signals68| Signal | Scale Direction | Reason |69|--------|----------------|--------|70| Queue depth increasing | Scale up | Work is backing up |71| P95 latency rising | Scale up | Capacity insufficient |72| Queue empty for 5min | Scale down | Over-provisioned |73| Error rate > 5% | Pause scaling | Fix errors first |7475## A/B Testing7677### Setup781. Define hypothesis (e.g., "new prompt reduces hallucination by 20%").792. Split traffic (e.g., 90/10 control/experiment).803. Run for statistical significance (typically 1000+ samples per variant).814. Measure: quality score, latency, cost, user feedback.8283### Metrics to Compare84- Task success rate (did the agent complete the task correctly?).85- Token usage (cost proxy).86- Latency p50/p95/p99.87- Tool failure rate.88- User satisfaction signal (thumbs up/down, follow-up corrections).89- Hallucination rate (if measurable via ground truth).9091### Graduation Criteria92- Improvement statistically significant (p < 0.05).93- No regression in any critical metric.94- Cost increase acceptable (<20% for same quality).9596## Shadow Testing9798### Pattern99```100User Request → Production Agent (responds to user)101 → Shadow Agent (runs silently, output logged)102```103104### Purpose105- Test new version against real traffic without user impact.106- Compare outputs offline (human eval or automated scoring).107- Detect regressions before any user sees them.108109### Rules110- Shadow agent output never reaches the user.111- Shadow uses same input but may have different model/prompt/tools.112- Compare at scale (1000+ requests) before promoting.113- Track divergence rate and categorize differences.114115## Monitoring116117### Key Metrics (Real-Time Dashboard)118| Metric | Alert Threshold | Action |119|--------|----------------|--------|120| Token usage/task | >2x baseline | Check for loops/verbose output |121| Latency p95 | >30s | Scale up or investigate bottleneck |122| Tool failure rate | >5% | Check tool availability |123| Hallucination rate | >3% | Rollback, investigate prompt |124| User negative feedback | >10% | Investigate, consider rollback |125| Cost per task | >$0.50 | Check for inefficiency |126127### Structured Logging128Every agent invocation must log:129- Request ID, user ID, agent version.130- Input (sanitized of PII).131- Output summary.132- Tools invoked and their results.133- Token counts (input, output, total).134- Latency breakdown (thinking, tool calls, generation).135- Success/failure determination.136137## Rollback138139### Instant Rollback140- Version pointer in config store (not redeployment).141- Switch pointer → immediate traffic to previous version.142- Keep N previous versions warm (containers running, ready).143- Rollback decision within 5 minutes of detecting regression.144145### Rollback Triggers (Automatic)146- Error rate > 10% for 3 consecutive minutes.147- P95 latency > 60s for 5 minutes.148- User negative feedback spike (3x normal rate).149150## Health Checks151152### Synthetic Probes153- Run a known-good task against the agent every 5 minutes.154- Verify output matches expected structure.155- Check latency within bounds.156- Alert if probe fails 2 consecutive times.157158### Probe Design159- Task must be deterministic (or have verifiable structure).160- Must exercise core capabilities (reasoning + at least one tool).161- Must complete within health check timeout (10s recommended).162- Results logged for trend analysis.163164## Self-check165- [ ] Agent version tuple defined (model + prompt + tools + config).166- [ ] Health check probes running every 5 minutes.167- [ ] Monitoring covers: tokens, latency, errors, quality, cost.168- [ ] Rollback tested and confirmed instant.169- [ ] Shadow test shows no regression.170- [ ] A/B framework ready for future experiments.171- [ ] Cost per task tracked and within budget.172- [ ] Graceful degradation implemented for failures.