Skip to content

Session heartbeat for multi-session liveness detection #27742

@MaximKh

Description

@MaximKh

Feature has not been suggested before.

  • I have verified this feature I am about to request has not been suggested before.

Describe the enhancement you want to request

OpenCode advertises multi-session ("Start multiple agents in parallel on the same project") but provides no way for sessions to detect each other. If a parallel session crashes or hangs, its resources (temp dirs, ports, files) are never released, and other sessions have no way to know.

Add two fields to the existing session table:

  • heartbeat_at — timestamp, written every 30s while session is alive
  • peer_id — unique per process, survives session restarts

Extend the existing compaction/prune to skip sessions with heartbeat_at older than 5 min as stale.

Why core: multi-session is a public feature, but without heartbeat it is unsafe. External modules (MCP, SLM) can read the DB for coordination; core just tracks liveness.

Scope: ~10 lines across 3 existing files (session/schema.ts, session/lifecycle.ts, session/compaction.ts). No new tables, no new config, no new dependencies.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions