Skip to content

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

@alexey-pelykh

Description

@alexey-pelykh

Problem

isHeartbeatEnabledForAgent in src/infra/heartbeat-runner.ts:113-123 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 at line 122 returns true for the default agent:

return resolvedAgentId === resolveDefaultAgentId(cfg);

This silently enables heartbeat at the default 1h 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() (line 108-111): Only checks per-agent heartbeat, ignores agents.defaults.heartbeat
  • isHeartbeatEnabledForAgent() (line 113-123): 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

Test at line 228-237 asserts the broken behavior as correct:

it("falls back to default agent when no explicit heartbeat entries", () => {
  // cfg has agents.defaults.heartbeat but no per-agent heartbeat
  // asserts only default agent enabled — THIS IS THE BUG
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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