mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 18:31:10 +00:00
fix(routing): preserve explicit cron account and bound message defaults
Co-authored-by: lbo728 <72309817+lbo728@users.noreply.github.com> Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com>
This commit is contained in:
@@ -299,4 +299,39 @@ describe("resolveDeliveryTarget", () => {
|
||||
expect(result.to).toBe("987654");
|
||||
expect(result.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("explicit delivery.accountId overrides session-derived accountId", async () => {
|
||||
setMainSessionEntry({
|
||||
sessionId: "sess-5",
|
||||
updatedAt: 1000,
|
||||
lastChannel: "telegram",
|
||||
lastTo: "chat-999",
|
||||
lastAccountId: "default",
|
||||
});
|
||||
|
||||
const result = await resolveDeliveryTarget(makeCfg({ bindings: [] }), AGENT_ID, {
|
||||
channel: "telegram",
|
||||
to: "chat-999",
|
||||
accountId: "bot-b",
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.accountId).toBe("bot-b");
|
||||
});
|
||||
|
||||
it("explicit delivery.accountId overrides bindings-derived accountId", async () => {
|
||||
setMainSessionEntry(undefined);
|
||||
const cfg = makeCfg({
|
||||
bindings: [{ agentId: AGENT_ID, match: { channel: "telegram", accountId: "bound" } }],
|
||||
});
|
||||
|
||||
const result = await resolveDeliveryTarget(cfg, AGENT_ID, {
|
||||
channel: "telegram",
|
||||
to: "chat-777",
|
||||
accountId: "explicit",
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.accountId).toBe("explicit");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ export async function resolveDeliveryTarget(
|
||||
channel?: "last" | ChannelId;
|
||||
to?: string;
|
||||
sessionKey?: string;
|
||||
accountId?: string;
|
||||
},
|
||||
): Promise<DeliveryTargetResolution> {
|
||||
const requestedChannel = typeof jobPayload.channel === "string" ? jobPayload.channel : "last";
|
||||
@@ -114,6 +115,11 @@ export async function resolveDeliveryTarget(
|
||||
}
|
||||
}
|
||||
|
||||
// Explicit delivery account should override inferred session/binding account.
|
||||
if (jobPayload.accountId) {
|
||||
accountId = jobPayload.accountId;
|
||||
}
|
||||
|
||||
// Carry threadId when it was explicitly set (from :topic: parsing or config)
|
||||
// or when delivering to the same recipient as the session's last conversation.
|
||||
// Session-derived threadIds are dropped when the target differs to prevent
|
||||
|
||||
@@ -314,6 +314,7 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
channel: deliveryPlan.channel ?? "last",
|
||||
to: deliveryPlan.to,
|
||||
sessionKey: params.job.sessionKey,
|
||||
accountId: deliveryPlan.accountId,
|
||||
});
|
||||
|
||||
const { formattedTime, timeLine } = resolveCronStyleNow(params.cfg, now);
|
||||
|
||||
Reference in New Issue
Block a user