Skip to content

Heartbeat hook incorrectly attributes main CLI activity to specialist agents #69

@eltmon

Description

@eltmon

Problem

The Panopticon dashboard shows the test-agent (and potentially other specialists) as "active" with a spinner, even when they are sitting idle at a prompt.

Root Cause

The heartbeat hook (~/.panopticon/bin/heartbeat-hook) line 26:

AGENT_ID="${PANOPTICON_AGENT_ID:-$(tmux display-message -p '#S' 2>/dev/null || true)}"

When running Claude Code outside of tmux (e.g., in VS Code integrated terminal), tmux display-message -p '#S' still returns a session name from the tmux server - typically the most recently active session. In this case, it returns specialist-test-agent.

This causes the main CLI tool activity to be written to ~/.panopticon/heartbeats/specialist-test-agent.json, making the dashboard think the test-agent is actively working.

Reproduction:

# Outside of any tmux session (e.g., VS Code terminal)
tmux display-message -p '#S'
# Returns: specialist-test-agent (or another active session)

Solution

Check if we are actually INSIDE a tmux session before using tmux display-message. The $TMUX environment variable is only set when inside a tmux session.

Fix in heartbeat-hook:

# Get agent ID from env (set by pan work issue) or tmux session name
if [ -n "$PANOPTICON_AGENT_ID" ]; then
  AGENT_ID="$PANOPTICON_AGENT_ID"
elif [ -n "$TMUX" ]; then
  # Only use tmux session name if we are actually inside tmux
  AGENT_ID=$(tmux display-message -p '#S' 2>/dev/null)
else
  # Not in tmux, use a distinct identifier for the main CLI
  AGENT_ID="main-cli"
fi
AGENT_ID="${AGENT_ID:-unknown}"

Impact

  • Specialist agent status incorrectly shows "active" when idle
  • Dashboard spinner misleads users about agent activity
  • Could mask actual agent issues if users dismiss the spinner as a false positive

Files to Modify

  • src/templates/hooks/heartbeat-hook (source template)
  • Users will need to re-run pan sync to update their installed hook

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions