-
-
Notifications
You must be signed in to change notification settings - Fork 69k
Bug: Subagent announce delivery fails with wrong WhatsApp account (multi-account routing) #1058
Description
Summary
When a spawned subagent completes and the announce flow attempts to deliver to the requester, it fails with:
Delivery failed (whatsapp to +64273938855): Error: No active WhatsApp Web listener (account: default)
The delivery tries to use the default account instead of the correct account (e.g., kev) because accountId is not propagated through the subagent spawn → announce → delivery chain.
Root Cause
The sessions_spawn tool captures agentChannel (e.g., "whatsapp") but not agentAccountId. When the announce flow later calls callGateway({ method: "agent", deliver: true }), it has no way to specify which account to use for delivery.
The delivery code in delivery.ts tries to get accountId from sessionEntry?.lastAccountId, but when the announce triggers a fresh agent run, the session entry lookup may not have the right account context.
Fix
Thread accountId through the entire subagent lifecycle:
sessions-spawn-tool.ts: AcceptagentAccountIdin tool options, pass toregisterSubagentRun()subagent-registry.ts: StorerequesterAccountIdinSubagentRunRecord, pass torunSubagentAnnounceFlow()subagent-announce.ts: PasschannelandaccountIdto the gatewayagentcallagent.ts(gateway handler): AcceptaccountIdparam, resolve it with fallback tosessionEntry?.lastAccountIddelivery.ts: Useopts.accountIdwith fallback to session-based resolutionagent.ts(schema): AddaccountIdtoAgentParamsSchema
Files Changed
src/agents/tools/sessions-spawn-tool.tssrc/agents/subagent-registry.tssrc/agents/subagent-announce.tssrc/agents/clawdbot-tools.tssrc/commands/agent/types.tssrc/commands/agent/delivery.tssrc/gateway/server-methods/agent.tssrc/gateway/protocol/schema/agent.ts
Testing
- Start gateway with WhatsApp account
kev - Spawn a subagent:
sessions_spawn task="What is 2+2?" agentId="scout" - Wait for completion
- Verify announce is delivered via correct WhatsApp account
Before fix: Delivery fails with "No active WhatsApp Web listener (account: default)"
After fix: Delivery succeeds via account kev