fix(routing): use bodySnippet fallback + warn log when listComments fails

When ctx.issues.listComments() throws, the previous catch silently
replaced commentBody with "(שגיאה בקריאת התגובה)" — causing CEO to
receive garbage text instead of an actionable instruction.

Now: falls back to payload.bodySnippet (always present in Paperclip
webhooks), logs a proper warning with the real error for diagnosis,
and if even bodySnippet is empty, sends a clear meta-instruction
telling CEO to read comments directly instead of corrupted content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 14:53:31 +00:00
parent b6bf726570
commit 0a8790b088

View File

@@ -623,17 +623,26 @@ const plugin = definePlugin({
latest?.body || latest?.body ||
payload?.bodySnippet || payload?.bodySnippet ||
"(לא ניתן לקרוא את התגובה)"; "(לא ניתן לקרוא את התגובה)";
} catch { } catch (err) {
commentBody = payload?.bodySnippet || "(שגיאה בקריאת התגובה)"; ctx.logger.warn("listComments failed, falling back to bodySnippet", {
issueId, commentId, error: String(err),
});
commentBody = payload?.bodySnippet ?? "";
} }
} }
// If we still have no body, instruct CEO to read comments directly
// rather than sending empty/error content as the instruction.
const promptBody = commentBody
? commentBody
: "(לא ניתן לקרוא את תוכן התגובה — קרא את ה-comments האחרונים על ה-issue ישירות)";
try { try {
const { runId } = await ctx.agents.invoke(ceoAgentId, event.companyId, { const { runId } = await ctx.agents.invoke(ceoAgentId, event.companyId, {
prompt: [ prompt: [
`תגובה חדשה מחיים על issue "${issue.title}" (${issue.identifier || issueId}):`, `תגובה חדשה מחיים על issue "${issue.title}" (${issue.identifier || issueId}):`,
"", "",
commentBody, promptBody,
"", "",
`קרא את ה-comments האחרונים על ה-issue, הבן מה חיים מבקש, והחלט מה לעשות.`, `קרא את ה-comments האחרונים על ה-issue, הבן מה חיים מבקש, והחלט מה לעשות.`,
`אם ההוראה ברורה — נתב לסוכן המתאים. אם לא ברור — שאל את חיים.`, `אם ההוראה ברורה — נתב לסוכן המתאים. אם לא ברור — שאל את חיים.`,