>_
Nexus Academy
Building Reliable Agents
Testing, monitoring, error recovery, and safe deployment patterns for production agent systems.
Prerequisites
- Course: Agent Engineering Fundamentals (or equivalent experience)
- Experience with production software operations
- Familiarity with monitoring and observability concepts
Learning outcomes
- Design and implement agent evaluation pipelines
- Build monitoring dashboards for agent systems
- Implement error recovery and graceful degradation
- Set up CI/CD workflows for agent deployments
- Measure and improve agent reliability over time
Course modules
Module 1
Reliability Fundamentals
Why agent reliability is different from software reliability. The six failure mode categories. Setting reliability objectives and SLIs.
Duration: 45 min
Module 2
Testing Agents
Unit evaluations for common failure modes. Building a regression test suite from production traces. Automated evaluation pipelines.
Duration: 60 min
Module 3
Monitoring and Observability
Agent metrics, structured logging, causal tracing. Building dashboards and alerting. Integrating with Datadog, Grafana, and Sentry.
Duration: 60 min
Module 4
Error Recovery Patterns
Automatic retry strategies, checkpoint-restart for long tasks, graceful degradation, and human escalation workflows.
Duration: 45 min
Module 1: Reliability Fundamentals (Detailed)
Agent reliability differs fundamentally from software reliability. A function either returns the correct answer or throws an error ? the behavior is deterministic and failure modes are enumerable. An agent may complete a task using the wrong approach, producing a solution that works today but is unmaintainable tomorrow. It may succeed on the happy path but fail on edge cases. It may exhaust its context window mid-task, forget critical information, or use a tool incorrectly while producing plausible-looking output.
The six failure mode categories. Based on analysis of 50,000+ production sessions across 800+ organizations, failures fall into six categories. Task failures (38%): agent produces incorrect or incomplete output. Tool failures (24%): agent uses tools incorrectly ? wrong tool, bad parameters, misread output. Reasoning failures (18%): logical errors in the agent'''s reasoning chain ? incorrect inference, premature conclusion, contradictory reasoning. Memory failures (10%): agent fails to retain or retrieve relevant context. Safety failures (7%): agent takes actions outside its intended scope. Observability failures (3%): agent operates incorrectly but monitoring cannot detect the failure ? the most dangerous category.
Setting reliability objectives. Define SLIs (service-level indicators) for each failure category. Example: task failure rate < 10%, tool call accuracy > 85%, memory retrieval precision > 80%, safety incident rate < 1%. Set SLOs (service-level objectives) based on these SLIs with error budgets that account for non-determinism. Monitor these metrics in your dashboard and set up alerts for SLO violations.
Module 2: Testing Agents (Detailed)
Testing agents requires a different approach than testing traditional software. Unit evaluations test individual agent capabilities (tool selection accuracy, plan validity, output correctness) in isolation. Integration evaluations test end-to-end task completion. Regression evaluations ensure that improvements for one task type do not degrade others.
Building an evaluation suite. Start with 50-100 representative tasks from your domain. For each task, define: task description (natural language), ground truth (expected output or success criteria), evaluation metrics (how to measure success: exact match, semantic similarity, or human review), and failure categories (which categories this task tests). Use the Nexus evaluation framework to run these tasks:
nexus eval run --suite my-suite --agent my-agent nexus eval report --suite my-suite --format html
Regression test suite from production traces. Automatically extract failing cases from production logs and add them to your regression suite. The Nexus platform captures every failure with full context. Run nexus eval capture --agent my-agent --last-failures 100 to build a regression suite from the last 100 production failures.
Module 3: Monitoring and Observability (Detailed)
Monitoring agents requires metrics that capture not just system health but semantic correctness. Four categories of agent metrics: Task metrics: completion rate, accuracy score, time to completion, plan validity rate. Tool metrics: tool call accuracy, parameter error rate, tool selection precision, fallback frequency. Memory metrics: retrieval hit rate, retrieval latency, consolidation rate, confidence distribution. Operational metrics: latency percentiles, token usage, cost per task, error rate by failure category.
Setting up structured logging. The Nexus agent emits structured JSON logs for every action. Configure log shipping to your observability platform:
logging:
format: json
output: stdout
ship:
- provider: datadog
api_key: ${DD_API_KEY}
- provider: s3
bucket: nexus-agent-logs
prefix: prod/Alerting thresholds. Set up alerts for: task completion rate drops below SLO (e.g., < 85%), tool call accuracy drops below threshold (< 80%), spike in any failure category (> 2x baseline), memory retrieval precision drops (< 70%), latency p99 exceeds 30 seconds.
Exercises
Exercise 1: Create an evaluation suite with 10 tasks covering at least 4 failure categories. Run the suite against an agent and review the report. Exercise 2: Set up a Grafana dashboard with agent metrics. Configure alerts for task completion rate and tool call accuracy. Exercise 3: Introduce a deliberate configuration error (e.g., remove a tool from nexus.yaml). Run the evaluation suite and observe how the failure pattern changes. Does the reliability score capture the degradation?
Module 4: Error Recovery Patterns (Detailed)
Error recovery is how agents handle failures gracefully and continue working. Three fundamental recovery patterns: Retry with backoff ? for transient failures (network timeouts, temporary service unavailability), the agent retries with exponential backoff: 1s, 2s, 4s, 8s, max 5 retries. Each retry should be logged with the error and retry count. Checkpoint-restart ? for long-running tasks, the agent checkpoints progress every N steps. On failure, it restarts from the last checkpoint rather than from scratch. Configure checkpoint frequency in nexus.yaml: checkpoint: every: 5 steps. Graceful degradation ? when a critical tool is unavailable, the agent switches to a degraded mode. Example: if the compiler tool is down, the agent focuses on code analysis and produces compilation commands for the user to run manually.
Human escalation workflow. When automated recovery fails, the agent should escalate to a human. The escalation includes: task context (original task and agent'''s understanding), failure details (which step failed and why), attempted recoveries (what the agent tried and what happened), and suggested next steps (the agent'''s recommendation for resolution). Configure escalation in nexus.yaml:
escalation: max_retries: 3 channel: slack notify: "#agent-alerts" include_trace: true
Reliability Score Calculation
The Nexus reliability framework computes a composite score from five dimensions. Correctness C: fraction of task outputs passing validation (weight 0.3). Completeness K: fraction of task requirements covered (weight 0.2). Consistency S: output stability across repeated runs (weight 0.15). Robustness R: performance under perturbation (weight 0.2). Transparency V: fraction of reasoning steps with inspectable evidence (weight 0.15). The overall reliability score R = 0.3C + 0.2K + 0.15S + 0.2R + 0.15V ranges from 0 (unreliable) to 1 (perfect).
Calculate the score for your agent using the CLI:
nexus eval score --agent my-agent --suite regression-suite