Agentic System · Engineering notes
Recovering work after a background job fails
A completed background run can still leave a gap in memory. The system records when a job finished, when it produced work and where each conversation should resume.
- Did it run?HeartbeatSee the last successful check and the last time it produced work.
- How far did it get?WatermarkResume from a saved message ID or line in this conversation.
- What is pending?Echo retry recordFinish indexing the transcript even if its memories are already saved.
Technology
- Python
- Windows Task Scheduler
- SQLite
- JSON
Read the two clocks
Each monitored job writes a small JSON heartbeat. At startup it marks itself running. A successful finish updates last_ok. Only a run that produces work also updates last_work_ts. An error records the failure and preserves both timestamps. A monitor checks every 30 minutes and flags jobs with no recorded success or whose last success is over two expected intervals old. Yesterday’s work timestamp can be perfectly healthy if no new sessions arrived.
Keep the unfinished step
Suppose the watcher saves a conversation’s facts but transcript indexing fails. Three records answer three different questions. The heartbeat tells me when the job last succeeded. The session watermark tells me how far curated extraction read. Echo’s separate indexing record tells me that the transcript still needs a retry. The next sweep can finish Echo even when the source file is unchanged and extraction has already advanced.
Who watches the monitor?
The nightly consolidation job checks the monitor’s last successful run. That gives me a second signal if the monitor stops reporting. Both jobs require the workstation and an interactive logon, so neither can report a machine outage from that machine.