Monitoring and Reliability › Health Checks: Is the Agent Alive?
AI Agent HandbookAll chapters 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:
## 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
passThis 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:
curl http://your-agent-url.com/healthIf 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.