openclaw - ✅(Solved) Fix [Bug]: Subagent announce delivered to parallel Telegram channel session instead of originating parent session (single-user, intra-agent) [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#80201Fetched 2026-05-11 03:17:41
View on GitHub
Comments
1
Participants
2
Timeline
14
Reactions
3
Author
Timeline (top)
referenced ×8cross-referenced ×3labeled ×2commented ×1

When a subagent is spawned from agent:main:main and the agent is bound to a Telegram bot, the subagent's completion announce is delivered to the parallel channel-bound session (agent:main:telegram:default:direct:<chat_id>) instead of the originating parent session, so the parent session never observes the result and any logic gated on completion fails to fire.

Root Cause

Affected: any OpenClaw deployment with a single agent bound to a Telegram (or likely any push channel) where work is initiated from agent:main:main rather than from the channel-bound session. Severity: High for any workflow that relies on sub-agent completion to trigger follow-up actions in the parent (logging, chained delegations, user-facing replies), because the parent is never notified. Frequency: Reproducible (2/2 observed attempts on 2026-05-03 in this environment). Consequence: Silent loss of completion signal at the parent session. Manual intervention required to detect that the subagent finished. Logging tied to spawn cycle (e.g. delegation registries) is never written because the parent never receives the close event.

Fix Action

Fix / Workaround

Workaround currently in use: after every sessions_spawn, the parent session manually runs sessions_history against both the main session AND the parallel channel session to detect completion. This defeats the purpose of subagent_announce and is timing-fragile.

PR fix notes

PR #80242: fix: route subagent announce to originating parent session instead of channel-bound peer session

Description (problem / solution / changelog)

Summary

When a subagent is spawned from agent:main:main while a Telegram DM session is active, the completion announce is delivered to the parallel channel-bound session (agent:main:telegram:default:direct:<chat_id>) instead of the originating parent session. The parent never observes the result and any logic gated on completion fails to fire.

Root Cause

Two interacting bugs:

1. Spawn tool receives wrong requester key

The embedded-run pipeline passes sandboxSessionKey (the Telegram peer key) through to createSessionsSpawnTool, which stores it as requesterInternalKey:

attempt.ts:841  → sandboxSessionKey = params.sandboxSessionKey || params.sessionKey
attempt.ts:1010 → sessionKey: sandboxSessionKey  (passed to pi-tools)
pi-tools.ts:797 → agentSessionKey: options?.sessionKey  (= Telegram peer key)
openclaw-tools.ts:402 → createSessionsSpawnTool({ agentSessionKey: ... })
sessions-spawn-tool.ts:394 → requesterInternalKey = resolve(agentSessionKey)

Result: requesterInternalKey = agent:main:telegram:default:direct:<chat_id> instead of agent:main:main.

2. Child binding hijacks delivery target

resolveSubagentCompletionOrigin in subagent-announce-delivery.ts:319-335 checked child session bindings before requester bindings. When both share the same channel + accountId (common for Telegram DMs with a single bot), the child binding won and routed the announce to the Telegram peer session.

Fix

Change 1: Use runSessionKey for spawn tool requester ownership

# src/agents/openclaw-tools.ts:402
createSessionsSpawnTool({
-  agentSessionKey: options?.agentSessionKey,
+  agentSessionKey: options?.runSessionKey ?? options?.agentSessionKey,

The runSessionKey (e.g., agent:main:main) is already threaded through from attempt.ts:1014 and the CreateOpenClawToolsOptions interface. The ?? fallback preserves behavior when no separate run key exists.

Change 2: Check requester binding first, child binding as fallback

# src/agents/subagent-announce-delivery.ts:319-352
- check child session binding FIRST → requester SECOND
+ check requester session binding FIRST → child as FALLBACK

This ensures the parent session's own binding (if any) determines where the announce is delivered, rather than being hijacked by the child's inherited binding.

Tests Added

  • sessions-spawn-tool.test.ts: Verifies agentSessionKey flows correctly to spawnSubagentDirect context, and that the Telegram peer key is not used when a run session key is available.
  • subagent-announce-delivery.test.ts: Verifies requester binding takes priority when both child and requester share the same channel + accountId; verifies child binding still works as fallback when requester has no binding.

Fixes #80201

Changed files

  • src/agents/openclaw-tools.ts (modified, +1/-1)
  • src/agents/subagent-announce-delivery.test.ts (modified, +106/-0)
  • src/agents/subagent-announce-delivery.ts (modified, +8/-8)
  • src/agents/tools/sessions-spawn-tool.test.ts (modified, +45/-0)

Code Example

Anchor case: 2026-05-03, two consecutive subagent spawns from `agent:main:main` for an image-preset calibration. Both subagents finished cleanly with detailed announce payloads (preset config, dry-run output). Both announces were delivered to `agent:main:telegram:default:direct:323421384`; `agent:main:main` received nothing.

The originating parent declared "spawn returned no output" until the user manually pointed out that the result was visible in the parallel session.

Internal note recorded in workspace memory at the time:
"el subagent_announce (sourceTool en provenance) llegó a la sesión agent:main:telegram:default:direct:323421384 en lugar de a la sesión principal agent:main:main"

Workaround currently in use: after every sessions_spawn, the parent session manually runs `sessions_history` against both the main session AND the parallel channel session to detect completion. This defeats the purpose of subagent_announce and is timing-fragile.

Gateway journal slices around the affected timestamps can be provided on request.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When a subagent is spawned from agent:main:main and the agent is bound to a Telegram bot, the subagent's completion announce is delivered to the parallel channel-bound session (agent:main:telegram:default:direct:<chat_id>) instead of the originating parent session, so the parent session never observes the result and any logic gated on completion fails to fire.

Steps to reproduce

  1. Start OpenClaw 2026.5.7 with a single agent (main) bound to one Telegram bot, allowFrom set to one chat_id.
  2. From a session whose key is agent:main:main (driving the agent from the main session, not from a Telegram-channel-bound session), call sessions_spawn to start a subagent run that emits a completion announce on success.
  3. Wait for the subagent to finish (observable via subagent transcript / subagents action=list).
  4. Inspect agent:main:main: the announce is not present, the parent session keeps waiting as if the spawn were still running.
  5. Inspect agent:main:telegram:default:direct:<chat_id>: the announce is there.

Expected behavior

The completion announce is delivered to the originating parent session (the session that issued sessions_spawn). In prior installations (and per the design intent of subagent_announce), the parent that launched the spawn should be the session that observes the result, regardless of whether a parallel channel-bound session also exists for the same agent.

Actual behavior

The announce is routed by sourceChannel / last-touched delivery context for that channel rather than by parentSessionKey. With sourceChannel=telegram, the channel-bound session (agent:main:telegram:default:direct:<chat_id>) wins and receives the announce. The originating session agent:main:main receives nothing and remains in a "waiting on subagent" state until manual intervention.

OpenClaw version

2026.5.7 (eeef486)

Operating system

Ubuntu 24.04.4 LTS (aarch64)

Install method

npm global

Model

anthropic/claude-opus-4-7 (parent), anthropic/claude-sonnet-4-6 (subagent)

Provider / routing chain

openclaw -> anthropic

Additional provider/model setup details

Single agent main configured in ~/.openclaw/openclaw.json. Telegram channel enabled with dmPolicy allowlist, single allowFrom chat_id, groupPolicy disabled. Auth via SecretRef to ~/.openclaw/secrets.json. No proxy or routing gateway between OpenClaw and Anthropic.

Logs, screenshots, and evidence

Anchor case: 2026-05-03, two consecutive subagent spawns from `agent:main:main` for an image-preset calibration. Both subagents finished cleanly with detailed announce payloads (preset config, dry-run output). Both announces were delivered to `agent:main:telegram:default:direct:323421384`; `agent:main:main` received nothing.

The originating parent declared "spawn returned no output" until the user manually pointed out that the result was visible in the parallel session.

Internal note recorded in workspace memory at the time:
"el subagent_announce (sourceTool en provenance) llegó a la sesión agent:main:telegram:default:direct:323421384 en lugar de a la sesión principal agent:main:main"

Workaround currently in use: after every sessions_spawn, the parent session manually runs `sessions_history` against both the main session AND the parallel channel session to detect completion. This defeats the purpose of subagent_announce and is timing-fragile.

Gateway journal slices around the affected timestamps can be provided on request.

Impact and severity

Affected: any OpenClaw deployment with a single agent bound to a Telegram (or likely any push channel) where work is initiated from agent:main:main rather than from the channel-bound session. Severity: High for any workflow that relies on sub-agent completion to trigger follow-up actions in the parent (logging, chained delegations, user-facing replies), because the parent is never notified. Frequency: Reproducible (2/2 observed attempts on 2026-05-03 in this environment). Consequence: Silent loss of completion signal at the parent session. Manual intervention required to detect that the subagent finished. Logging tied to spawn cycle (e.g. delegation registries) is never written because the parent never receives the close event.

Additional information

Possibly related, distinct symptoms:

  • #77292 — same family (deliveryContext not isolated by intended scope) but cross-user case (multi-user same Telegram bot). This report is single-user, single chat_id, intra-agent (between two sessions of the same agent).
  • #79053 — completion announce dropped entirely when parent is idle. Different symptom: there the announce is never delivered anywhere; here it IS delivered, just to the wrong session of the same agent.

Suggested investigation: the subagent_announce delivery path appears to resolve the destination by sourceChannel / last-touched delivery context rather than by parentSessionKey recorded at spawn time. If parentSessionKey=agent:main:main, that should win regardless of sourceChannel.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The completion announce is delivered to the originating parent session (the session that issued sessions_spawn). In prior installations (and per the design intent of subagent_announce), the parent that launched the spawn should be the session that observes the result, regardless of whether a parallel channel-bound session also exists for the same agent.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Subagent announce delivered to parallel Telegram channel session instead of originating parent session (single-user, intra-agent) [1 pull requests, 1 comments, 2 participants]