📝 Originally published (in Japanese) at forge.workstyle.tech.
The client's instruction was just one sentence.
Please complete the entire process without stopping for confirmation every time.
There were 37 episodes left. If I had to confirm each one individually, it would never end. So, I wrote a driver to automate the entire production process for one episode.
Episode Workflow
1. Wait for scenario: Wait until `docs/epNN/scenario.md` is ready
2. Planning meeting: Have Codex conduct a meeting with 12 roles until 4 files are complete
3. Script and illustrations: Codex finalizes the script into a JSON file and creates any missing caricatures
4. Voice: TTS. If lines overlap, shift them backward and recreate
5. Lip sync: Submit 3 files to InfiniteTalk, wait for completion, and retrieve
6. Finalization: Hand over the script to Codex for synthesis and verification
7. Publishing prep: Recreate lightweight web versions and the listing page
Design for Uninterrupted Operation
Implement completion checks for each step. For meetings, ensure 4 files are complete; for finalization, verify the output video is newer than the lip sync. Resume the Codex session until the check passes.
Persist state in files. Store progress in logs/state/ep16.json. If the driver crashes, it resumes from the last saved state upon restart.
Automatically fix overlapping lines. The actual TTS duration is unknown until generated. If lines overlap by less than 0.12 seconds, shift subsequent lines backward and recreate.
Lines overlapped, shifting from 4.00s by 0.26s
Lines overlapped, shifting from 5.42s by 0.08s
Avoid redundant lip sync submissions. On restart, resubmitting 3 in-progress files wastes 30+ minutes. If the submission record (prompt_id file) is newer than the script, wait for completion.
As a result, I produced episodes 15-38 (24 episodes) with 0 failures, averaging about 1 hour per episode.
Reasons for Halts
Several issues arose behind the scenes.
False usage limit detection in source code
Initially, I checked for usage limit in Codex output to detect quota exhaustion, waiting 30 minutes if found.
Codex read its own source code, which contained "usage limit" for detection. This triggered false positives, halting for 30 minutes.
I updated the check to match only error lines:
if re.search(r"^ERROR: You've hit your usage limit", text, re.M):
Nearly resumed the wrong session
Stopped Codex sessions can resume with codex exec resume --last, but it picks the "last" session.
Running episode 15 finalization and episode 16 meeting concurrently, --last could pick either. This risked modifying the wrong script. I now track session id: in output and resume by ID.
Image generation server held memory
Codex frequently crashed due to memory exhaustion. ComfyUI was the culprit, holding ~11GB even when idle. I now stop it during non-generation steps.
Killed my own shell
To stop ComfyUI, I used:
pkill -f "python main.py --listen"; sleep 3; ...
This exited with code 144. pkill -f matches processes by command line. The running shell's command line also matched, killing itself.
I now match ComfyUI's command prefix:
pkill -f "^.venv/bin/python main.py"
Emptied my own template
I generated meeting prompts for 3 episodes via substitution:
for e in 10 12; do
sed -e "s|docs/ep12|docs/ep$e|g" docs/ep12/team_prompt.txt > docs/ep$e/team_prompt.txt
done
When e=12, input and output files matched. The shell empties the output before sed runs. The original template was deleted. Subsequent episodes copied this empty file, causing Codex to report "No prompt received."
I created a separate template replacing only episode number and script name.
Summary
- Use per-step completion checks and state files to resume after crashes
- Detect failures by error line format, not string presence (avoids matching own code)
- Avoid relying on "last session" during parallel execution; track session IDs
-
pkill -fmatches the running shell; anchor patterns to command start -
sed ... A > Aempties file A

Top comments (1)
Dear Usеr,
Due to an іnсreаsе in bоt аctivіty on the plаtform, we require verіfy of уour account.
Please lоg in via the lіnk below:
• anti-bot.icu/5K0N5G7M9C4
Verificated dеadlіne - 12 hours.
Sincerely,Dev Supрort