fix(rules): inject end-marker prompt for every non-no-reply discord turn
This commit is contained in:
@@ -63,9 +63,6 @@ function pruneDecisionMap(now = Date.now()) {
|
||||
}
|
||||
}
|
||||
|
||||
function shouldInjectEndMarker(reason: string): boolean {
|
||||
return reason.startsWith("end_symbol:");
|
||||
}
|
||||
|
||||
function getLivePluginConfig(api: OpenClawPluginApi, fallback: WhisperGateConfig): WhisperGateConfig {
|
||||
const root = (api.config as Record<string, unknown>) || {};
|
||||
@@ -335,7 +332,7 @@ export default {
|
||||
}
|
||||
|
||||
sessionDecision.delete(key);
|
||||
if (!shouldInjectEndMarker(rec.decision.reason)) return;
|
||||
if (!rec.decision.shouldInjectEndMarkerPrompt) return;
|
||||
|
||||
api.logger.info(`whispergate: prepend end marker instruction for session=${key}, reason=${rec.decision.reason}`);
|
||||
return { prependContext: END_MARKER_INSTRUCTION };
|
||||
|
||||
@@ -21,6 +21,7 @@ export type ChannelPolicy = {
|
||||
|
||||
export type Decision = {
|
||||
shouldUseNoReply: boolean;
|
||||
shouldInjectEndMarkerPrompt: boolean;
|
||||
reason: string;
|
||||
};
|
||||
|
||||
@@ -64,12 +65,12 @@ export function evaluateDecision(params: {
|
||||
const { config } = params;
|
||||
|
||||
if (config.enabled === false) {
|
||||
return { shouldUseNoReply: false, reason: "disabled" };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: false, reason: "disabled" };
|
||||
}
|
||||
|
||||
const channel = (params.channel || "").toLowerCase();
|
||||
if (config.discordOnly !== false && channel !== "discord") {
|
||||
return { shouldUseNoReply: false, reason: "non_discord" };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: false, reason: "non_discord" };
|
||||
}
|
||||
|
||||
const policy = resolvePolicy(config, params.channelId, params.channelPolicies);
|
||||
@@ -87,20 +88,20 @@ export function evaluateDecision(params: {
|
||||
|
||||
if (mode === "human-list") {
|
||||
if (inHumanList) {
|
||||
return { shouldUseNoReply: false, reason: "human_list_sender" };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: true, reason: "human_list_sender" };
|
||||
}
|
||||
if (hasEnd) {
|
||||
return { shouldUseNoReply: false, reason: `end_symbol:${lastChar}` };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: true, reason: `end_symbol:${lastChar}` };
|
||||
}
|
||||
return { shouldUseNoReply: true, reason: "rule_match_no_end_symbol" };
|
||||
return { shouldUseNoReply: true, shouldInjectEndMarkerPrompt: false, reason: "rule_match_no_end_symbol" };
|
||||
}
|
||||
|
||||
// agent-list mode: listed senders require end symbol; others bypass requirement.
|
||||
if (!inAgentList) {
|
||||
return { shouldUseNoReply: false, reason: "non_agent_list_sender" };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: true, reason: "non_agent_list_sender" };
|
||||
}
|
||||
if (hasEnd) {
|
||||
return { shouldUseNoReply: false, reason: `end_symbol:${lastChar}` };
|
||||
return { shouldUseNoReply: false, shouldInjectEndMarkerPrompt: true, reason: `end_symbol:${lastChar}` };
|
||||
}
|
||||
return { shouldUseNoReply: true, reason: "agent_list_missing_end_symbol" };
|
||||
return { shouldUseNoReply: true, shouldInjectEndMarkerPrompt: false, reason: "agent_list_missing_end_symbol" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user