fix: pass threadId/to/accountId from parent to subagent gateway call
When spawning a subagent, the requesterOrigin's threadId, to, and
accountId were not forwarded to the callGateway({method:'agent'}) params.
This meant the subagent's runContext had no currentThreadTs or
currentChannelId, so resolveTelegramAutoThreadId could not auto-inject
the forum topic thread ID when the subagent used the message tool.
Changes:
- sessions-spawn-tool: pass to, accountId, threadId from requesterOrigin
- run-context: populate currentChannelId from opts.to as fallback
Fixes subagent messages landing in General Topic instead of the correct
Telegram DM topic thread.
This commit is contained in:
@@ -231,6 +231,10 @@ export function createSessionsSpawnTool(opts?: {
|
|||||||
message: task,
|
message: task,
|
||||||
sessionKey: childSessionKey,
|
sessionKey: childSessionKey,
|
||||||
channel: requesterOrigin?.channel,
|
channel: requesterOrigin?.channel,
|
||||||
|
to: requesterOrigin?.to ?? undefined,
|
||||||
|
accountId: requesterOrigin?.accountId ?? undefined,
|
||||||
|
threadId:
|
||||||
|
requesterOrigin?.threadId != null ? String(requesterOrigin.threadId) : undefined,
|
||||||
idempotencyKey: childIdem,
|
idempotencyKey: childIdem,
|
||||||
deliver: false,
|
deliver: false,
|
||||||
lane: AGENT_LANE_SUBAGENT,
|
lane: AGENT_LANE_SUBAGENT,
|
||||||
|
|||||||
@@ -42,5 +42,14 @@ export function resolveAgentRunContext(opts: AgentCommandOpts): AgentRunContext
|
|||||||
merged.currentThreadTs = String(opts.threadId);
|
merged.currentThreadTs = String(opts.threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate currentChannelId from the outbound target so that
|
||||||
|
// resolveTelegramAutoThreadId can match the originating chat.
|
||||||
|
if (!merged.currentChannelId && opts.to) {
|
||||||
|
const trimmedTo = opts.to.trim();
|
||||||
|
if (trimmedTo) {
|
||||||
|
merged.currentChannelId = trimmedTo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user