Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gnarco
Copy link
Contributor

@gnarco gnarco commented Jan 19, 2026

Problem

When a subagent is spawned from a Telegram forum topic, the announce result was being sent to #general instead of the original topic.

Root Cause

The to field (containing the full target path like telegram:group:-123:topic:456) was not being propagated through the tool chain. The DeliveryContext has a to field, but it was never populated when creating the requesterOrigin in sessions-spawn-tool.ts.

Solution

Propagate the to field through the entire chain:

  1. sessions-spawn-tool.ts: Added agentTo param, pass to normalizeDeliveryContext
  2. clawdbot-tools.ts: Added agentTo param, forward to spawn tool
  3. pi-tools.ts: Added messageTo param, forward to clawdbot-tools
  4. pi-embedded-runner/run/types.ts: Added messageTo to EmbeddedRunAttemptParams
  5. pi-embedded-runner/run/params.ts: Added messageTo to RunEmbeddedPiAgentParams
  6. pi-embedded-runner/run.ts: Pass messageTo to attempt
  7. pi-embedded-runner/run/attempt.ts: Pass messageTo to createClawdbotCodingTools
  8. agent-runner-execution.ts: Pass OriginatingTo from sessionCtx
  9. agent-runner-memory.ts: Pass OriginatingTo from sessionCtx
  10. followup-runner.ts: Pass originatingTo from queued run

Testing

  • Existing tests pass
  • Manual testing: spawn a subagent from a Telegram forum topic → result should now appear in the same topic

When a subagent is spawned from a Telegram forum topic, the announce
result was being sent to #general instead of the original topic.

The issue was that the 'to' field (containing the full target path like
'telegram:group:-123:topic:456') was not being propagated through the
tool chain:

- sessions-spawn-tool.ts: Added agentTo param, pass to DeliveryContext
- clawdbot-tools.ts: Added agentTo param, forward to spawn tool
- pi-tools.ts: Added messageTo param, forward to clawdbot-tools
- pi-embedded-runner: Added messageTo to params and attempt
- agent-runner-*.ts: Pass OriginatingTo/To from sessionCtx
- followup-runner.ts: Pass originatingTo from queued run

This ensures subagent results are announced back to the correct
Telegram topic (or other threaded destination) where the spawn
was initiated.
@fayrose
Copy link

fayrose commented Jan 20, 2026

I'm running into a similar slack problem where i speak to clawdbot in a thread, and the reply comes back to the main chat. Would this also solve that?

steipete added a commit that referenced this pull request Jan 20, 2026
@steipete
Copy link
Contributor

Landed via squash on main.

  • Rebased onto main and folded in the thread/topic routing refactor + delivery context updates.
  • Added changelog entry + clawtributors update.
  • Ran pnpm lint && pnpm build && pnpm test.

Commit: 02ca148

Thanks @gnarco!

@steipete steipete closed this Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants