Fix address hallucination and duplicate status messages

- answerFor returning '' (intentionally blank) was treated as falsy,
  falling through to AI which fabricated "123 Main Street". Now
  empty string skips the field without triggering AI or reporting unknown.
- status.mjs was printing to stdout AND sending via Telegram, causing
  OpenClaw to relay a duplicate plain-text copy. Now only prints to
  stdout when Telegram isn't configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 16:47:18 -08:00
parent 84a98e7839
commit 38dabbd6dd
2 changed files with 10 additions and 3 deletions

View File

@@ -607,9 +607,10 @@ Answer:`;
let formatHint = field.placeholder ? `(format: ${field.placeholder})` : ''; let formatHint = field.placeholder ? `(format: ${field.placeholder})` : '';
if (field.type === 'number') formatHint = '(must be a number, no text or units)'; if (field.type === 'number') formatHint = '(must be a number, no text or units)';
let answer = this.answerFor(lbl); let answer = this.answerFor(lbl);
// answerFor returns null (no match) vs '' (intentionally blank — skip AI, leave empty)
// For number fields, always try AI if no answer — LinkedIn validates them even if not marked required // For number fields, always try AI if no answer — LinkedIn validates them even if not marked required
const needsAnswer = field.required || field.type === 'number'; const needsAnswer = field.required || field.type === 'number';
if (!answer && needsAnswer) { if (answer === null && needsAnswer) {
answer = await this.aiAnswerFor(formatHint ? `${lbl} ${formatHint}` : lbl); answer = await this.aiAnswerFor(formatHint ? `${lbl} ${formatHint}` : lbl);
if (answer) this.saveAnswer(lbl, answer); if (answer) this.saveAnswer(lbl, answer);
} }
@@ -618,6 +619,10 @@ Answer:`;
const num = String(answer).replace(/[^\d.]/g, ''); const num = String(answer).replace(/[^\d.]/g, '');
if (num) answer = num; if (num) answer = num;
} }
if (answer === '') {
// Intentionally blank (e.g. street address) — skip without reporting unknown
continue;
}
if (answer && answer !== this.profile.cover_letter) { if (answer && answer !== this.profile.cover_letter) {
const el = await byTag(field.tag); const el = await byTag(field.tag);
if (!el) continue; if (!el) continue;

View File

@@ -267,9 +267,11 @@ if (jsonMode) {
} else { } else {
const report = formatReport(status); const report = formatReport(status);
const settings = loadConfig(resolve(__dir, 'config/settings.json')); const settings = loadConfig(resolve(__dir, 'config/settings.json'));
// Always send via Telegram directly if configured (so markdown renders) // Send via Telegram directly if configured (so markdown renders)
if (settings.notifications?.bot_token && settings.notifications?.telegram_user_id) { if (settings.notifications?.bot_token && settings.notifications?.telegram_user_id) {
await sendTelegram(settings, report); await sendTelegram(settings, report);
// Don't also print to stdout — OpenClaw would relay it as a duplicate plain-text message
} else {
console.log(report);
} }
console.log(report);
} }