Skip to content

Heartbeat: configurable workspace file injection to reduce token cost #20649

@zoskebutler

Description

@zoskebutler

Problem

Heartbeat sessions currently inject ALL workspace bootstrap files (AGENTS.md, SOUL.md, MEMORY.md, USER.md, TOOLS.md, IDENTITY.md, plus any custom files like HEARTBEAT.md, AUTOMATIONS.md, etc.) into the system prompt. There's no way to control which files get loaded.

For home automation use cases with frequent heartbeats (every 10 minutes), this adds significant token overhead. Files like MEMORY.md (long-term personal memory, 3-4k+ tokens) and SOUL.md are irrelevant to the heartbeat task, which only needs HEARTBEAT.md and maybe TOOLS.md.

At ~20k tokens per heartbeat cycle and 144 cycles/day, the workspace file overhead accounts for a meaningful chunk of daily cost.

Proposal

Add a config option to specify which workspace files get injected into heartbeat sessions:

{
  agents: {
    defaults: {
      heartbeat: {
        every: "10m",
        model: "claude-sonnet-4-20250514",
        // Only inject these files into heartbeat system prompt
        workspaceFiles: ["HEARTBEAT.md", "AUTOMATIONS.md", "TOOLS.md"]
      }
    }
  }
}

Default behavior: If workspaceFiles is omitted, inject all files (current behavior, no breaking change).

Alternative: An exclude list (workspaceFilesExclude: ["MEMORY.md", "SOUL.md"]) might be easier to maintain since you'd only list what to skip.

Impact

For a 10-minute heartbeat running Sonnet:

  • Current: ~20k tokens/cycle × 144 cycles/day = ~2.9M tokens/day
  • With filtering: could reduce by 5-8k tokens/cycle = ~0.7-1.1M tokens saved/day
  • That's roughly $1-2/day savings on Sonnet alone

Context

Discovered while building a home automation plugin (home-palantir). The heartbeat runs a home intelligence loop that only needs sensor data, automation goals, and tools config — not personal memory or identity files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    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