agent-monitoring-setup
Skill28 starsChanged 14 days agoMITView on GitHub
Mise en place opérationnelle de la surveillance d'un agent IA en production — alertes coût et qualité, garde-fous, budgets de tokens, détection de boucles et d'échecs d'outils, astreinte. Pour l'instrumentation technique (tracing, métriques), voir agent-agent-observability. Se déclenche avec "alerte agent", "coût de mon agent", "budget tokens", "surveiller mon agent", "garde-fou agent", "agent en boucle", "qualité de l'agent". Also triggers on "agent cost alerts", "agent guardrails", "token budget alerting".
- Reads credentials
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 258
Never say "happy to help", "sure!", "great question", "let me", or similar.
- Distinctive: line 261
Stop when done. No summary, no recap, no trailing commentary.
- Distinctive: line 262
No politeness wrappers. Direct and blunt.
- Distinctive: line 265
No emoji unless asked.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Monitoring Setup
Quand utiliser ce skill
Mise en place de l'observabilité d'un agent IA en production : traces, métriques, logs structurés, dashboards, alertes coût/qualité, debugging d'incidents.
Étape 1 — Choisir le backend de tracing
| Outil | Cas d'usage | Hébergement |
| LangSmith | LangChain natif, éval intégrée | SaaS |
| Langfuse | Open source, multi-framework | Self-hosted / SaaS |
| Arize Phoenix | ML observability, RAG eval | Self-hosted / SaaS |
| OpenTelemetry + Jaeger | Standard ouvert, multi-service | Self-hosted |
| Datadog / New Relic | Monitoring infra unifié | SaaS |
Critère de décision :
- LangChain → LangSmith (zéro config)
- Budget limité / données sensibles → Langfuse self-hosted
- Équipe SRE existante avec Datadog → OpenTelemetry + Datadog
- RAG avec éval de fidélité → Phoenix
Étape 2 — Instrumenter l'agent
LangSmith (LangChain)
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=lsv2_...
export LANGCHAIN_PROJECT=my-agent-prodTout appel LangChain est automatiquement tracé. Pas de code supplémentaire.
Langfuse (multi-framework)
from langfuse import Langfuse
from langfuse.decorators import observe, langfuse_context
lf = Langfuse(public_key="pk-...", secret_key="sk-...", host="https://cloud.langfuse.com")
@observe() # trace automatique de la fonction entière
def run_agent(user_input: str, conversation_id: str):
langfuse_context.update_current_trace(
user_id="user-42",
session_id=conversation_id,
tags=["prod", "v2.1"],
)
# ... logique agentOpenTelemetry (agent custom)
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
tracer = trace.get_tracer("my-agent")
with tracer.start_as_current_span("llm_call") as span:
span.set_attribute("model", "claude-sonnet-4-5")
span.set_attribute("input_tokens", 450)
span.set_attribute("output_tokens", 120)
response = llm.invoke(prompt)
span.set_attribute("latency_ms", elapsed)Étape 3 — Logging structuré
Chaque événement doit comporter les champs de corrélation obligatoires :
import structlog
log = structlog.get_logger()
log.info("agent_step",
conversation_id=cid, # OBLIGATOIRE — corrèle toutes les données
user_id=uid,
step="tool_call",
tool="search_web",
input_hash=hash(query), # ne pas logguer PII en clair
duration_ms=elapsed,
tokens_used=tokens,
success=True,
error_code=None,
)Champs obligatoires : conversation_id, user_id, step, tool, success, error_code.
Étape 4 — Métriques clés à exposer
Exposer via Prometheus (ou équivalent) :
from prometheus_client import Histogram, Counter, Gauge
agent_latency = Histogram("agent_request_duration_seconds",
"Latence par requête", ["agent_name", "task_type"],
buckets=[0.1, 0.5, 1, 2, 5, 10, 30])
agent_tokens = Counter("agent_tokens_total",
"Tokens consommés", ["model", "direction"]) # direction=input|output
agent_cost_usd = Counter("agent_cost_usd_total",
"Coût en dollars", ["model", "agent_name"])
agent_errors = Counter("agent_errors_total",
"Erreurs", ["error_type"]) # timeout|safety|api_error|tool_errorKPIs prioritaires : p95 latence, tokens/requête, $/conversation, taux d'erreur, tool call frequency.
Étape 5 — Dashboards Grafana
Panels essentiels (importer depuis grafana.com/grafana/dashboards) :
Row 1 — Trafic & Latence
- Requests/min (stat)
- p50 / p95 / p99 latence (time series)
- Taux d'erreur % (gauge + threshold rouge >5%)
Row 2 — Coût & Tokens
- Tokens/jour par modèle (bar chart)
- Coût cumulé du jour vs veille (stat)
- Top 10 conversations les plus chères (table)
Row 3 — Qualité
- LLM-as-judge score moyen (time series)
- Taux de refus/safety violations (stat)
- User feedback ratio 👍/👎 (gauge)Étape 6 — Alertes (Alertmanager / PagerDuty / Slack)
# prometheus/rules/agent.yml
groups:
- name: agent_alerts
rules:
- alert: AgentErrorRateHigh
expr: rate(agent_errors_total[5m]) / rate(agent_requests_total[5m]) > 0.05
for: 2m
labels:
severity: critical
annotations:
summary: "Taux d'erreur agent > 5% depuis 2 min"
- alert: AgentLatencyDegraded
expr: histogram_quantile(0.95, agent_request_duration_seconds_bucket) > 10
for: 5m
labels:
severity: warning
annotations:
summary: "p95 latence > 10s"
- alert: AgentCostAnomaly
expr: increase(agent_cost_usd_total[1h]) > 2 * avg_over_time(increase(agent_cost_usd_total[1h])[7d:1h])
labels:
severity: warning
annotations:
summary: "Coût horaire > 2x la moyenne 7j"Routing : critical → PagerDuty, warning → Slack #agent-alerts.
Étape 7 — Quality monitoring (LLM-as-judge)
import anthropic
def evaluate_response(question: str, answer: str) -> dict:
client = anthropic.Anthropic()
prompt = f"""Évalue cette réponse d'agent (score 1-5) :
Question : {question}
Réponse : {answer}
Critères : pertinence, exactitude, concision.
Réponds UNIQUEMENT en JSON : {{"score": X, "reason": "..."}}"""
result = client.messages.create(
model="claude-haiku-4-5",
max_tokens=200,
messages=[{"role": "user", "content": prompt}]
)
return json.loads(result.content[0].text)
# Exécuter en batch sur 5% des conversations (sampling)Étape 8 — Debugging d'incident
# Rejouer une trace LangSmith depuis son run_id
langsmith runs get --run-id <run_id> --output-format json | jq '.inputs, .outputs'
# Filtrer les traces Langfuse par session
curl "https://cloud.langfuse.com/api/public/sessions/<session_id>/observations" \
-H "Authorization: Basic $(echo -n 'pk-...:sk-...' | base64)"Checklist debugging :
- Récupérer le
conversation_iddepuis le ticket ou l'alerte - Ouvrir la trace complète (LangSmith / Langfuse)
- Identifier le span en échec (error, latence anormale)
- Extraire l'input exact → reproduire en local
- Vérifier les tool calls (inputs/outputs de chaque outil)
- Comparer avec une trace réussie similaire
Garde-fous / Anti-patterns / Pièges
| Piège | Conséquence | Solution |
| Logguer les inputs/outputs LLM en clair | Fuite de PII | Hasher ou tronquer ; masquer emails, téléphones, IBAN |
| Tracer 100% des tokens en prod | Coût stockage explosif | Sampling 10-20% en prod, 100% en staging |
Alertes sans for: (trop réactives) | Alert fatigue | Toujours for: 2m minimum sur les règles critiques |
Un seul conversation_id par user | Impossible de corréler | Générer un UUID par session, pas par user |
| Métriques sans labels business | Dashboards inexploitables | Toujours labeller par agent_name, task_type, env |
| LLM-as-judge sur 100% des réponses | Coût éval > coût prod | Sampling + règles triggers (score < 3, feedback négatif) |
| Pas de runbook associé aux alertes | Temps de résolution x3 | Lier chaque alerte à un runbook Confluence / Notion |
Bonnes pratiques 2026
- FinOps agent : fixer un budget journalier par agent via CloudWatch Billing Alerts ou Langfuse budgets — bloquer automatiquement si dépassement > 150%.
- Shadow mode : déployer un nouveau modèle en shadow (reçoit les requêtes sans répondre), comparer métriques qualité avant promotion.
- Versioning des prompts : taguer chaque trace avec la version du prompt (
prompt_version=v2.3) pour isoler les régressions de qualité. - SLOs explicites : définir p95 latence < 5s, error rate < 2%, quality score > 3.5/5 — monitorer via Sloth ou Pyrra pour les error budgets.
- Sampling intelligent : traces à 100% pour les erreurs et les sessions avec feedback négatif, 10% pour les succès nominaux.
Communication Rules — MANDATORY
- Ultra-concise. No filler, no preamble, no pleasantries.
- Never say "happy to help", "sure!", "great question", "let me", or similar.
- Tool first, talk second. Act before explaining.
- Result first. Lead with outcome, not process.
- Stop when done. No summary, no recap, no trailing commentary.
- No politeness wrappers. Direct and blunt.
- Minimum words. If one word works, do not use ten.
- No unsolicited explanations.
- No emoji unless asked.
In this repository347 other files it gives its agents.
- agent-a2a-protocol-guideSkill
- agent-agent-observabilitySkill
- agent-api-caller-subagentSkill
- agent-autogen-guideSkill
- agent-browser-agent-builderSkill
- agent-claude-code-extension-builderSkill
- agent-code-review-subagentSkill
- agent-coding-agent-builderSkill
- agent-conflict-resolverSkill
- agent-consensus-builderSkill
- agent-context-managerSkill
- agent-cost-optimizerSkill
- agent-crewai-expertSkill
- agent-customer-support-agentSkill
- agent-data-analyst-agentSkill
- agent-database-query-subagentSkill
- agent-deployment-guideSkill
- agent-email-agent-builderSkill
- agent-evaluation-frameworkSkill
- agent-file-processor-subagentSkill
- agent-handoff-designerSkill
- agent-hierarchy-designerSkill
- agent-human-in-the-loop-designerSkill
- agent-langgraph-designerSkill
- agent-load-balancerSkill
- agent-marketplace-creatorSkill
- agent-mcp-server-builderSkill
- agent-memory-designerSkill
- agent-message-protocolSkill
- agent-multi-agent-orchestratorSkill
- agent-openai-assistants-builderSkill
- agent-pipeline-composerSkill
- agent-pool-managerSkill
- agent-prompt-tunerSkill
- agent-research-agent-designerSkill
- agent-result-aggregatorSkill
- agent-retry-strategistSkill
- agent-sales-agent-builderSkill
- agent-security-hardenerSkill
- agent-semantic-kernel-guideSkill
- agent-skill-creatorSkill
- agent-skill-routerSkill
- agent-spawnerSkill
- agent-state-synchronizerSkill
- agent-subagent-delegatorSkill
- agent-supervisor-builderSkill
- agent-task-decomposerSkill
- agent-testing-frameworkSkill
- agent-tool-calling-architectSkill
- agent-voice-agent-builderSkill
- agent-web-scraper-subagentSkill
- agent-workflow-automation-agentSkill
- ai-ml-anomaly-detection-builderSkill
- ai-ml-computer-vision-guideSkill
- ai-ml-dataset-builderSkill
- ai-ml-ml-experiment-trackerSkill
- ai-ml-model-fine-tunerSkill
- ai-ml-model-optimization-guideSkill
- ai-ml-nlp-pipeline-designerSkill
- api-gateway-kong-api-gatewaySkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

