Get an alert when an AI job returns an empty or too-short answer
The model call returned, the script exited with 0, and this morning's summary is empty. Or it is one line instead of the usual page. Nothing failed, so nothing alerted. The fix is the same as for a load that brings 0 rows: send a number with every run and compare it with the usual.
Why an empty answer looks like success
- When a quota or credit runs out, some tools and wrappers return an empty answer with exit code 0 instead of an error; one developer's agent did exactly that (DEV Community, 2026).
- The script catches the API error, writes an empty file and carries on, because a crash at night felt worse than an empty report.
- The prompt's input was empty (no new tickets, an empty export), so the model had nothing to summarise and said so in one line.
- The answer was cut off or filtered, and the script saved whatever came back.
Retrying doesn't help with a used-up quota: both the OpenAI and Claude API docs say those errors keep failing until the limit or the credit changes.
Send the length of the answer
Send the number of characters in the answer with the finishing ping, as your own number. The Python code below sends it as chars (replace answer with your variable):
# --- TaskBeacon: top of the script (standard library only) ---
import json, traceback, urllib.request
TB = "https://taskbeacon.io/ping/your-job-id"
def tb_ping(path="", data=None):
body = json.dumps(data).encode() if data else None
req = urllib.request.Request(TB + path, data=body, headers={"Content-Type": "application/json"})
try:
urllib.request.urlopen(req, timeout=10)
except Exception as e:
print("TaskBeacon ping failed:", e)
tb_ping("/start")
try:
# --- your code here ---
from datetime import date
df = [{}] # example data: replace with your own (e.g. pandas.read_csv)
except Exception as e:
# the error and the last 20 lines of the traceback go with the failure
tb_ping("/fail", {"error": f"{type(e).__name__}: {e}"[:200],
"log": "\n".join(traceback.format_exc().splitlines()[-20:])[-4000:]})
raise
# --- TaskBeacon: end of the script ---
tb_ping("", {"chars": float(len(answer))})In the app, the Code tab of your job gives you this code with the job's own address instead of your-job-id, and you can untick the parts you don't need.
Then add two rules on the job page:
- chars is below X with X = 1: an empty answer is Odd data right away.
- chars drops more than X% below the recent average, for example 60%: a one-line answer instead of the usual page.
You can send another number instead, or as well: the items the job processed, the rows it classified, the size of the file it wrote. Rules on your own numbers are part of Pro, open to everyone for now; see your own number.
On your job's Code tab, Copy prompt for your AI gives you a ready message for ChatGPT, Claude or Copilot that adds these lines to your script; check the result before you run it.
Without TaskBeacon
Check the answer in the job: if it is empty or shorter than a fixed minimum, exit with a non-zero code so the scheduler reports a failure. A fixed minimum is easy; "much shorter than usual" needs earlier lengths stored somewhere and an average, and you still need something that tells you. Related: monitor a scheduled AI agent for the runs that fail or never start.
Connected Claude or ChatGPT to TaskBeacon? Ask it "what failed last night, and why?" and it answers from your jobs. How that works.
Related
In the Docs: Your own number · Statuses · Python.
- Monitor a scheduled AI agent or LLM jobAn AI job can "succeed" and do nothing.
- Get an alert when a job loads 0 rows, or far fewer than usualExit code 0 says nothing about how many rows arrived.
- Check that a daily table or file is freshA load that "works" but brings yesterday's data again.
TaskBeacon is free to start, with every feature open for now and no credit card. Create a job, paste the code, and the first ping shows up on the job page.
Start free View live demoSources
- DEV Community: The model worked, the cron job almost killed my AI agent (empty answer with exit code 0) (2026-05-21)
- OpenAI API docs: Error codes (quota and credit errors are not fixed by retrying) (undated; checked 2026-11-12)
- Claude API docs: HTTP errors (a spend-cap 429 keeps failing until access resumes) (undated; checked 2026-11-12)
Page checked against its sources on 2026-11-09. Menus and limits of other products change; if something here no longer matches, write to support@taskbeacon.io.