-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Feature Request] Allow cron jobs to set session key matching inbound DM reply routing #80212
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
When a cron job sends a proactive message to a Telegram DM topic (thread), the outbound delivery creates a session with one routing key, but when the user replies in the same thread, the inbound message routes to a different session key. This breaks session continuity for cron-initiated conversations.
Problem
We have an isolated cron job (
agentId: "finance") that:messagetool to that topicOutbound delivery session key:
Inbound reply session key:
The difference: the inbound key includes the peer ID (
104506878) becausedmScopeisper-account-channel-peer. The outbound key does not include the peer because it was created by the bot, not by a user message.This means when the user replies to the cron-generated report, OpenClaw creates a new session with no context from the cron run. The agent cannot see the report it just generated, nor the operation mappings.
Config context
Why existing solutions don't work
sessionTarget: "main"— requirespayload.kind: "systemEvent", cannot run full agent workflows (export, sync, message tool calls). NeedagentTurnwhich requiresisolated.sessionTarget: "session:xxx"— named session persists across cron runs, but inbound DM replies still route to the routing-based key, not the named session.sessionTarget: "current"— binds to the session active at cron creation time, not dynamically.sessionKeyon cron job — threadId changes daily (new topic per day), so we can't hardcode it. Even if we could, the agent has no API to create a session with an arbitrary routing key.File-based workaround — works (cron writes mapping to disk, new session reads it), but this is a workaround for what seems like an architectural gap.
Proposed solutions (any of these would help)
Option A: Outbound session key alignment
When a cron agent sends a message via the
messagetool to a DM thread, create/update the session using the same routing key that would be computed for an inbound reply to that thread. This ensures the user's reply finds the same session.Option B: Session key override for cron
Allow cron jobs (or agent tool calls) to explicitly set the session routing key, so the cron can create a session that matches the inbound routing pattern.
Option C: Session key aliasing
Allow linking two session keys as aliases, so inbound routing finds the session regardless of which key was used to create it.
Related
message_thread_idbeing suppressed; this is about session key mismatch)dmScope: "per-account-channel-peer"doesn't address proactive (cron-initiated) messagesEnvironment
dmScope: "per-account-channel-peer"