Skip to content

isHeartbeatEnabledForAgent ignores agents.defaults.heartbeat and implicitly enables heartbeat for default agent #41879

@alexey-pelykh

Description

@alexey-pelykh

Problem

isHeartbeatEnabledForAgent in src/infra/heartbeat-runner.ts has two bugs:

Bug 1: Default agent gets heartbeat with zero configuration

When no heartbeat is configured anywhere (no agents.defaults.heartbeat, no per-agent heartbeat), the fallback returns true for the default agent:

return resolvedAgentId === resolveDefaultAgentId(cfg);

This silently enables heartbeat at the default interval for the default agent even though nobody asked for it. If no heartbeat is configured, heartbeat should be disabled for all agents.

Bug 2: agents.defaults.heartbeat is ignored for enabled/disabled decision

When agents.defaults.heartbeat IS configured but no individual agent has a per-agent heartbeat property, hasExplicitHeartbeatAgents() returns false (it only scans list[].heartbeat, not defaults). The function then falls through to the same default-agent-only fallback, meaning only the default agent gets heartbeat — even though the user explicitly configured heartbeat defaults intending it for all agents.

Affected code

  • hasExplicitHeartbeatAgents(): Only checks per-agent heartbeat, ignores agents.defaults.heartbeat
  • isHeartbeatEnabledForAgent(): Fallback logic unconditionally enables heartbeat for default agent

Expected behavior

Configuration Expected
No heartbeat anywhere All agents disabled
agents.defaults.heartbeat set, no per-agent All agents enabled (using defaults)
Per-agent heartbeat on some agents Only those agents enabled
Both defaults and per-agent Per-agent agents enabled; agents without per-agent inherit defaults

Existing tests encode the bug

The test "falls back to default agent when no explicit heartbeat entries" asserts the broken behavior as correct — it expects only the default agent to be enabled when agents.defaults.heartbeat is set without per-agent entries.


Also tracked downstream: remoteclaw#623

Metadata

Metadata

Assignees

No one assigned

    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