Skip to content

Feature: Add accountId support for heartbeat config #8695

@lsh411

Description

@lsh411

Summary

Currently, heartbeat delivery uses the accountId from the session's deliveryContext (based on previous conversations). When a session has no prior conversation history, heartbeats default to the first/primary Telegram account instead of the agent's intended bot.

This feature request proposes adding support for explicitly specifying accountId in the heartbeat configuration, allowing multi-agent setups to reliably route heartbeat messages to the correct bot.

Problem

In a multi-agent Telegram setup:

  • Agent A (main) → uses bot "default"
  • Agent B (secondary) → uses bot "secondary"

When Agent B's heartbeat fires without prior session history, messages incorrectly route to "default" instead of "secondary".

Proposed Solution

Add optional accountId field to heartbeat config:

{
  "id": "secondary-agent",
  "heartbeat": {
    "every": "1h",
    "target": "telegram",
    "to": "12345678",
    "accountId": "secondary"
  }
}

Suggested Implementation

1. Schema change (zod-schema.agent-runtime.js)

     to: z.string().optional(),
+    accountId: z.string().optional(),
     prompt: z.string().optional(),

2. Logic change (infra/outbound/targets.js)

In resolveHeartbeatDeliveryTarget:

     const resolvedTarget = resolveSessionDeliveryTarget({...});
+    // Use explicit accountId from heartbeat config if provided
+    const effectiveAccountId = heartbeat?.accountId ?? resolvedTarget.accountId;

Then use effectiveAccountId instead of resolvedTarget.accountId throughout the function.

Backward Compatibility

  • If accountId is not specified in config, behavior is unchanged (falls back to session-derived accountId)
  • Existing configs continue to work without modification

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions