fix(secretaria): não injetar agenda interna (sec_calendar) quando há agenda real
O nó `calendar` despejava o sec_calendar (agenda interna/de teste do motor) no prompt, criando uma "agenda-fantasma" que conflitava com a agenda real do satélite e podia fazer a IA oferecer horários inexistentes. Agora, quando há ponte configurada (agenda_url/clinica_id), getCalendarContext instrui a usar a ferramenta listar_horarios em vez de listar o sec_calendar. Sem satélite, o fallback interno continua igual. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -799,6 +799,18 @@ class ProtocolEngine {
|
|||||||
}
|
}
|
||||||
// ── Calendar Context ──────────────────────────────────────────────────────
|
// ── Calendar Context ──────────────────────────────────────────────────────
|
||||||
async getCalendarContext() {
|
async getCalendarContext() {
|
||||||
|
// Quando há AGENDA REAL (satélite pareado / ponte configurada), NÃO despejar o
|
||||||
|
// sec_calendar aqui — ele é a agenda INTERNA/de teste do motor e, injetado no
|
||||||
|
// prompt, vira uma "agenda-fantasma" que conflita com a agenda real. Nesses
|
||||||
|
// casos a disponibilidade vem SEMPRE da ferramenta listar_horarios.
|
||||||
|
let cfg = {};
|
||||||
|
try {
|
||||||
|
cfg = await this.config.get('secretaria');
|
||||||
|
}
|
||||||
|
catch { /* segue */ }
|
||||||
|
if (cfg?.agenda_url || cfg?.clinica_id) {
|
||||||
|
return 'A agenda real da clínica é consultada pela ferramenta listar_horarios (por dia e período). NÃO ofereça nenhuma lista fixa de horários aqui — sempre consulte a ferramenta antes de propor um horário.';
|
||||||
|
}
|
||||||
const today = new Date().toISOString().split('T')[0];
|
const today = new Date().toISOString().split('T')[0];
|
||||||
const nextWeek = new Date();
|
const nextWeek = new Date();
|
||||||
nextWeek.setDate(nextWeek.getDate() + 7);
|
nextWeek.setDate(nextWeek.getDate() + 7);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -834,6 +834,16 @@ export class ProtocolEngine {
|
|||||||
// ── Calendar Context ──────────────────────────────────────────────────────
|
// ── Calendar Context ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
private async getCalendarContext(): Promise<string> {
|
private async getCalendarContext(): Promise<string> {
|
||||||
|
// Quando há AGENDA REAL (satélite pareado / ponte configurada), NÃO despejar o
|
||||||
|
// sec_calendar aqui — ele é a agenda INTERNA/de teste do motor e, injetado no
|
||||||
|
// prompt, vira uma "agenda-fantasma" que conflita com a agenda real. Nesses
|
||||||
|
// casos a disponibilidade vem SEMPRE da ferramenta listar_horarios.
|
||||||
|
let cfg: any = {}
|
||||||
|
try { cfg = await this.config.get('secretaria') } catch { /* segue */ }
|
||||||
|
if (cfg?.agenda_url || cfg?.clinica_id) {
|
||||||
|
return 'A agenda real da clínica é consultada pela ferramenta listar_horarios (por dia e período). NÃO ofereça nenhuma lista fixa de horários aqui — sempre consulte a ferramenta antes de propor um horário.'
|
||||||
|
}
|
||||||
|
|
||||||
const today = new Date().toISOString().split('T')[0]
|
const today = new Date().toISOString().split('T')[0]
|
||||||
const nextWeek = new Date()
|
const nextWeek = new Date()
|
||||||
nextWeek.setDate(nextWeek.getDate() + 7)
|
nextWeek.setDate(nextWeek.getDate() + 7)
|
||||||
|
|||||||
Reference in New Issue
Block a user