Fallback (ai_disabled, ai_error, invalid_json, ai_max_candidates_cap -- any candidate the AI never actually analyzed) now produces classification 'AI_FALLBACK', an explicit technical state that is never part of the 11-class enum sent to OpenAI (the AI itself can never legitimately return it). Previously it silently claimed ACTIONABLE_NOW with confidence 0, which made unanalyzed tickets indistinguishable from genuinely confirmed ones at the classification-label level. Also normalizes blocker_type/waiting_for when the model returns the literal string "null"/"none"/"n/a"/"" instead of JSON null -- done once, in the validation layer (logic/classification.js), not scattered around the workflow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
1006 B
JavaScript
26 lines
1006 B
JavaScript
// AI_FALLBACK e um estado tecnico: significa "a IA nunca analisou este chamado" (erro,
|
|
// timeout, IA desligada, JSON invalido, ou cortado pelo limite de AI_MAX_CANDIDATES). NAO e
|
|
// uma conclusao da IA -- por isso nunca usa uma das 11 classes que a IA pode retornar
|
|
// (ver logic/classification.js). Politica de elegibilidade fica centralizada em
|
|
// logic/cooldown.js (applyFallbackPolicy), nao aqui.
|
|
const AI_FALLBACK_CLASSIFICATION = 'AI_FALLBACK';
|
|
|
|
function buildFallbackClassification(reason) {
|
|
return {
|
|
classification: AI_FALLBACK_CLASSIFICATION,
|
|
actionable_today: false,
|
|
confidence: 0,
|
|
blocker_type: null,
|
|
waiting_for: null,
|
|
next_action: 'Revisar chamado manualmente (nao analisado pela IA)',
|
|
suggested_action_type: 'manual_review',
|
|
business_risk: 'medium',
|
|
reason: `Fallback deterministico: ${reason}`,
|
|
evidence: [],
|
|
is_fallback: true,
|
|
fallback_reason: reason,
|
|
};
|
|
}
|
|
|
|
module.exports = { buildFallbackClassification, AI_FALLBACK_CLASSIFICATION };
|