Monitoring and Reliability › Health Checks: Is the Agent Alive?

Michael BrenndoerferAugust 20, 20252 min read
AI Agent HandbookAll chapters
Part 14 of 15Deployment and Operations - From Prototype to Production
Chapter 40Monitoring and Reliability › Health Checks: Is the Agent Alive?
Reading section 3 of 14 · Health Checks: Is the Agent Alive? · 2 minSection 3 of 14 · 2 min

Book contents

Section 3 of 14 · 2 min read

Monitoring and Reliability › Health Checks: Is the Agent Alive?One section · Sections in this chapter3 / 14 ↓

The most basic form of monitoring is a health check. This is a simple endpoint that tells you whether your agent is running and able to respond. Think of it like checking someone's pulse. You're not diagnosing complex issues, just verifying the system is alive.

Let's add a health check to our agent's API:

In[2]:
Code
## Example (Claude Sonnet 4.5)
## Using Claude Sonnet 4.5 for its superior agent capabilities
from flask import Flask, jsonify
import time

app = Flask(__name__)
start_time = time.time()

@app.route('/health', methods=['GET'])
def health_check():
    """Simple health check endpoint"""
    uptime = time.time() - start_time
    return jsonify({
        "status": "healthy",
        "uptime_seconds": uptime,
        "timestamp": time.time()
    })

@app.route('/chat', methods=['POST'])
def chat():
    # Your agent logic here
    pass

This health check returns a simple response confirming the agent is running and how long it's been up. You can call this endpoint periodically to verify the agent is responsive:

In[4]:
Code
curl http://your-agent-url.com/health

If you get a response, the agent is alive. If the request times out or fails, something is wrong.

Most deployment platforms can use health checks automatically. You configure them to ping your health endpoint every minute or so. If the health check fails multiple times in a row, the platform can alert you or automatically restart your agent.