fix(auto-reply): acknowledge reset triggers

This commit is contained in:
Peter Steinberger
2025-12-10 15:55:20 +00:00
parent 8f456ea73b
commit 51d77aea2e
5 changed files with 108 additions and 82 deletions

View File

@@ -582,15 +582,24 @@ export async function getReplyFromConfig(
? applyTemplate(reply.bodyPrefix ?? "", sessionCtx)
: "";
const baseBody = sessionCtx.BodyStripped ?? sessionCtx.Body ?? "";
const baseBodyTrimmed = baseBody.trim();
const rawBodyTrimmed = (ctx.Body ?? "").trim();
const isBareSessionReset =
isNewSession && baseBodyTrimmed.length === 0 && rawBodyTrimmed.length > 0;
// Bail early if the cleaned body is empty to avoid sending blank prompts to the agent.
// This can happen if an inbound platform delivers an empty text message or we strip everything out.
if (!baseBody.trim()) {
if (!baseBodyTrimmed) {
await onReplyStart();
if (isBareSessionReset) {
cleanupTyping();
return {
text: "Started a fresh session. Send a new message to continue.",
};
}
logVerbose("Inbound body empty after normalization; skipping agent run");
cleanupTyping();
return {
text:
"I didn't receive any text in your message. Please resend or add a caption.",
text: "I didn't receive any text in your message. Please resend or add a caption.",
};
}
const abortedHint =