Skip to content

fix(telegram): propagate parent thread context to sub-agent sessions - #5296

Closed
Lukavyi wants to merge 2 commits into
openclaw:mainfrom
Lukavyi:fix/subagent-thread-context
Closed

Lukavyi wants to merge 2 commits into
openclaw:mainfrom
Lukavyi:fix/subagent-thread-context

Conversation

@Lukavyi

@Lukavyi Lukavyi commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

When the main agent spawns a sub-agent via sessions_spawn, the child session's toolContext was missing threadId/currentThreadTs. This caused sub-agent message tool calls to route to the General topic instead of the parent's Telegram thread.

Changes

  • src/agents/tools/sessions-spawn-tool.ts: Pass threadId (from opts.agentThreadId) and accountId (from opts.agentAccountId) into the child session's callGateway({ method: 'agent' }) params.

How it works

The gateway's agent handler already resolves currentThreadTs from the threadId param and passes it through runContext → toolContext → message tool. The spawn tool simply wasn't forwarding the parent's thread ID to the child.

Testing

Verified the change compiles. The fix is a 2-line addition passing existing values through an established code path.

When the main agent spawns a sub-agent via sessions_spawn, the child
session's toolContext was missing threadId/currentThreadTs. This caused
sub-agent message tool calls to route to the General topic instead of
the parent's Telegram thread.

Pass agentThreadId and agentAccountId from the parent session into the
child's gateway agent call so that runContext.currentThreadTs is set
correctly for the child session.
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram app: web-ui App: web-ui agents Agent runtime and tooling labels Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: telegram Channel integration: telegram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant