fix: derive prefixes from routed identity (#578) (thanks @p6l-richard)

This commit is contained in:
Peter Steinberger
2026-01-09 16:39:32 +01:00
parent 43848b7b43
commit 66bbb723c5
18 changed files with 156 additions and 27 deletions

View File

@@ -7,6 +7,8 @@
* across multiple providers.
*/
import { resolveAgentIdFromSessionKey } from "../../agents/agent-scope.js";
import { resolveResponsePrefix } from "../../agents/identity.js";
import type { ClawdbotConfig } from "../../config/config.js";
import { sendMessageDiscord } from "../../discord/send.js";
import { sendMessageIMessage } from "../../imessage/send.js";
@@ -26,6 +28,8 @@ export type RouteReplyParams = {
channel: OriginatingChannelType;
/** The destination chat/channel/user ID. */
to: string;
/** Session key for deriving agent identity defaults (multi-agent). */
sessionKey?: string;
/** Provider account id (multi-account). */
accountId?: string;
/** Telegram message thread id (forum topics). */
@@ -60,8 +64,14 @@ export async function routeReply(
params;
// Debug: `pnpm test src/auto-reply/reply/route-reply.test.ts`
const responsePrefix = params.sessionKey
? resolveResponsePrefix(
cfg,
resolveAgentIdFromSessionKey(params.sessionKey),
)
: cfg.messages?.responsePrefix;
const normalized = normalizeReplyPayload(payload, {
responsePrefix: cfg.messages?.responsePrefix,
responsePrefix,
});
if (!normalized) return { ok: true };