You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a heartbeat runs with isolatedSession: true on a Telegram topic-scoped session, the newly created isolated session loses the threadId from the base session's deliveryContext. This causes heartbeat responses to be delivered to the group's General topic instead of the correct topic.
Steps to Reproduce
Configure a Telegram group with topics enabled
Have a topic-scoped session (e.g., agent:main:telegram:group:<groupId>:topic:1189)
Enable heartbeat with isolatedSession: true
Wait for heartbeat to trigger on that session
Expected Behavior
The heartbeat isolated session should inherit deliveryContext.threadId from the base session, so responses route to the correct topic.
Actual Behavior
The isolated session's deliveryContext is missing threadId. Responses route to the group's General topic instead.
{
"deliveryContext": {
"channel": "telegram",
"to": "telegram:-1003577364307",
"accountId": "default"// threadId is missing!
},
"chatType": "direct"// should be "group"
}
Root Cause (source code analysis)
In heartbeat-runner-*.js, resolveCronSession() is called with forceNew: true to create the isolated session. The new session entry explicitly sets deliveryContext: void 0 (line ~89):
This clears the delivery context for the new session. Later, when the heartbeat response needs to be delivered, it falls back through lastTo → origin.to, neither of which carries the threadId.
Additionally, chatType is set to "direct" instead of inheriting "group" from the base session.
Additional Context
The MessageThreadId is correctly passed to the inbound message context (line ~708), but this doesn't fix the session metadata used for delivery routing.
Description
When a heartbeat runs with
isolatedSession: trueon a Telegram topic-scoped session, the newly created isolated session loses thethreadIdfrom the base session'sdeliveryContext. This causes heartbeat responses to be delivered to the group's General topic instead of the correct topic.Steps to Reproduce
agent:main:telegram:group:<groupId>:topic:1189)isolatedSession: trueExpected Behavior
The heartbeat isolated session should inherit
deliveryContext.threadIdfrom the base session, so responses route to the correct topic.Actual Behavior
The isolated session's
deliveryContextis missingthreadId. Responses route to the group's General topic instead.Base session metadata:
{ "deliveryContext": { "channel": "telegram", "to": "telegram:-1003577364307", "accountId": "default", "threadId": 1189 } }Heartbeat isolated session metadata:
{ "deliveryContext": { "channel": "telegram", "to": "telegram:-1003577364307", "accountId": "default" // threadId is missing! }, "chatType": "direct" // should be "group" }Root Cause (source code analysis)
In
heartbeat-runner-*.js,resolveCronSession()is called withforceNew: trueto create the isolated session. The new session entry explicitly setsdeliveryContext: void 0(line ~89):This clears the delivery context for the new session. Later, when the heartbeat response needs to be delivered, it falls back through
lastTo→origin.to, neither of which carries thethreadId.Additionally,
chatTypeis set to"direct"instead of inheriting"group"from the base session.Additional Context
MessageThreadIdis correctly passed to the inbound message context (line ~708), but this doesn't fix the session metadata used for delivery routing.Suggested Fix
When creating a heartbeat isolated session, inherit
deliveryContext(includingthreadId) andchatTypefrom the base session entry.