Recognize substantive requests for a brief as chat clarification

This commit is contained in:
Dotta 2026-09-11 15:22:21 -05:00
parent 85aaea820a
commit 2f438a0ba0
2 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,17 @@ describe("chat acceptance contracts", () => {
expect(
isChatClarificationReply("Tell me the intended audience and format."),
).toBe(true);
expect(
isChatClarificationReply(
"Thanks — before assigning the welcome-note drafting work, I need a compact brief covering:\n\n- Club and audience: club name and intended readers.\n- Purpose: welcome or next steps.\n- Required content: dates, links, and contacts.\n- Voice: tone and sender.\n- Delivery constraints: format, length, and deadline.\n- Examples or policies: existing notes and approval requirements.",
),
).toBe(true);
expect(isChatClarificationReply("I'll need your details about the audience and format.")).toBe(true);
expect(isChatClarificationReply("We need some information about the club and intended readers.")).toBe(true);
expect(isChatClarificationReply("I needed a compact brief before I assigned the work.")).toBe(false);
expect(isChatClarificationReply("I need a compact brief:")).toBe(false);
expect(isChatClarificationReply("I need information.")).toBe(false);
expect(isChatClarificationReply("I need to create the task and write the note.")).toBe(false);
expect(isChatClarificationReply("Please share:")).toBe(false);
expect(isChatClarificationReply("Please share.")).toBe(false);
expect(

View File

@ -53,6 +53,8 @@ export function isChatClarificationReply(body: string): boolean {
if (body.includes("?")) return true;
const request = body.match(
/\b(?:please\s+(?:share|provide|clarify|confirm)|tell me|let me know)\b([\s\S]*)/i,
) ?? body.match(
/\b(?:I|we)(?:'ll|\s+will)?\s+need\s+(?:(?:a|some|the|your|more|following|compact|short|few|additional)\s+){0,4}(?:brief|details|information|context|clarification)\b([\s\S]*)/i,
);
return Boolean(request && /[\p{L}\p{N}]/u.test(request[1]));
}