fix: polish reply threading + tool dedupe (thanks @mneves75) (#326)

This commit is contained in:
Peter Steinberger
2026-01-08 00:50:29 +00:00
parent 33e2d53be3
commit 17d052bcda
16 changed files with 193 additions and 350 deletions

View File

@@ -10,10 +10,15 @@ import { logVerbose } from "../../globals.js";
import { registerAgentRunContext } from "../../infra/agent-events.js";
import { defaultRuntime } from "../../runtime.js";
import { stripHeartbeatToken } from "../heartbeat.js";
import type { OriginatingChannelType } from "../templating.js";
import { SILENT_REPLY_TOKEN } from "../tokens.js";
import type { GetReplyOptions, ReplyPayload } from "../types.js";
import type { FollowupRun } from "./queue.js";
import { extractReplyToTag } from "./reply-tags.js";
import {
createReplyToModeFilter,
resolveReplyToMode,
} from "./reply-threading.js";
import { isRoutableChannel, routeReply } from "./route-reply.js";
import { incrementCompactionCount } from "./session-updates.js";
import type { TypingController } from "./typing.js";
@@ -179,6 +184,14 @@ export function createFollowupRunner(params: {
if (stripped.shouldSkip && !hasMedia) return [];
return [{ ...payload, text: stripped.text }];
});
const replyToChannel =
queued.originatingChannel ??
(queued.run.messageProvider?.toLowerCase() as
| OriginatingChannelType
| undefined);
const applyReplyToMode = createReplyToModeFilter(
resolveReplyToMode(queued.run.config, replyToChannel),
);
const replyTaggedPayloads: ReplyPayload[] = sanitizedPayloads
.map((payload) => {
@@ -194,7 +207,8 @@ export function createFollowupRunner(params: {
payload.text ||
payload.mediaUrl ||
(payload.mediaUrls && payload.mediaUrls.length > 0),
);
)
.map(applyReplyToMode);
if (replyTaggedPayloads.length === 0) return;