Fix AI hallucinating street addresses and other facts

- Add street/address pattern to answerFor() — returns profile address or empty string
- Update AI prompt: return "UNKNOWN" instead of guessing facts
- Handle UNKNOWN response by treating it as no answer (triggers Telegram ask)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 16:25:32 -08:00
parent fd30646d8a
commit 05739a455b

View File

@@ -153,6 +153,7 @@ export class FormFiller {
}
if (l.includes('email')) return p.email || null;
if (l.includes('phone') || l.includes('mobile')) return p.phone || null;
if (l.includes('street') || (l.includes('address') && !l.includes('email'))) return p.location?.address || '';
if (l.includes('city') && !l.includes('remote')) return p.location?.city || null;
if (l.includes('zip') || l.includes('postal')) return p.location?.zip || null;
if (l.includes('country code') || l.includes('phone country')) return 'United States (+1)';
@@ -242,7 +243,7 @@ Rules:
- For yes/no or multiple choice, return ONLY the exact option text
- For short-answer fields, be brief and direct (1 line)
- Use first person
- Never make up facts
- NEVER guess or fabricate factual information (addresses, numbers, dates, credentials, etc.) — if you don't know, return exactly: UNKNOWN
- Just the answer text — no preamble, no explanation, no quotes`;
const userPrompt = `Candidate: ${this.profile.name?.first} ${this.profile.name?.last}
@@ -275,6 +276,10 @@ Answer:`;
if (!res.ok) return null;
const data = await res.json();
const answer = data.content?.[0]?.text?.trim() || null;
if (answer === 'UNKNOWN') {
console.log(` [AI] "${label}" -> UNKNOWN (skipping)`);
return null;
}
if (answer) console.log(` [AI] "${label}" -> "${answer}"`);
return answer;
} catch {