mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:50:50 +00:00
Agents: simplify subagent delivery routing
This commit is contained in:
@@ -379,6 +379,12 @@ function resolveThreadBindingDeliveryOrigin(childSessionKey: string): DeliveryCo
|
||||
});
|
||||
}
|
||||
|
||||
function hasRoutableDeliveryOrigin(
|
||||
origin?: DeliveryContext,
|
||||
): origin is DeliveryContext & { channel: string; to: string } {
|
||||
return Boolean(origin?.channel && origin.to);
|
||||
}
|
||||
|
||||
export async function spawnSubagentDirect(
|
||||
params: SpawnSubagentParams,
|
||||
ctx: SpawnSubagentContext,
|
||||
@@ -740,7 +746,7 @@ export async function spawnSubagentDirect(
|
||||
const deliverInitialChildRunDirectly =
|
||||
requestThreadBinding &&
|
||||
spawnMode === "session" &&
|
||||
Boolean(childSessionOrigin?.channel && childSessionOrigin.to);
|
||||
hasRoutableDeliveryOrigin(childSessionOrigin);
|
||||
const shouldAnnounceCompletion = deliverInitialChildRunDirectly
|
||||
? false
|
||||
: expectsCompletionMessage;
|
||||
|
||||
@@ -40,29 +40,7 @@ export function createChannelOutboundRuntimeSend(params: {
|
||||
const outbound = await loadChannelOutboundAdapter(params.channelId);
|
||||
const threadId = resolveRuntimeThreadId(opts);
|
||||
const replyToId = resolveRuntimeReplyToId(opts);
|
||||
const hasMedia = Boolean(opts.mediaUrl);
|
||||
if (hasMedia && outbound?.sendMedia) {
|
||||
return await outbound.sendMedia({
|
||||
cfg: opts.cfg ?? loadConfig(),
|
||||
to,
|
||||
text,
|
||||
mediaUrl: opts.mediaUrl,
|
||||
mediaAccess: opts.mediaAccess,
|
||||
mediaLocalRoots: opts.mediaLocalRoots,
|
||||
mediaReadFile: opts.mediaReadFile,
|
||||
accountId: opts.accountId,
|
||||
threadId,
|
||||
replyToId,
|
||||
silent: opts.silent,
|
||||
forceDocument: opts.forceDocument,
|
||||
gifPlayback: opts.gifPlayback,
|
||||
gatewayClientScopes: opts.gatewayClientScopes,
|
||||
});
|
||||
}
|
||||
if (!outbound?.sendText) {
|
||||
throw new Error(params.unavailableMessage);
|
||||
}
|
||||
return await outbound.sendText({
|
||||
const buildContext = () => ({
|
||||
cfg: opts.cfg ?? loadConfig(),
|
||||
to,
|
||||
text,
|
||||
@@ -78,6 +56,14 @@ export function createChannelOutboundRuntimeSend(params: {
|
||||
gifPlayback: opts.gifPlayback,
|
||||
gatewayClientScopes: opts.gatewayClientScopes,
|
||||
});
|
||||
const hasMedia = Boolean(opts.mediaUrl);
|
||||
if (hasMedia && outbound?.sendMedia) {
|
||||
return await outbound.sendMedia(buildContext());
|
||||
}
|
||||
if (!outbound?.sendText) {
|
||||
throw new Error(params.unavailableMessage);
|
||||
}
|
||||
return await outbound.sendText(buildContext());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user