GUIDE · CREWAI · AGENT-FIRST

Monitor CrewAI — dead-man's-switch for scheduled multi-agent crew runs

Wrap crew.kickoff() with three lines of Python — or add the LastPing MCP server to your crew and let an agent instrument the watchdog itself. Catches missed scheduled runs, hung tool calls within the crew, and unhandled exceptions. Free, no monitor cap.

CrewAI crews fail silently across three dimensions.

A multi-agent crew is harder to observe than a single agent — failures can happen in any agent's tool, at task delegation boundaries, or at the level of the overall run that never happens at all.

Failure mode 01

Crew never runs

The cron job or scheduler that calls crew.kickoff() fails silently — OOM kill, expired API key, network partition at startup. No task runs, no output file is created, no error is logged to any observable location.

Failure mode 02

Agent stuck on a tool

One agent within the crew blocks on a slow or hung tool — a web search, a code interpreter, an external API. The crew's task loop waits. crew.kickoff() never returns. No exception is raised from the outer scope.

Failure mode 03

Exception swallowed upstream

A rate limit, a context overflow, or a tool error that CrewAI's retry logic doesn't recover from raises an exception. If the scheduler swallows it or if the process exits non-zero with no alerting, the failure is invisible.


Setup: three lines around crew.kickoff()

No CrewAI plugin, callback, or flow change needed. The watchdog wraps the entire run from outside — exactly where the boundary failures occur.

Let the crew instrument itself via MCP

Add the LastPing MCP server at mcp.lastping.dev as an MCP server or as a tool in your CrewAI setup. Ask an agent: "Register a LastPing monitor for this crew — weekly Monday 5 AM UTC, 60-minute grace, alert me on Slack if missed. Get the ping code and add it to the kickoff wrapper." Learn about the LastPing MCP server →

Create a heartbeat monitor in LastPing

In the console, create a monitor, choose Heartbeat, set the period to your crew's run schedule. Add a generous grace window for long-running crew tasks (e.g. 60 minutes for a research crew). Copy the ping URL.

https://ping.lastping.dev/<uuid>

Wrap crew.kickoff() with start, success, and fail pings

This pattern works for synchronous crew.kickoff() and for the async crew.kickoff_async() — use httpx.AsyncClient in the async case.

import requests from crewai import Crew, Agent, Task PING_URL = "https://ping.lastping.dev/<uuid>" def run_crew(): requests.get(f"{PING_URL}/start", timeout=10) # arm watchdog try: result = my_crew.kickoff() requests.get(PING_URL, timeout=10) # signal success return result except Exception as exc: requests.post( f"{PING_URL}/fail", data=f"Crew failed: {type(exc).__name__}: {exc}", headers={"Content-Type": "text/plain"}, timeout=10, ) raise

For async crews: use httpx.AsyncClient

import httpx async def run_crew_async(): async with httpx.AsyncClient() as client: await client.get(f"{PING_URL}/start", timeout=10) try: result = await my_crew.kickoff_async() await client.get(PING_URL, timeout=10) return result except Exception as exc: await client.post( f"{PING_URL}/fail", content=f"Crew failed: {type(exc).__name__}: {exc}", headers={"Content-Type": "text/plain"}, ) raise

Done — every crew run now reports in

LastPing receives the start and completion pings. A crew that never starts — scheduler failure, OOM kill, expired key — is caught when the expected ping doesn't arrive in the grace window. Alerts go to email, Telegram, Slack, Discord, or a signed webhook.


What this catches

The same durable detection engine as LastPing's cron monitoring — deadlines live in the database, restarts never miss a due check.

  • Crews that never run — scheduler failure, OOM kill, expired API key. No start ping in the expected window → incident.
  • Hung crews — an agent's tool call never returns; crew.kickoff() blocks; overrun detection opens an incident after the grace window.
  • Crew exceptions — the except block fires immediately, POSTing the exception type and message (up to 64 KB) to the incident.
  • Recovery — the next successful kickoff closes the incident automatically.
  • Agent self-registration — a crew agent can create its own LastPing monitor via MCP and wire the pings into the kickoff wrapper.

The same pattern applies to OpenAI Agents SDK and LangChain agents. For CI/CD pipelines, see GitHub Actions or the monitoring guides index. The LastPing MCP server at mcp.lastping.dev lets agents self-register their own monitors in a single conversation.


Questions people ask

Front-loaded answers — the most important fact first.

  • How do I monitor a CrewAI crew running on a schedule?

    Wrap crew.kickoff() with a start ping before, a success ping after, and a fail POST in the exception handler. Create a heartbeat monitor in LastPing with your schedule and a grace window that accounts for how long the crew typically runs. Free, no monitor cap.

  • Why does a multi-agent crew need a longer grace window?

    A single agent might complete a task in seconds; a research crew with multiple agents doing web searches, writing drafts, and reviewing output might legitimately run for 20-40 minutes. Set the grace window in LastPing to your crew's 95th-percentile runtime so occasional slow runs don't trigger false alerts.

  • Can a crew agent set up its own LastPing monitor?

    Yes. Add the LastPing MCP server at mcp.lastping.dev as an available server in your CrewAI configuration or as a tool wrapped in a CrewAI Tool class. An agent in the crew can then call create_monitor and get_ping_instructions to create a watchdog and receive the curl commands to embed in the kickoff wrapper.

  • Does this work with CrewAI Flows?

    Yes. For CrewAI Flows using the @start() decorator, wrap the flow's entry method the same way: start ping at the top, success ping at the end, fail POST in an exception handler. The same heartbeat monitor catches missed flow executions and flow-level exceptions.

  • Is this free?

    Yes. LastPing is free for individuals with no monitor cap. The MCP server is included. See also OpenAI Agents SDK monitoring and LangChain monitoring.

AGENT-FIRST · FREE FOR INDIVIDUALS · MCP-NATIVE

Your crew's next tool hang is already in progress.

Three lines of Python now beats a post-mortem later. First monitor up in under two minutes — and LastPing monitors itself the same way.