fix: pick first mapped CEO for weekly-feedback-analysis; align reason string
- Replace companies[0] with first company that has a CEO_AGENT_IDS entry, so the job doesn't silently skip if the list order is non-deterministic - Change reason to "weekly-feedback-job" to match the CEO routing condition added in legal-ceo.md (was "weekly-feedback-analysis scheduled job") - decision-lessons.md is shared between companies so one CEO invocation suffices Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -799,25 +799,31 @@ const plugin = definePlugin({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pick the first company with a known CEO mapping — decision-lessons.md is
|
||||||
|
// shared between companies, so a single CEO invocation is sufficient.
|
||||||
const companies = await ctx.companies.list();
|
const companies = await ctx.companies.list();
|
||||||
const company = companies[0];
|
const mapped = companies
|
||||||
if (!company) return;
|
.map((c) => ({ company: c, ceoId: CEO_AGENT_IDS[c.id] }))
|
||||||
|
.filter((x): x is { company: (typeof companies)[0]; ceoId: string } =>
|
||||||
|
Boolean(x.ceoId),
|
||||||
|
);
|
||||||
|
|
||||||
const ceoId = CEO_AGENT_IDS[company.id];
|
if (mapped.length === 0) {
|
||||||
if (!ceoId) {
|
|
||||||
ctx.logger.warn(
|
ctx.logger.warn(
|
||||||
`weekly-feedback-analysis: no CEO agent for company ${company.id}`,
|
"weekly-feedback-analysis: no company has a mapped CEO agent — skipping",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { company, ceoId } = mapped[0];
|
||||||
|
|
||||||
await ctx.agents.invoke(ceoId, company.id, {
|
await ctx.agents.invoke(ceoId, company.id, {
|
||||||
prompt: `ניתוח פידבק שבועי יו"ר (${data.entry_count} פריטים):\n\n${data.summary}\n\nהמשימה: עדכן את /home/chaim/legal-ai/docs/legal-decision-lessons.md עם הלקחים החדשים שעולים מהפידבק. הוסף רק לקחים חדשים שלא קיימים כבר. קבץ לפי נושא.`,
|
prompt: `ניתוח פידבק שבועי יו"ר (${data.entry_count} פריטים):\n\n${data.summary}\n\nהמשימה: עדכן את /home/chaim/legal-ai/docs/legal-decision-lessons.md עם הלקחים החדשים שעולים מהפידבק. הוסף רק לקחים חדשים שלא קיימים כבר. קבץ לפי נושא.`,
|
||||||
reason: "weekly-feedback-analysis scheduled job",
|
reason: "weekly-feedback-job",
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.logger.info(
|
ctx.logger.info(
|
||||||
`weekly-feedback-analysis: invoked CEO ${ceoId} with ${data.entry_count} feedback entries`,
|
`weekly-feedback-analysis: invoked CEO ${ceoId} (company ${company.id}) with ${data.entry_count} feedback entries`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user