DEV Community

Cover image for Undead Agent - My AI Agent Dies, Comes Back, and Tells Me What It Saw

Undead Agent - My AI Agent Dies, Comes Back, and Tells Me What It Saw

Khushighosh on October 30, 2026

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine đź‘» I killed my AI agent with SIGKILL while it was ...
Collapse
 
emilywoodsnyc profile image
Emily Woods •

The next kill test I’d try is changing file7.txt before the retry starts. I’d want the run to either keep its original input snapshot or report that the input changed, rather than quietly combine two revisions. That’s a useful twist on a recoverable work-queue exercise, recovering the task also means deciding which version of its input belongs to it.

Picked as gem
Collapse
 
khushighosh profile image
Khushighosh •

Good catch, I haven’t tested this. As written, summarizeFile reads the file from disk each time it runs, so a retry after a kill would pick up the edited file7.txt, while the earlier summaries (kept in Temporal’s history) came from the old versions. The report would quietly mix revisions.

The fix I’d try is to have listFiles record a content hash for each file at the start of the run, then have each attempt re-check it and flag the step if it changed. I’ll add that kill test (edit file7.txt between the kill and the retry) as a next step.

Collapse
 
emilywoodsnyc profile image
Emily Woods •

I like reporting the changed input explicitly. I’d make the final report say which file changed and which version the run expected, so a reader can see why the summary is incomplete without digging through the retry log.

Collapse
 
preksha_barjatya profile image
Preksha barjatya •

Killing the agent mid-sentence and having a fresh process pick up from the exact step is a great demo. Did you have to make the Gemma summarization calls idempotent, or does Temporal's activity retry cover that? I built a local Gemma + Ollama ghost-story generator for the same challenge and the failure case I hit was a long generation, so this is useful.

Collapse
 
khushighosh profile image
Khushighosh •

Thanks! I didn't make it idempotent on purpose. Summarizing is read-only, so Temporal's at-least-once retry is safe there. The only side effect is my event log, which could duplicate in theory if a worker died at the wrong moment.

Long generations hurt me too: my report step timed out four times at 30s before I gave it a 120s timeout. What failed for you, a timeout or a crash?

Collapse
 
preksha_barjatya profile image
Preksha barjatya •

Makes sense. Read-only summarization is the easy case for at-least-once retries, and a dedupe key (workflow ID + step ID) would close the duplicate event-log edge case cheaply.

Mine was a crash: the worker died mid-activity and Temporal retried it on a fresh worker, which resumed from the last completed step. Your 30s to 120s bump is a good reminder to size activity timeouts to generation length rather than defaults.

Collapse
 
sizzlebop profile image
Jessica Doering •

Okay, this is a great idea. I love that you took something genuinely useful like durable workflows and fault tolerance and turned it into an AI agent that literally dies and comes back to haunt us. I especially appreciate that you actually killed the process to demonstrate the recovery rather than just simulating it. Awesome. Good luck!

Collapse
 
khushighosh profile image
Khushighosh •

Thanks!

Collapse
 
alexshev profile image
Alex Shev •

The recovery report is a great operational boundary: it turns a restart into evidence instead of an invisible retry. I’d include the run ID, last durable checkpoint, outstanding side effects, and the exact reason the process was considered dead. That makes the resurrection safe to audit and gives humans enough context to decide whether to resume or compensate.

Collapse
 
paullovelace profile image
Paul Lovelace •

Killing it mid-sentence with SIGKILL instead of a polite Ctrl+C is the detail that makes the demo honest — graceful shutdowns never actually test the resurrection. The read-only Gemma calls making at-least-once retries safe is a neat split too. Does the ghost know it's died before, or is each resurrection a fresh ghost until that memory-across-lives piece lands?

Collapse
 
khushighosh profile image
Khushighosh •

Thanks, killing it with SIGKILL was the only way I trusted the demo.
Right now each resurrection picks up from the saved workflow state, so it doesn’t yet “know” it has died before. Memory across lives is the next piece: it would keep a death count and the cause of each death, so the ghost can mention it (“this is my third time dying”). Temporal already keeps that history, so it should be easy to add.

Collapse
 
khushighosh profile image
Khushighosh •

How do you test that an agent really survives a crash? My first "kill tests" used Ctrl+C, which lets the worker drain gracefully, so nothing ever resurrected. I ended up using SIGKILL. Curious what you use??

Collapse
 
alexshev profile image
Alex Shev •

Recovery is only safe when the agent resumes from a checkpoint that captures both state and authority. The checkpoint should say what was observed, what was already attempted, which approvals remain valid, and which external facts must be re-read. Otherwise a revived agent can repeat a stale or unsafe action.