CLAUDE LABJP
CONNECTORS — Managed MCP connectors gain connector observability in public beta for adoption, errors, latency, and usageDIRECTORY — Admins can now submit MCP connectors to the directory directly from ClaudeSLACK — Team and Enterprise users can tag Claude in Slack to delegate tasksENTERPRISE — Claude Enterprise adds richer admin analytics, model-level entitlements, and spend alertsMODEL — Claude Sonnet 5 is the default across all plans at $2/$10 per million tokens through August 31LIMITS — Claude Code weekly usage limits are up 50% through July 13; Claude Science applications close July 15CONNECTORS — Managed MCP connectors gain connector observability in public beta for adoption, errors, latency, and usageDIRECTORY — Admins can now submit MCP connectors to the directory directly from ClaudeSLACK — Team and Enterprise users can tag Claude in Slack to delegate tasksENTERPRISE — Claude Enterprise adds richer admin analytics, model-level entitlements, and spend alertsMODEL — Claude Sonnet 5 is the default across all plans at $2/$10 per million tokens through August 31LIMITS — Claude Code weekly usage limits are up 50% through July 13; Claude Science applications close July 15
Articles/Claude Code
Claude Code/2026-07-07Advanced

My background session sat at running all night — adding heartbeats to the agents view

The Claude Code agents view finally lets you see every background session at once, but a running badge is not proof of progress. Here is the external heartbeat layer I built to catch a silently stalled session in minutes instead of the next morning, with real numbers and the traps I hit.

Claude Code183background sessionsunattended automation5indie development14observability16

Premium Article

Last Tuesday, one of the background sessions I had running overnight sat at "running" until morning.

When I opened the agents view, the other eleven showed green checkmarks, and that one still had a spinning icon. Its last log line was seven hours old, and nothing had moved since. The task itself was a trivial dependency bump that should have finished in a couple of minutes. What stayed with me was not what had gone wrong, but why I had not noticed until morning.

As an indie developer, I run a handful of wallpaper apps and a few technical blogs, and every night I batch the small chores — dependency bumps, changelog drafts, crash summaries, ad-config checks — as headless Claude Code runs. On a busy night that is twelve sessions. The July 6, 2026 update that improved the agents view and background-session reliability was a genuinely welcome change for this workflow, letting me see every run on one screen. But after a week of leaning on it, one thing became clear: the agents view tells you a session exists, not that it is making progress.

This article shares the external heartbeat layer and reconciler I built to close that gap.

When running lies to you

Let me start from the failure side, because that is where the need becomes obvious.

Background sessions stall for two broad reasons. One is a crash — the process dies, the agents view flips to a failed state, and it is relatively easy to spot. The nastier one is the second: the process is alive but no longer moving forward.

In just the cases I have personally hit, the states looked like this.

Kind of stallProcessAgents viewActual progress
Hung on a network responsealiverunningstopped
Tool call that never returnsaliverunningstopped
Silent retry loopaliverunningeffectively stopped
Wedged waiting on inputaliverunningstopped

Every one of them keeps showing "running." Presence is true; liveness is false. In observability terms, what we actually want is a proof of life, not a proof of attendance.

That distinction turns fatal under unattended operation. During the day, when a human is watching, a spinner that lingers too long feels wrong and gets noticed. But a background session is in the background precisely because nobody is watching — so there is no one to feel that friction. The stall simply sits there until the next morning.

For tracing a session's identity all the way to a commit, I wrote separately about threading a correlation key through unattended runs with readable session names. This piece is about the layer before that: asking whether the session is even alive right now.

Separating presence from liveness

There is only one design principle here: add a liveness signal to the agents view from the outside.

Concretely, have each background session leave a small "I am still alive" stamp at a fixed cadence. Then a separate tiny process watches the freshness of those stamps. Fresh stamp, alive; stale stamp, suspected stall. That is the heartbeat idea.

Why external? You cannot — and should not — modify the agents view or the session state itself. The only levers you truly hold are emitting a side effect whenever something happens inside the session, and observing that side effect from outside. Combine the two and you can bolt on a liveness layer without breaking any official behavior.

The stamp can be startlingly small. What I actually write is just three fields: session name, epoch seconds, and current phase.

{"session":"wallpaper-ios-deps-0706-a3f","ts":1751850600,"phase":"tool:bash"}

The important choice is using epoch seconds (ts) rather than a date string. I once wrote log dates with a plain date, UTC and JST drifted apart, and a run overwrote the previous day's file. If a machine is going to compare times, hold them as integers that leave no room for timezone interpretation. Freshness then falls out of a single subtraction: current epoch seconds minus ts.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Why the running badge in the agents view cannot reveal a stall, and how separating presence from liveness reshapes the whole design
A complete working setup: a PostToolUse hook stamps each session with a heartbeat, and a reconciler judges staleness using plain epoch seconds
The measured drop from next-morning discovery to a nine-minute median, plus fixes for the three traps: silent thinking, cloud-sync write contention, and long single tools
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Claude Code2026-07-06
Which Nightly Job Wrote This Commit? Threading a Correlation Key Through Claude Code's Readable Session Names
When you run unattended nightly jobs across several repositories, you lose track of which session produced which commit. Here is how I redesigned Claude Code's readable session names into a correlation key that ties commits, logs, and sessions into a single thread — with real numbers.
Claude Code2026-07-04
A 1M Context Window Is the New Default — So I Built an Admission Policy Instead of Filling It
Sonnet 5 is now the Claude Code default and native 1M context is standard. The hard errors disappeared, but a quieter kind of degradation took their place. Here is how I made it visible with a probe, plus an admission policy and an effective-token-cost view — with working code and my own measurements.
Claude Code2026-07-02
Which Model Ran Last Night's Unattended Session? Building Model Attribution and Default-Drift Detection After the Sonnet 5 Switch
Claude Code's default model switched to Sonnet 5, and unpinned headless runs changed models silently. Here is a working design for extracting the actual model from run output, appending an atomic run record, and deciding per task lineage whether to pin or follow the default.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →