Fix discussion channel closure handling
This commit is contained in:
@@ -29,6 +29,9 @@ type BeforeModelResolveDeps = {
|
||||
pruneDecisionMap: () => void;
|
||||
shouldDebugLog: (config: DirigentConfig & DebugConfig, channelId?: string) => boolean;
|
||||
ensureTurnOrder: (api: OpenClawPluginApi, channelId: string) => Promise<void> | void;
|
||||
discussionService?: {
|
||||
isClosedDiscussion: (channelId: string) => boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export function registerBeforeModelResolveHook(deps: BeforeModelResolveDeps): void {
|
||||
@@ -47,6 +50,7 @@ export function registerBeforeModelResolveHook(deps: BeforeModelResolveDeps): vo
|
||||
pruneDecisionMap,
|
||||
shouldDebugLog,
|
||||
ensureTurnOrder,
|
||||
discussionService,
|
||||
} = deps;
|
||||
|
||||
api.on("before_model_resolve", async (event, ctx) => {
|
||||
@@ -86,6 +90,15 @@ export function registerBeforeModelResolveHook(deps: BeforeModelResolveDeps): vo
|
||||
|
||||
if (derived.channelId) {
|
||||
sessionChannelId.set(key, derived.channelId);
|
||||
if (discussionService?.isClosedDiscussion(derived.channelId)) {
|
||||
sessionAllowed.set(key, false);
|
||||
api.logger.info(`dirigent: before_model_resolve forcing no-reply for closed discussion channel=${derived.channelId} session=${key}`);
|
||||
return {
|
||||
model: ctx.model,
|
||||
provider: ctx.provider,
|
||||
noReply: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
const resolvedAccountId = resolveAccountId(api, ctx.agentId || "");
|
||||
if (resolvedAccountId) {
|
||||
|
||||
Reference in New Issue
Block a user