Discord: allow disabling thread starter context

This commit is contained in:
Josh Palmer
2026-02-04 13:25:28 -08:00
parent 5d82c82313
commit bebf323775
5 changed files with 133 additions and 15 deletions

View File

@@ -31,6 +31,7 @@ export type DiscordGuildEntryResolved = {
enabled?: boolean;
users?: Array<string | number>;
systemPrompt?: string;
includeThreadStarter?: boolean;
autoThread?: boolean;
}
>;
@@ -43,6 +44,7 @@ export type DiscordChannelConfigResolved = {
enabled?: boolean;
users?: Array<string | number>;
systemPrompt?: string;
includeThreadStarter?: boolean;
autoThread?: boolean;
matchKey?: string;
matchSource?: ChannelMatchSource;
@@ -241,6 +243,7 @@ function resolveDiscordChannelConfigEntry(
enabled: entry.enabled,
users: entry.users,
systemPrompt: entry.systemPrompt,
includeThreadStarter: entry.includeThreadStarter,
autoThread: entry.autoThread,
};
return resolved;

View File

@@ -209,22 +209,25 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
let threadLabel: string | undefined;
let parentSessionKey: string | undefined;
if (threadChannel) {
const starter = await resolveDiscordThreadStarter({
channel: threadChannel,
client,
parentId: threadParentId,
parentType: threadParentType,
resolveTimestampMs,
});
if (starter?.text) {
const starterEnvelope = formatThreadStarterEnvelope({
channel: "Discord",
author: starter.author,
timestamp: starter.timestamp,
body: starter.text,
envelope: envelopeOptions,
const includeThreadStarter = channelConfig?.includeThreadStarter !== false;
if (includeThreadStarter) {
const starter = await resolveDiscordThreadStarter({
channel: threadChannel,
client,
parentId: threadParentId,
parentType: threadParentType,
resolveTimestampMs,
});
threadStarterBody = starterEnvelope;
if (starter?.text) {
const starterEnvelope = formatThreadStarterEnvelope({
channel: "Discord",
author: starter.author,
timestamp: starter.timestamp,
body: starter.text,
envelope: envelopeOptions,
});
threadStarterBody = starterEnvelope;
}
}
const parentName = threadParentName ?? "parent";
threadLabel = threadName