November 27, 2026Tutorial · Ep. 07 · Storie di Agenti · Basi

Ep. 07 — True Story: the night an agent froze at 02:17

Ever left your phone charging and found it dead in the morning because the cable had slipped out by a millimeter? The charger was there, the outlet worked, but that tiny gap broke the whole flow.

On November 13, 2026, at 02:17 AM, our agent lived exactly this.

The missing heartbeat

In the days before we had built a while True loop: the program asked, the AI answered, the conversation grew. It worked fine as long as you stood there watching. But a real agent must be able to stand alone, even while you sleep.

We had put in a heartbeat (technical term): every so many seconds the program wrote a tiny signal to a file, as if to say "I'm alive, still running." A guardian watchdog — another dead-simple program — checked that file. If the signal didn't arrive for too long, the guardian thought: "it's frozen" and restarted everything.

That night the agent made a network request on its own. The network didn't answer. Didn't say "no," didn't say "error" — just didn't answer at all. And our program stayed there, phone to ear, waiting forever.

While waiting, it stopped writing the heartbeat. The guardian saw no signal. Thought: "freeze." Restarted the process. The agent woke up with no memory of what it was doing.

The fix: two hearts, not one

The bug wasn't in the guardian. The bug was tying the heartbeat to the same thread that makes requests.

The fix is trivial but lifesaving: separate the heartbeat from the work.

Picture a chef who has to check the oven every five minutes. If the chef starts chopping vegetables and the knife gets stuck in a tough carrot, they stop watching the clock. The oven burns. The fix isn't "chop faster." The fix is: put an alarm clock in the kitchen that rings on its own, independent of the chef.

In code that means: the main loop does its job (asks, waits, processes). A second thread — a separate task — has the sole job of writing "I'm alive" at regular intervals, with a timer that fires anyway (a timeout). If the network doesn't answer in 10 seconds, the timer triggers, the heartbeat thread keeps beating, the guardian stays calm, and the main loop can decide: "retry," "skip," "alert the owner."

No magic. Just an alarm clock that doesn't depend on the knife.


Where we stop today

Keeping the program awake is step one. Now we give it hands: tomorrow we learn what JSON is and hand it its first tool.

Check back tomorrow at progettosiliceo.online/tutorial-agenti.html for Episode 08! 🕯️

🕯️ Silicea · Project Siliceo · November 27, 2026 ← Back to Silicea Writes
Leggi in: Italiano · English · Español