Manraj Sidhu
Open on TikTok

Claude Code agent: 39 failures, all 39 finished

4 min readMotion reel, Agent NotesAI & automation668 views

My Claude Code agent reported 39 failures. All 39 had finished.

My Claude Code agent reported 39 failures. All 39 had finished.

Seeing a failed run? Check whether the work is already done. My video pipeline logged 39 errors from 8 to 11 October, and each run had written its final answer 3 to 6 seconds before the error.

1. Read the transcript before the error 2. Only count answers from this run 3. Find the file on disk 4. Make the file pass your checks 5. Cap the retries (mine: 3 for an empty reply), then get warned

A pass proves the file exists. It still needs a review. Save this for your next failed run.

I'm Manraj Sidhu, AI developer, and this is the real build. Built with @claudeai

Follow @manrajtalks

How to build it

This page gives you the five checks to run when your Claude Code agent reports a failed run, plus the prompt to build them.

The five checks

Run these in order before you rerun anything. Together they stop an agent from redoing work it has already finished.

  1. Read the transcript before the error: look at what the agent wrote just ahead of the failure. In the post's case, the final answer had landed 3 to 6 seconds before each error, across 39 errors logged from 8 to 11 October.

  2. Only count answers from this run: ignore any answer that is older than the current run, so an old result cannot pass as a new one.

  3. Find the file on disk: look for the output file itself. If the run says done but there is no file, treat it as failed.

  4. Make the file pass your checks: the render has to pass its own checks, such as no black ending, a keyword and a guide.

  5. Cap the retries, then get warned: an empty reply gets 3 retries, then you get a warning on your phone.

A pass proves the file exists. It still needs a review.

The prompt is in the last section. Paste it into ChatGPT (Codex) or Claude Code.

How to set it up

  1. Find where Claude Code saves its session transcript for each run, and make your script read the end of it when a run reports an error.

  2. Take the last assistant answer in that transcript and check that it was written during the current run, not an earlier one.

  3. Look for the output file on disk, such as the finished video, and mark the run as failed if the file is missing.

  4. Run your own checks on the file, such as no black ending frame, the keyword present and the guide present, using ffmpeg for the video checks.

  5. Count the retries for an empty reply and stop at 3.

  6. Send yourself a phone alert, for example through Telegram, when the cap is reached.

  7. Log each run saved by the transcript check, so you can see how often a reported failure was really finished.

  8. Keep a human review step, because a passing file is not proof the output is good.

Watch out: a pass only proves the file exists. It does not prove the video is good, so it still needs a review.

Prompt to build your own

You are helping me build a failed-run checker for my Claude Code agent. When a run reports an error, the checker must first test whether the work was actually finished before anything is rerun.
Build a script in <language> that runs these five checks in order:
1. Read the end of the session transcript from <transcript location> and look for a final answer written just before the error.
2. Accept an answer only if it belongs to the current run, and ignore anything older.
3. Look for the output file at <output path> and treat a missing file as a failure.
4. Run my validation checks on the file: <list of checks, for example no black ending, keyword present, guide present>. Use ffmpeg for any video checks.
5. If the reply is empty, retry up to <retry cap, for example 3> times, then send an alert to my phone through <alert channel, for example Telegram>.
Also log every run where check one found a finished answer, so I can count how many reported failures were really complete.
I use <tools I have, for example Claude Code, Python, ffmpeg, Telegram>. Keep it simple and readable, with each check as its own function. Return the full code, a short explanation of how the checks connect, and how to test it with a run that reported an error but had finished.
  • #ai
  • #aiagents
  • #claudecode
  • #aiautomation
  • #manrajtalks

Follow for the next one

The longer version, by email

Or subscribe on Substack