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:
@@ -623,17 +623,26 @@ const plugin = definePlugin({
|
||||
latest?.body ||
|
||||
payload?.bodySnippet ||
|
||||
"(לא ניתן לקרוא את התגובה)";
|
||||
} catch {
|
||||
commentBody = payload?.bodySnippet || "(שגיאה בקריאת התגובה)";
|
||||
} catch (err) {
|
||||
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 {
|
||||
const { runId } = await ctx.agents.invoke(ceoAgentId, event.companyId, {
|
||||
prompt: [
|
||||
`תגובה חדשה מחיים על issue "${issue.title}" (${issue.identifier || issueId}):`,
|
||||
"",
|
||||
commentBody,
|
||||
promptBody,
|
||||
"",
|
||||
`קרא את ה-comments האחרונים על ה-issue, הבן מה חיים מבקש, והחלט מה לעשות.`,
|
||||
`אם ההוראה ברורה — נתב לסוכן המתאים. אם לא ברור — שאל את חיים.`,
|
||||
|
||||
Reference in New Issue
Block a user